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: I need two Databases in my hibernate.properties. how?
PostPosted: Thu May 12, 2005 6:49 am 
Newbie

Joined: Mon Dec 27, 2004 2:52 pm
Posts: 6
Hibernate version:
2.1.7

Could anybody tell me how to manage more than one database in hibernate?

I need to create two different connections, I supose that I'll need two sessionFactories, but how can I configure it ?

At the moment, I've got my hibernate.properties, which is loaded in the ContextListener :

configuration = new Configuration();
configuration.addMappings..
configuration.buildSessionFactory()

Thanks for advanced


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 12, 2005 7:06 am 
Regular
Regular

Joined: Tue Nov 23, 2004 7:42 am
Posts: 82
Location: London, England
You're correct in assuming that you need two session factories. You will need two configuration files two. This is how I did it...

Code:
Properties properties = new Properties();
InputStream inputStream = new FileInputStream("/path/to/database.properties");
properties.load(inputStream);

Configuration configuration = new Configuration();
configuration.setProperties(properties)
configuration.addMappings(...)
sessionFactory = configuration.buildSessionFactory()


Your other session factory would read a different properties file.

HTH


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 12, 2005 7:43 am 
Newbie

Joined: Mon Dec 27, 2004 2:52 pm
Posts: 6
Thanks so much


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.