List of usage examples for org.hibernate.mapping RootClass getSubclassIterator
public Iterator getSubclassIterator()
From source file:org.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration.java
License:Apache License
/** * Creates foreign keys for subclass tables that are mapped using table per subclass. Further information is * available in the <a href="http://jira.grails.org/browse/GRAILS-7729">JIRA ticket</a> *//* w w w. j ava 2 s. c o m*/ private void createSubclassForeignKeys() { if (subclassForeignKeysCreated) { return; } for (PersistentClass persistentClass : classes.values()) { if (persistentClass instanceof RootClass) { RootClass rootClass = (RootClass) persistentClass; if (rootClass.hasSubclasses()) { Iterator subclasses = rootClass.getSubclassIterator(); while (subclasses.hasNext()) { Object subclass = subclasses.next(); // This test ensures that foreign keys will only be created for subclasses that are // mapped using "table per subclass" if (subclass instanceof JoinedSubclass) { JoinedSubclass joinedSubclass = (JoinedSubclass) subclass; joinedSubclass.createForeignKey(); } } } } } subclassForeignKeysCreated = true; }