-->
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.  [ 6 posts ] 
Author Message
 Post subject: two configuration file in hibernate
PostPosted: Fri Jan 09, 2009 9:54 am 
Newbie

Joined: Tue Jan 06, 2009 9:33 am
Posts: 7
Hi what I've a modular application, and I wanna to include the moduleA-hibernate.cfg.xml into the main hibernate.cgf.xml, how can I do that?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2009 9:55 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
u can't add hibernate.cfg.xml to another hibernate.cfg.xml file. to tackle this problem,

getConfiguration() from current SessionFactory and change as u like and rebuild by code.. that's a solution

for eg.,

Configuration cfg = new Configuration()
.addResource("Item.hbm.xml")
.addResource("Bid.hbm.xml");

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2009 10:13 am 
Newbie

Joined: Tue Jan 06, 2009 9:33 am
Posts: 7
Ok, just one more question, there is a way to get the configuration from my SessionFactory. Because I'm using the hibernate.cfg.xml, that have all the basic configuration, and what I have to do to put the other's mapping was this:


configuration = new Configuration();
configuration.configure("hibernate.cfg.xml");


I do that because I've some dependence in the tables. And after thatI've add the resourses, but I see in the log that there is no SessionFactory selected, the message on the log was:

INFO Configuration:1419 - Configured SessionFactory: null

And after this message the tables are map.

So waht I really wanna do is get the configuration from my current SessionFactory (that have all the mapping from my cfg), so I can just add my others resources without havengi to reload all the hibernate config.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2009 10:14 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
just use inital configuration and changes and update that config and then rebuild your sessionFactory.

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2009 10:18 am 
Newbie

Joined: Tue Jan 06, 2009 9:33 am
Posts: 7
could you show template code


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2009 10:20 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
Configuration config=new Configuration();
config.configure("/hibernate.cfg.xml");
config.addResource("Report1.hbm.xml");
SessionFactory sf=config.buildSessionFactory();
Session session=sf.openSession();
...............
...............

config.addResource("Report2.hbm.xml");
config.addResource("Report3.hbm.xml");

_________________
If u feel it will help you, don't forget to rate me....


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

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.