List of usage examples for org.hibernate.mapping ForeignKey getTable
public Table getTable()
From source file:com.medigy.tool.persist.hibernate.dbdd.MedigyDatabaseStructureRules.java
License:Open Source License
public boolean isParentRelationship(final TableStructure structure, final ForeignKey foreignKey) { for (Iterator colls = structure.getConfiguration().getCollectionMappings(); colls.hasNext();) { final Collection coll = (Collection) colls.next(); if (coll.isOneToMany()) { if (foreignKey.getReferencedTable() == coll.getOwner().getTable() && foreignKey.getTable() == coll.getCollectionTable()) return true; }//from w w w . j a v a 2 s.c o m } return false; }
From source file:com.medigy.tool.persist.hibernate.dbdd.MedigyDatabaseStructureRules.java
License:Open Source License
public boolean isSubclassRelationship(final TableStructure structure, final ForeignKey foreignKey) { PersistentClass sourceClass = structure.getClassForTable(foreignKey.getTable()); PersistentClass refClass = structure.getClassForTable(foreignKey.getReferencedTable()); return refClass.getMappedClass().isAssignableFrom(sourceClass.getMappedClass()); }
From source file:com.netspective.medigy.util.HibernateDiagramReferenceTableNodeGenerator.java
License:Open Source License
public String getEdgeSourceElementAndPort(final HibernateDiagramGenerator generator, final HibernateDiagramGeneratorFilter filter, final ForeignKey foreignKey) { return foreignKey.getTable().getName(); }
From source file:com.netspective.tool.hibernate.document.diagram.HibernateDiagramGenerator.java
License:Open Source License
/** * Ascertain whether the referenced class in the foreign key relationship is a superclass of the source * class.// ww w. j a v a 2 s. co m * * @param foreignKey The foreign key relationship * * @return True if the source of the foreign key is a subclass of the referenced class */ public boolean isSubclassRelationship(final ForeignKey foreignKey) { PersistentClass sourceClass = getClassForTable(foreignKey.getTable()); PersistentClass refClass = getClassForTable(foreignKey.getReferencedTable()); return refClass.getMappedClass().isAssignableFrom(sourceClass.getMappedClass()); }
From source file:com.netspective.tool.hibernate.document.diagram.HibernateDiagramGenerator.java
License:Open Source License
public boolean isParentRelationship(final ForeignKey foreignKey) { for (Iterator colls = getConfiguration().getCollectionMappings(); colls.hasNext();) { final Collection coll = (Collection) colls.next(); if (coll.isOneToMany()) { // for parents, we put the crow arrow pointing to us (the source becomes the parent, not the child -- this way it will look like a tree) if (foreignKey.getReferencedTable() == coll.getOwner().getTable() && foreignKey.getTable() == coll.getCollectionTable()) return true; }/* w w w .j av a 2s . co m*/ } return false; }
From source file:com.netspective.tool.hibernate.document.diagram.HibernateDiagramTableStructureNodeGenerator.java
License:Open Source License
public String getEdgeSourceElementAndPort(final HibernateDiagramGenerator generator, final HibernateDiagramGeneratorFilter filter, final ForeignKey foreignKey) { // the subclass will point to the superclass and be formatted as a "back" reference to properly set the weight if (filter.isShowClassStructure(generator, foreignKey) && generator.isSubclassRelationship(foreignKey)) return foreignKey.getReferencedTable().getName(); // for parents, we put the crow arrow pointing to us (the source becomes the parent, not the child -- this way it will look like a tree) if (generator.isParentRelationship(foreignKey)) return foreignKey.getReferencedTable().getName(); return filter.isIncludeEdgePort(generator, foreignKey, true) ? (foreignKey.getTable().getName() + ":" + (showConstraints/*ww w .j av a 2 s . c om*/ ? (foreignKey.getColumn(0).getName() + HibernateDiagramFilter.COLUMN_PORT_NAME_CONSTRAINT_SUFFIX) : foreignKey.getColumn(0).getName())) : foreignKey.getTable().getName(); }
From source file:com.netspective.tool.hibernate.document.diagram.HibernateDiagramTableStructureNodeGenerator.java
License:Open Source License
public String getEdgeDestElementAndPort(final HibernateDiagramGenerator generator, final HibernateDiagramGeneratorFilter filter, final ForeignKey foreignKey) { // the subclass will point to the superclass and be formatted as a "back" reference to properly set the weight if (filter.isShowClassStructure(generator, foreignKey) && generator.isSubclassRelationship(foreignKey)) return foreignKey.getTable().getName(); // for parents, we put the crow arrow pointing to us (the source becomes the parent, not the child -- this way it will look like a tree) if (generator.isParentRelationship(foreignKey)) return foreignKey.getTable().getName(); return filter.isIncludeEdgePort(generator, foreignKey, false) ? (foreignKey.getReferencedTable().getName() + ":" + foreignKey.getReferencedTable().getPrimaryKey().getColumn(0).getName()) : foreignKey.getReferencedTable().getName(); }
From source file:com.siemens.scr.avt.ad.query.common.NaturalJoinTreeLoadingStrategy.java
License:Open Source License
private void processFKs(NaturalJoinTree tree, Set<ForeignKey> fks) { for (ForeignKey fk : fks) { assert fk.getColumnSpan() == 1;// we do not allow composite FK for now String columnName = fk.getColumn(0).getName(); Table contextTable = fk.getTable(); String table = tableNameFromTable(contextTable); String entityName = fk.getReferencedEntityName(); PersistentClass referencedPC = getConfig().getClassMapping(entityName); String referencedTable = tableNameFromPersistentClass(referencedPC); tree.handleFK(table, referencedTable, columnName); }/*from w w w .jav a2 s . co m*/ }
From source file:org.openeos.tools.hibernate.hbm2java.UnoReverseEngineeringStrategy.java
License:Apache License
@Override public boolean isOneToOne(ForeignKey foreignKey) { Map tableMap = this.tableToMetaAttributes(TableIdentifier.create(foreignKey.getTable())); if (tableMap != null) { MetaAttribute forceOneToOne = (MetaAttribute) tableMap.get("force-one-to-one"); if (forceOneToOne != null) { String[] fks = forceOneToOne.getValue().split(","); for (int i = 0; i < fks.length; i++) { if (fks[i].trim().equalsIgnoreCase(foreignKey.getName())) { return true; }/* w ww.j a va 2 s.co m*/ } } } return super.isOneToOne(foreignKey); }
From source file:org.sns.tool.hibernate.analyzer.HibernateAnalysis.java
License:Open Source License
public boolean isParentRelationship(final ForeignKey foreignKey) { for (Iterator colls = getConfiguration().getCollectionMappings(); colls.hasNext();) { final Collection coll = (Collection) colls.next(); if (coll.isOneToMany()) { if (foreignKey.getReferencedTable() == coll.getOwner().getTable() && foreignKey.getTable() == coll.getCollectionTable()) return true; }/*from ww w .j a va2 s . c o m*/ } return false; }