-->
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: ITransaction, Rollback(), and Dispose()
PostPosted: Tue Jun 26, 2007 5:20 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
Hibernate version: 1.2.0 (.NET 1.1)

Code between sessionFactory.openSession() and session.close():

That's the question: this:

Code:
         using (ISession sess = factory.OpenSession())
         using (ITransaction tx = sess.BeginTransaction()) {
            // do some work...
            tx.Commit();
         }


- or this:

Code:
         using (ISession sess = factory.OpenSession()) {
            ITransaction tx = sess.BeginTransaction();
            try {
               // do some work...
               tx.Commit();
            }
            catch ( Exception ex ) {
               tx.Rollback();
               throw;
            }
         }


Are these (as the docs imply, but do not state) essentially equivalent? That is: does ITransaction.Dispose() provide the required rollback? Or again: as AdoTransaction.Dispose() (the default impl) falls back on IDbTransaction.Dispose(), does it cause a rollback?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 27, 2007 12:54 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
IDbTransaction.Dispose should roll back the transaction since that's the only sane behavior (why would it commit something unless you told it explicitly?), but it's not specified in the documentation anywhere, I believe.


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.