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.
|