-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate for Multiple Databases
PostPosted: Mon Jul 21, 2008 11:07 am 
Newbie

Joined: Sun Jun 17, 2007 12:13 pm
Posts: 2
Location: new york
Hi All,

I am newbie to hibernate, My question is ..

Using hibernate can we execute a SQL query which is across multiple database? (as far as I know one session/transaction you can get it from only one sessionfactory and sessionfactory is bind to particular database connection but just curious if it can be done in some way using HQL)

For ex: I have Table A in SQLServer , and Table B in Oracle and I would like to join these tables and get the data out of it.

Any help would be appreciated.

Regards,
Ram


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 21, 2008 2:55 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
The Hibernate Session takes its lead from the hibernate.cfg.xml file, which as you can see, only points to one database.

An application can use multiple Session objects, and perhaps have each of those dedicated to a particular database. That would allow your program to hit multiple databases within a program, although you wouldn't be able to hit multiple databases with a single query through a single Hibernate Session.

There is a Hibernate module called Shards which hasn't quite gone GA yet which is focussed at solving this multiple databases with Hibernate problem.

Hope that helps!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Hibernate for Multiple Databases
PostPosted: Mon Jul 21, 2008 4:28 pm 
Newbie

Joined: Sun Jun 17, 2007 12:13 pm
Posts: 2
Location: new york
Thanks a lot Cameron , this really helps.

Best Regards,
Ram


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