Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > nested begin transactions, the inner rollback or commit affected the outer most transaction block.

Reply
Thread Tools

nested begin transactions, the inner rollback or commit affected the outer most transaction block.

 
 
xyzzy12@hotmail.com
Guest
Posts: n/a
 
      02-23-2007
In Hibernate, we ran into this issue. With nested begin transactions,
the inner rollback or commit affected the outer most transaction
block.

So given:
beginTransaction()
beginTransaction()
insert...
commit() //this commit erroneously committed the outermost
commit block
read() //this read failed since the transaction is closed.
commit()


Our hibernate.current_session_context_class is thread and our
hibernate.transaction.factory_class is
org.hibernate.transaction.JDBCTransactionFactory so we don't have a
proper JTA.

We ended up do a reference counting mutex (is that the correct term?)
in which the inner commit does nothing until the outer commit() is
noticed.

An inner rollback will throw an exception so the outermost rollback
will catch it and roll it back.

The basic pattern we are using is:

XDao dao = XDao.getInstance();

try {
dao.begin();
...operations
dao.commit();
} catch (Exception x) {
dao.rollback(x);
}



This is the particular javadoc that doomed us:

/**

* Begin a unit of work and return the associated <tt>Transaction</tt>
object.
* If a new underlying transaction is required, begin the transaction.
Otherwise
* continue the new work in the context of the existing underlying
transaction.
* The class of the returned <tt>Transaction</tt> object is determined
by the
* property <tt>hibernate.transaction_factory</tt>.
*
*/
public Transaction beginTransaction() throws HibernateException;



thanks for your help.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 DBs connections + commit/rollback Paulo Roberto ASP .Net 3 03-15-2010 05:05 PM
Transaction rollback not working teser3@hotmail.com Java 6 10-16-2007 10:56 PM
SQLObject transaction rollback not working jacob.miles@gmail.com Python 2 12-05-2005 05:28 PM
JSTL - <sql:transaction>, rollback? Sid Eaton Java 2 05-24-2004 04:10 PM
Connection auto commit - No begin? =?ISO-8859-1?Q?Thomas_Gagn=E9?= Java 1 11-19-2003 02:22 PM



Advertisments