[hibernate-dev] Does any RuntimeException cause a transaction rollback?
Hardy Ferentschik
hibernate at ferentschik.de
Mon Feb 22 12:47:45 EST 2010
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
More information about the hibernate-dev
mailing list