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.  [ 4 posts ] 
Author Message
 Post subject: How to handle query against multiple datasources?
PostPosted: Fri Aug 25, 2006 3:01 pm 
Newbie

Joined: Tue Sep 14, 2004 1:16 pm
Posts: 7
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0

Are there any examples on how to query against multiple databases?


Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 25, 2006 6:15 pm 
Beginner
Beginner

Joined: Tue Aug 08, 2006 11:53 am
Posts: 37
Each database has different SessionFactory configured.

DB1 - SF1
DB2 - SF2

SF1.getCurrenSession().createQuery(...)

SF2.getCurrenSession().createQuery(...)

If you need transaction support plan to use JTA

Pls rate if you are satisfied with the answer!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 25, 2006 6:47 pm 
Beginner
Beginner

Joined: Sat Aug 19, 2006 8:04 pm
Posts: 30
^ i'm pretty sure that's not what he's trying to do. i think he wants to write one query and do selects from different databases in the same statement.

i had to do this once, the solution i came up with was to make another database containing only views on the tables from the 3 other databases that i needed. that way i could do some pretty powerful queries.


Top
 Profile  
 
 Post subject: Yes, that is exactly what I'm trying to do
PostPosted: Sun Aug 27, 2006 9:45 am 
Newbie

Joined: Tue Sep 14, 2004 1:16 pm
Posts: 7
lloyd.mcclendon wrote:
^ i'm pretty sure that's not what he's trying to do. i think he wants to write one query and do selects from different databases in the same statement.

i had to do this once, the solution i came up with was to make another database containing only views on the tables from the 3 other databases that i needed. that way i could do some pretty powerful queries.



I was going on the same path as you suggested. What is still troubling me is that our database is not normalized at all. Doing an insert or update may require updating different tables possibly in different datasource. How would you handle this?

Thanks


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