-->
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.  [ 2 posts ] 
Author Message
 Post subject: Configuration in a Multiple Datasources scenario
PostPosted: Sun Dec 04, 2005 9:55 am 
Newbie

Joined: Sun Dec 04, 2005 9:30 am
Posts: 2
Hi,

when reading CaveatEmptor HibernateUtils, I found the following excerpt:

* Note: This class supports only one data store. Support for several
* <tt>SessionFactory</tt> instances can be easily added (through a static <tt>Map</tt>,
* for example). You could then lookup a <tt>SessionFactory</tt> by its name.

which makes sense due the SessionFactory variable´s static signature.

But, considering the following scenario:

1) A web-app have to be deployed twice, in diferent contexts C1 and C2.
2) C1 has a datasource D1 and C2 has a datasource D2.
3) The mappings are identical for both deployments. The only difference is the Datasource configuration, e.g. C1 accesses
jdbc:mysql://localhost:3306/d1
and C2:
jdbc:mysql://localhost:3306/d2

or, in a less restrictive manner, one can be configured via JDBC driver, and the other via JNDI.

The question is: Is necessary to build a SessionFactory for each context? Is there some way to use a single SessionFactory, but switch the datasource accordinglly the calling context?

Thanx in advance.
Fábio.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 04, 2005 7:59 pm 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
Having a separate SessionFactory is what I read in the docs as recommended. You will also have to take into considering the issues with Class Loading etc. expecially cross-context. Typically I would assume they would ultimately be separate SessionFactory instances based on how the underlying container chooses to do this.


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