-->
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.  [ 5 posts ] 
Author Message
 Post subject: multiple hibernate-configuration files?
PostPosted: Tue Mar 28, 2006 2:29 am 
Can i have more than one hibernate-configuration file (hibernate.cfg.xml)

one each for subproject?

if yes, how they are managed and accessed?

i am using weblogic 8.1 and hibernate 3.1

Regards,
RCP


Top
  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 4:12 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Hi,

you can explicitly load the configuration
using something like:

Code:
Configuration cfg1 = new Configuration();
cfg1.configure("file:hibernate1.cfg.xml");

Configuration cfg2 = new Configuration();
cfg2.configure("file:hibernate2.cfg.xml");


Note that the two cfgs do not know each other.

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject: same sessionfactory to talk to two databases
PostPosted: Tue Mar 28, 2006 5:58 am 
Newbie

Joined: Sun Mar 26, 2006 3:04 pm
Posts: 6
Now that we have the the two Configuration objects we could build separate SessionFactories from each of them and get connections to the two databases. But is it possible to use the same session factory to obtain connections to two different databases ?

Also is it possible to add tags corresponding to two databases in the same configuration file?


Top
 Profile  
 
 Post subject: Re: same sessionfactory to talk to two databases
PostPosted: Wed Mar 29, 2006 10:11 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
dukot123 wrote:
But is it possible to use the same session factory to obtain connections to two different databases ?


Yes, this is possible. You can use
Code:
sessionFactory.openSession(connection);


with you own connection. But you certainly loose all
features concerning the connection pool.

dukot123 wrote:
Also is it possible to add tags corresponding to two databases in the same configuration file?


I dont think so.

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject: Re: same sessionfactory to talk to two databases
PostPosted: Thu Mar 30, 2006 12:01 am 
dukot123 wrote:
Also is it possible to add tags corresponding to two databases in the same configuration file?


yes, this is also possible, you have to write two session factories in one configuration file...

Code:
<hibernate-configuration>
   <session-factory>
           <!-- First -->
   </session-factory>

   <session-factory>
           <!-- Second -->
    </session-factory>
</hibernate-configuration>


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