We have several standalone systems using Hibernate that load a few classes/mappings. I have been adding classes to the mapping dynamically by doing something like this:
Code:
if (this.configuration.getClassMapping(clazz) == null) {
this.configuration.addClass(clazz);
this.sessionFactory = this.configuration.buildSessionFactory();
}
This works very well -- except when you have open sessions. Any open sessions now have a stale copy of the session factory. Is there some sanctioned way to rebuild the session factory with the new configuration information? If there isn't does it make sense support rebuilding an existing sessionFactory? something like
Code:
configuration.rebuildSessionFactory(this.sessionFactory)
.