[hibernate-dev] Exceptions thrown in a tx synchronization are eaten

Adam Warski adam at warski.org
Wed Mar 31 07:00:38 EDT 2010


> In an ideal world, a Synchronization should swallow exceptions (or do whatever it wants with it) if the exception should not tamper with the main Hibernate execution. In a word, Synchronization would be in control. It has my preference but It's a change of semantic.

Then maybe do as Steve suggested, either:
- introduce a new method to Synchronization (that would break existing synchronizations)
or
- introduce a new interface SynchronizationRollback which can be optionally implemented by the synchronization method
Then in JDBC transaction we could do:

if ((sync instanceof SynchronizationRollback) && ((SynchronizationRollback) sync).shouldRollback(exception) { // rollback }

-- 
Adam Warski
http://www.warski.org
http://www.softwaremill.eu








More information about the hibernate-dev mailing list