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.
Kingsley Idehen - 15 Oct 2004 18:18 GMT
10/15/2004 5:05:33 AM
Lionel <> wrote in message
<416f92db$0$563$626a14ce@news.free.fr>
> Hi !!!
>
[quoted text clipped - 15 lines]
>
> Thanks.
What about simply creating one JDBC DSN that connects you to all the
different databases? If you want to investigate this approach then
take a look at OpenLink Virtuoso at: http://virtuoso.openlinksw.com .
It allows you to make one JDBC connection to several ODBC or JDBC
Data Sources that are bound to a variety of backend databases.
Alternatively, you can have Hibernate simply bind to one data source,
since Virtuoso can produce Well-Formed and/or Valid XML data (that is
accessible via HTTP/WebDAV) from heterogeneous ODBC or JDBC data
sources on the Fly (using; SQLX, SQL-XML, XML-SQL Schema Mapping).
So you can give Hibernate a DSN or a URI to an XML doc, in both cases
the underlying heterogeneous data sources are unified without you
writing code to handle the complexity of this effort.
Regards,
Kingsley Idehen Weblog: http://www.openlinksw.com/blog/~kidehen
OpenLink Software Web: http://www.openlinksw.com
Universal Data Access & Universal Integration Middleware Providers.
Boris Cinkler - 29 Nov 2004 05:09 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
> Hi !!!
>
[quoted text clipped - 15 lines]
>
> Thanks.