-->
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.  [ 8 posts ] 
Author Message
 Post subject: session across multiple databases?
PostPosted: Thu Jan 06, 2005 5:21 am 
Newbie

Joined: Thu Jan 06, 2005 5:06 am
Posts: 2
I am wondering how it might be possible to work with multiple databases at the same time with Hibernate? I have a scenario with multiple 2 different databases (different DB software, different platforms). AFAIK, this would require Two SessionFactories(each one configured for respective database), then maintaining two Hibernate sessions in my application.

However, while each individual object can be guaranteed to be persisted in either one database or the other, the domain object model is split across the two databases (part is data shared with legacy systems). This means we will be trying to load object **graphs** which span databases - The mappings dont allow objects to be mapped to Tables in different databases, and I can't readily see how we could do this directly in Hibernate.

We had Some discussion about possibly front-ending the two databases with third party software, and this is an option but this has performance drawbacks in our specific case.

Has anybody acheived the same end result in some other way, or have any ideas, patters or suggestions on how it might be possible (no matter how daft!)?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 06, 2005 6:23 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You can not map associations across databases. This has to be solved at the JDBC or database level (Oracle makes this really easy).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 06, 2005 11:51 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
It is easy for oracle for same or differnet OS platform, but I think that hibernian have different DB platform
Hibernian,
Do you try cluster jdbc ? I think that You can set hibernate and cluster JDBC

regards


Top
 Profile  
 
 Post subject: session across multiple databases?
PostPosted: Thu Jan 06, 2005 12:35 pm 
Newbie

Joined: Wed Jan 05, 2005 12:30 pm
Posts: 17
Location: Philadelphia, PA
I deal with this extensively. Hibernate seems able to handle a few session factories without any real problem when the database vendors vary or are not linked or federated.

What I did was use the ServletFilter pattern but instead of having the ThreadLocal contain Session objects mine contains a lazily-built map of Session objects (luckily never more than 3 - 5) keyed by the name of the database.

My plan is that I can eventually make my SessionUtil class and mappings smart so it either aupports a single session or one of several sessions depending on which RDBMS my customer is running and whether or not it is federated or linked.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 06, 2005 4:48 pm 
Newbie

Joined: Thu Jan 06, 2005 5:06 am
Posts: 2
unfortunately one of the database platforms is not oracle or any of the main databases(the other is SQL server), and front-ending these together as a single database at the database level is something we have looked at - it works but is not a runner in our case for certain reasons.
I understand that we can have multiple sessions, but the point is that we want to do association mapping across the databases (which are different vendors).
I realise this is a tall order, and I suspect Christian is right... but might be a nice killer feature in Hibernate3.x perhaps !
many thanks for the input.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 06, 2005 4:50 pm 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Maybe http://c-jdbc.objectweb.org/ helps.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 18, 2006 1:51 am 
Beginner
Beginner

Joined: Mon Aug 15, 2005 9:00 pm
Posts: 37
Christian, can you provide more detail on how Oracle make this easy (for use with Hibernate)?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 18, 2006 5:38 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Quote:
Christian, can you provide more detail on how Oracle make this easy (for use with Hibernate)?


You make database link to other (remote/other local) database and synonym to table (object) on other database - after this you work with synonym similra local table/object

Best


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