Hibernate version:3.1.3
Mapping documents:working great
Code between sessionFactory.openSession() and session.close():working great
Full stack trace of any exception that occurs:no exceptions
Name and version of the database you are using:Oracle10g
The generated SQL (show_sql=true):n/a
Debug level Hibernate log excerpt:n/a
I wish to export the effective contents of a Configuration object that I have modified programmatically to a hibernate.cfg.xml document, so that I can log it and utilize it in other tools. I need to do this shortly after the Configuration has been modified at runtime.
*********************************
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml.base");
Mappings mappings = cfg.createMappings();
//load an extension mapping file
cfg.addResource("ExtensionMappings.hbm.xml");
//full programmatic mapping
PersistentClass c = cfg.getClassMapping("a.b.c.ExtensionBase");
JoinedSubclass subclass = new JoinedSubclass( c );
Table table = new Table();
//columns...etc
//add the mapping
mappings.addClass( subclass );
//end programmatic mapping
//export the combined settings + loaded mappings
cfg.saveToFile("hibernate.cfg.xml.effective");//<-- this would be grand!
*****************************
Any suggestions? I'd prefer not to walk the Configuration object and its children and manually reconstruct the hibernate.cfg.xml, because, as a hibernate user, I've become quite lazy.
ttfn,
J2
UPDATE :
looks like org.hibernate.tool.hbm2x.HibernateConfigurationExporter, from the Hibernate tools project, will do exactly what I need.
|