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.  [ 3 posts ] 
Author Message
 Post subject: Working with more than one SessionFactory
PostPosted: Wed Jan 13, 2010 2:29 am 
Newbie

Joined: Wed Jan 13, 2010 1:56 am
Posts: 2
Hi,
I have requirement of working with different configuration files for my application (i.e. one cfg for MySQL, another for Oracle, another for MS-SQL Server,...etc). But picking of cfg file needs to be done during run time (means no hard coding for xxxx.cfg.xml names for each configuration and file name picked as files added to the classpath). I have spring support for working with hibernate.

Any suggestion please...

Many thanks
Gayath


Top
 Profile  
 
 Post subject: Re: Working with more than one SessionFactory
PostPosted: Wed Jan 13, 2010 4:10 am 
Newbie

Joined: Wed Dec 23, 2009 12:38 pm
Posts: 14
You can instantiate more than one Configuration objects which in turn can refer to different cfg.xml files.

SessionFactory sf1 = new Configuration().configure(getConfigFile()).buildSessionFactory();

where getConfigFile() will return the appropriate file based on some logic.


Top
 Profile  
 
 Post subject: Re: Working with more than one SessionFactory
PostPosted: Wed Jan 13, 2010 4:14 am 
Newbie

Joined: Wed Jan 13, 2010 1:56 am
Posts: 2
Thanks keliveli... I'll try this option.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.