-->
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.  [ 2 posts ] 
Author Message
 Post subject: Write to 2 databases
PostPosted: Mon Jul 10, 2006 8:35 am 
Newbie

Joined: Mon Jul 10, 2006 8:31 am
Posts: 1
We use hibernate and what I would like to do is to be able to persist the data to 2 different databases. The same INSERTs, UPDATEs should be written to two different databases. Is this possible using Hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 9:32 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Yes, you have to declare two SessionFactory object, one per db. Then just use Sessions from each SessionFactory to execute your queries on each db.

If every queries have to be executed against both db, I'd write a class that executes each query against each db systematically. Pretty simple in fact.

You'll meet maybe some pbs for example if transactions could not be completed on a db although ok on another => Two phase commit ? If you don't want to take care about that, then it should be quick to design.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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