Java Mailing List Archive

http://www.gg3721.com/

Home » Hibernate Dev List »

[hibernate-dev] Does any RuntimeException cause a transaction
 rollback?

Hardy Ferentschik

2010-02-22

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi,

I was just looking at HHH-4676 - "Any interceptor exception (RTE) should
mark the tx for rollback"
and was wondering whether we can generally say that in JPA any
RuntimeException will mark the current
transaction for a rollback.

Currently we have this in AbstractEntityManagerImpl:


 public RuntimeException convert(RuntimeException e) {
   RuntimeException result = e;
   if ( e instanceof HibernateException ) {
     result = convert( (HibernateException) e );
   }
   else if (e instanceof ConstraintViolationException) {
     markAsRollback();
   }
   //if any RT exception should mark the tx for rollback, convert the last
else if into a else
   return result;
 }



Should this be changed to:


 public RuntimeException convert(RuntimeException e) {
   RuntimeException result = e;
   if ( e instanceof HibernateException ) {
     result = convert( ( HibernateException ) e, null );
   }
   else {
     markAsRollback();
   }
   return result;
 }

Meaning all RuntimeExceptions will mark the current transaction for
rollback? Any comments?

--Hardy
_______________________________________________
hibernate-dev mailing list
hibernate-dev@(protected)
https://lists.jboss.org/mailman/listinfo/hibernate-dev
©2008 gg3721.com - Jax Systems, LLC, U.S.A.