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.  [ 1 post ] 
Author Message
 Post subject: Exotic transactions
PostPosted: Mon Apr 07, 2008 5:00 pm 
Beginner
Beginner

Joined: Fri Aug 10, 2007 3:34 am
Posts: 44
in my project there are 2 sessionfactory's: one for 'normal' objects
and one for versions (the versions are stored in separate tables,
hence the 2 sessionfactory's)

i want to be able to span a transactions on 2 sessions,each from a different
sessionfactory like this

ISession session = Helper.GetSessionFact().OpenSession();
ITransaction transOne = session.BeginTransaction()
do some saving
transOne.Commit();
ISession sessionVer = Helper.GetVersionSessionFact().OpenSession();
ITransaction transVer = sessionVer.BeginTransaction()
do some saving
transVer.Commit();

i'm treating exceptions in a try catch block for every transaction.
there is a problem:
suppose the first transaction commits successfully:
if the second transaction fails i want to call transOne.Rollback()
but that throws an exception since transOne.IsActive is false due to
the call of transOne.Commit()

why can't i rollback the transaction after commit?
or better yet: what shoul i do to be able to rollback the transaction?
does it have anything to do with the fact that the transactions
origin from different sessionfactory's?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.