-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: export programmatically constructed mappings to .cfg.xml...
PostPosted: Wed Apr 19, 2006 3:23 pm 
Newbie

Joined: Wed Apr 19, 2006 2:35 pm
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.