List of usage examples for org.hibernate.mapping Collection getCollectionTable
public Table getCollectionTable()
From source file:com.enonic.cms.store.hibernate.cache.invalidation.InvalidationRulesBuilder.java
License:Open Source License
/** * Build the value mapping.//from w w w.j a v a 2 s . com */ private void buildMapping(Collection mapping) { String cacheRegion = mapping.getCacheRegionName(); String collectionTable = mapping.getCollectionTable().getName(); TableInvalidation rules = getOrCreateTableRule(collectionTable); rules.addCollectionRole(cacheRegion); }
From source file:com.github.shyiko.rook.target.hibernate4.cache.PrimaryKey.java
License:Apache License
public PrimaryKey(Collection collection, Map<String, Integer> columnIndexByNameMap) { this(collection.getKey(), collection.getCollectionTable(), columnIndexByNameMap); if (positionWithinRow.length != 1) { throw new IllegalStateException("Unexpected PK length " + positionWithinRow.length); }//from ww w.j a v a2 s . com }
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 ww.ja va 2 s .c om } return false; }
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; }/*from www . ja v a 2 s.c o m*/ } return false; }
From source file:com.vecna.maven.hibernate.HibernateDocMojo.java
License:Apache License
/** * Populate Hibernate properties with comments from javadocs (including nested properties). * @param propertyIterator iterator over top-level properties * @param accumulatedJavadoc comments accumulated so far (for nested properties) *//*from w w w .jav a 2 s. co m*/ private void processProperties(Iterator<Property> propertyIterator, Class<?> cls, JavaDocBuilder javaDocs, String accumulatedJavadoc) { JavaClass javaClass = javaDocs.getClassByName(cls.getName()); if (javaClass != null) { while (propertyIterator.hasNext()) { Property prop = propertyIterator.next(); Value value = prop.getValue(); if (value instanceof Collection) { Collection collection = (Collection) value; Value elementValue = collection.getElement(); if (elementValue instanceof Component) { processComponent((Component) elementValue, javaDocs, accumulatedJavadoc); } Table collectionTable = collection.getCollectionTable(); if (collectionTable.getComment() == null) { collectionTable.setComment(getSimpleValueJavadoc(prop, cls, javaClass)); } } else if (value instanceof Component) { String comment = getSimpleValueJavadoc(prop, cls, javaClass); comment = accumulateJavadoc(comment, accumulatedJavadoc); processComponent((Component) value, javaDocs, comment); } else if (value instanceof SimpleValue) { String comment = getSimpleValueJavadoc(prop, cls, javaClass); comment = accumulateJavadoc(comment, accumulatedJavadoc); setComment(comment, prop); } } } }
From source file:com.xpn.xwiki.store.migration.hibernate.R40000XWIKI6990DataMigration.java
License:Open Source License
/** * Retrieve the list of table that store collections of the provided persisted class, and that need to be manually * updated, since no cascaded update has been added for them. * * @param pClass the persisted class to analyse * @return a list of dual string, the first is the table name, and the second is the key in that table. *///from www . j av a 2 s.c o m private List<String[]> getCollectionProperties(PersistentClass pClass) { List<String[]> list = new ArrayList<String[]>(); if (pClass != null) { for (org.hibernate.mapping.Collection coll : getCollection(pClass)) { Table collTable = coll.getCollectionTable(); if (!this.fkTables.contains(collTable)) { list.add(new String[] { collTable.getName(), getKeyColumnName(coll) }); } } } return list; }
From source file:com.xpn.xwiki.store.migration.hibernate.R40000XWIKI6990DataMigration.java
License:Open Source License
/** * Retrieve the list of table that store collections of the provided persisted class. * * @param pClass the persisted class to analyse * @param all if false, return only collection that need manual updates, * see {@link #getCollectionProperties(PersistentClass pClass)} * @return a list of dual string, the first is the table name, and the second is the key in that table. *//*from www. j a v a 2 s.c om*/ private List<String[]> getCollectionProperties(PersistentClass pClass, boolean all) { List<String[]> list = new ArrayList<String[]>(); if (pClass != null) { for (org.hibernate.mapping.Collection coll : getCollection(pClass)) { Table collTable = coll.getCollectionTable(); if (all || !this.fkTables.contains(collTable)) { list.add(new String[] { collTable.getName(), getKeyColumnName(coll) }); } } } return list; }
From source file:com.xpn.xwiki.store.migration.hibernate.R40000XWIKI6990DataMigration.java
License:Open Source License
/** * Append change log to fix identifier type of a given persistent class. Collection table storing properties of this * persistent class will also be updated. * //from w ww . j a va2 s .com * @param sb the string builder to append to * @param pClass the persistent class to process */ private void appendDataTypeChangeLogs(StringBuilder sb, PersistentClass pClass) { if (pClass != null) { appendDataTypeChangeLog(sb, pClass.getTable(), getKeyColumnName(pClass)); // Update identifiers in ALL collection tables for (org.hibernate.mapping.Collection coll : getCollection(pClass)) { appendDataTypeChangeLog(sb, coll.getCollectionTable(), getKeyColumnName(coll)); } } }
From source file:com.xpn.xwiki.store.migration.hibernate.R40000XWIKI6990DataMigration.java
License:Open Source License
/** * Retrieve a list of tables used to store the given persistent class, that need to be processed for FK constraints. * The list include the main table use to persist the class, if this table has FK, as well as, all the collection * table used for storing this persisted class properties. * * @param pClass the persistent class to analyze * @return a list of table// w w w . j a va 2 s .c om */ private List<Table> getForeignKeyTables(PersistentClass pClass) { List<Table> list = new ArrayList<Table>(); if (pClass != null) { Table table = pClass.getTable(); if (checkFKtoPKinTable(table)) { list.add(table); } @SuppressWarnings("unchecked") Iterator<Property> it = pClass.getPropertyIterator(); while (it.hasNext()) { Property property = it.next(); if (property.getType().isCollectionType()) { org.hibernate.mapping.Collection coll = (org.hibernate.mapping.Collection) property.getValue(); Table collTable = coll.getCollectionTable(); if (checkFKtoPKinTable(collTable)) { list.add(collTable); } } } } return list; }
From source file:edu.wustl.common.util.dbManager.HibernateMetaData.java
License:BSD License
public static void getDATA(Class classObj) { org.hibernate.mapping.Collection coll = cfg.getCollectionMapping( "edu.wustl.catissuecore.domain.CollectionProtocolEvent.specimenRequirementCollection"); //System.out.println(map); System.out.println(coll.getCollectionTable().getName()); System.out.println(coll.getTable().getName()); //System.out.println(); Iterator it = coll.getColumnIterator(); while (it.hasNext()) { //org.hibernate.mapping.Set set = (org.hibernate.mapping.Set)it.next(); System.out.println(it.next()); }//w w w. j a v a 2s .c om }