Re: Hibernate and multiple datasources...

From: Boris Cinkler (boris_cinkler_at_yh.cm)
Date: 11/29/04


Date: Mon, 29 Nov 2004 05:09:57 GMT

There should be a way to pass java.sql.Connection to Hibernate when
openning session, and it will use that connection instead.

PS I didn't work with Hibernate 2.0 and 2.1, there may be actually
better way to do that.

Boris

Lionel wrote:
> Hi !!!
>
> I have an hibernate application thta as multiple databases.
> Depending on the country of the user, I will access the database of his
> country.
> All databases have exactly the same structure.
> How can I manage this with struts/hibernate ?
>
> Here is the solution I think I will use:
> - define a JNDI datasource for each database.
> - create an hibernate.cfg.xml for each database, using the same hbm files,
> load in context each SessionFactory
> - use a ServletFilter to open a connexion to the correct database depending
> on the user profile for each http request
>
> Do you see any problem in this configuration ?
> Could I do better ?
>
> Thanks.
>
>



Relevant Pages

  • Re: Database Backend?
    ... and a decent database ... As best as I can tell, Hibernate is the current best of breed. ... java code on the page, and that is a big pain to maintain. ... Tapestry is a very clean framework, but it takes a while to figure out. ...
    (comp.lang.java.programmer)
  • Re: acceptable way to program
    ... I'm an experienced database programmer learning the ... > Java/OO way of doing things and I'm puzzled that people use Hibernate ... There is undoubtedly some bad database programming being done by Java ... As for stored procedures, it is true that current production releases of ...
    (comp.lang.java.programmer)
  • Re: How to best use Hibernate
    ... Load it all into memory and then synchronize to the database. ... potential of Hibernate, and is the effort managable for lots and lots ...
    (comp.lang.java.programmer)
  • Re: What does everyone else do for graphically displaying data?
    ... JDBC API reference cover to cover a couple of times, ... you bind a data grid to a database table so that when you edit the ... put all JDBC code in the Model classes. ... Use something like Hibernate. ...
    (comp.lang.java.databases)
  • Re: How to best use Hibernate
    ... Load it all into memory and then synchronize to the database. ... potential of Hibernate, and is the effort managable for lots and lots ...
    (comp.lang.java.programmer)