-->
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: 2 HIbernate Sessions doing XA
PostPosted: Tue Aug 03, 2004 1:56 am 
Beginner
Beginner

Joined: Wed Mar 03, 2004 6:02 am
Posts: 46
Location: Kuala Lumpur, Malaysia
Context: Hibernate 2.1.4 + JBoss 3.2.3 + MySQL

Goal: to perform XA (distributed transaction) over 2 Hibernate sessions, each session connected to a different data source.

Both the datasources are local-tx-datasources since the MySQL Connector/J driver does not support XA.

Thus, I am getting a Warning as specified in this wiki item
http://www.jboss.org/wiki/Wiki.jsp?page ... MSWithJDBC

I want to know of some way to simulate 2PC. My idea is to create maintain my own transaction logs, one each for HibernateSession1 & HibernateSession2. I would do a flush on both sessions. If no exceptions are thrown, all is well. If I get some exceptions, I will try to simulate a rollback by reversing the steps in the transaction logs. I'd probably place the logs in a static ThreadLocal. My understanding is that when you call session.flush(), it is persisted to the DB and no explicit tx.rollback() will revert it to the previous state.

Qu'en pensez-vous ?

A


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2004 6:33 pm 
Newbie

Joined: Sat Aug 14, 2004 6:44 am
Posts: 17
Location: Auckland, NZ
Alister,

I guess nobody has replied to this because it just doesn't sound like a good idea (well not to me anyway).

Upgrading your JBoss to 3.2.6 will fix the warning. If you need 2PC then you should move to a database that supports it. Building these sort of things yourself is very difficult and adds considerable overhead to your application. Your solution may also fail under obscure conditions (what happens if your roll back fails for instance).

Firebird http://firebird.sourceforge.net/ is one suggestion. It is a real database with full XA transaction support. Online support is also good via its mailing lists.

David


Top
 Profile  
 
 Post subject: Re: 2 HIbernate Sessions doing XA
PostPosted: Fri Aug 27, 2004 7:36 am 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:09 am
Posts: 46
Location: Geneva, Switzerland
alistair wrote:
I would do a flush on both sessions. If no exceptions are thrown, all is well. If I get some exceptions, I will try to simulate a rollback by reversing the steps in the transaction logs.


Let's suppose you commited first DS. Then got error commiting second and you're going to rollback by hands first DS. So the data that was commited and maybe already used by someone else will magically disappear. In the worst case, some could have already changed that data so it will be lost forever. This is absolutely inappropriate and it's what XA about.

alistair wrote:
My understanding is that when you call session.flush(), it is persisted to the DB and no explicit tx.rollback() will revert it to the previous state.


No, session.flush() executes SQL statement against DS. if you're in TX calling tx.rollback() will revert the previous state (in fact, state is never changed unless it's commited).

David is right, if you need XA just use DS which supports it.

PS instead of writing hibernate XA emulation for MySQL maybe you can write XA support for MySQL itself?


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.