-->
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: hibernate in distributed architecture
PostPosted: Fri Mar 24, 2006 1:18 am 
How can i use hibernate when i have 2 database servers and in one transaction data is to be saved in 2 mapped tables that are in different databse servers. I have to rool back transaction in first server if transaction fails in second server.


Top
  
 
 Post subject:
PostPosted: Fri Mar 24, 2006 8:21 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
In this case you have to setup two session factories, one for each database server. In addition to that you must configure 2 XA DataSources in your app server and you have to bind hibernate to JTA of your app server.

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 24, 2006 8:38 am 
reffering to code below

Session session = HibernateUtil.getSessionFactory().getCurrentSession();

session.beginTransaction();

as in above code. the transaction in associated with one session, but my requirement is to attach one transaction with two sessions.

or is the case is that, using one session object i have access to both database servers??
like..
session.save(FirstPojo); // One DB server
session.save(secondPojo);// Other DB server

session.getTransaction().commit();
-----------------
in above case, is the commit is fired to both DB servers on successfull completion in both DB servers?


Top
  
 
 Post subject:
PostPosted: Fri Mar 24, 2006 10:06 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Call "UserTransaction.commit()" to commit JTA transaction.


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.