In Hibernate 3, in the org.hibernate.cfg.Configuration class there is a Map classes property that contains objects of type org.hibernate.mapping.PersistentClass.
In a Grails application (which uses hibernate underneath the covers) I was extending a class that was extending the org.hibernate.cfg.Configuration. This allowed me to tap into the Map classes and do as follows:
for(PersistentClass pc : classes.values()) {
for(Iterator iterator = pc.getTable().getForeignKeyIterator(); iterator.hasNext(); ) {
ForeignKey fk = (ForeignKey) iterator.next();
iterator.remove();
}
}
Basically, I am removing the foreign keys to certain 3rd party tables.
I want to upgrade to Hibernate 5 but the new Configuration class does not have the Map classes that I depend on.
How do I get the map of PersistentClass objects so that I can continue to remove their foreign key?
If it is not supposed to be done through the Configuration anymore, how do I get access to the persistent objects? Through what class?
Please help. I am stuck.