/** * Returns a list of DbAttributes that are mapped to foreign keys. * * @since 1.2 */ public Collection<DbAttribute> getMeaningfulFKs(ObjEntity objEntity) { List<DbAttribute> fks = new ArrayList<>(2); for (ObjAttribute property : objEntity.getAttributes()) { DbAttribute column = property.getDbAttribute(); // check if adding it makes sense at all if (column != null && column.isForeignKey()) { fks.add(column); } } return fks; }
/** * Returns a list of ObjAttributes that are mapped to foreign keys. * * @since 1.2 */ public Collection getMeaningfulFKs(ObjEntity objEntity) { List fks = new ArrayList(2); Iterator it = objEntity.getAttributes().iterator(); while (it.hasNext()) { ObjAttribute property = (ObjAttribute) it.next(); DbAttribute column = property.getDbAttribute(); // check if adding it makes sense at all if (column != null && column.isForeignKey()) { fks.add(column); } } return fks; }
protected void createRelationships(DbEntity entity) { for (DbAttribute attribute : entity.getAttributes()) { String name = attribute.getName(); if (name.length() < 4) { continue; } if (!name.substring(name.length() - 3, name.length()).equalsIgnoreCase("_ID")) { continue; } String baseName = name.substring(0, name.length() - 3); for (DbEntity targetEntity : entities) { // TODO: should we handle relationships to self?? if (targetEntity == entity) { continue; } if (baseName.equalsIgnoreCase(targetEntity.getName()) && !attribute.isPrimaryKey() && !targetEntity.getAttributes().isEmpty()) { if (!attribute.isForeignKey()) { InferredRelationship myir = new InferredRelationship(); myir.setSource(entity); myir.setTarget(targetEntity); inferredRelationships.add(myir); } createReversRelationship(targetEntity, entity); } } } }
public boolean visitToOne(ToOneProperty property) { ObjRelationship rel = property.getRelationship(); DbRelationship dbRel = rel.getDbRelationships().get(0); for (DbJoin join : dbRel.getJoins()) { DbAttribute src = join.getSource(); if (src.isForeignKey() && visited.add(src.getName())) { entityResult.addDbField(src.getName(), prefix + index[0]++); } } return true; } };
public boolean visitToOne(ToOneProperty property) { ObjRelationship rel = property.getRelationship(); DbRelationship dbRel = rel.getDbRelationships().get(0); for (DbJoin join : dbRel.getJoins()) { DbAttribute src = join.getSource(); if (src.isForeignKey() && visited.add(src.getName())) { result.addDbField("fetch." + prefix + "." + src.getName(), prefix + "." + src.getName()); } } return true; } };
if (index >= 0 && !dbAttribute.isForeignKey()) { continue;
if (index >= 0 && !dbAttribute.isForeignKey()) { continue;