Hibernate version:
3.2.5
JDBCTransaction snippet:
Code:
private void notifyLocalSynchsBeforeTransactionCompletion() {
if (synchronizations!=null) {
for ( int i=0; i<synchronizations.size(); i++ ) {
Synchronization sync = (Synchronization) synchronizations.get(i);
try {
sync.beforeCompletion();
}
catch (Throwable t) {
[b]!!! exceptions on beforeCompletion are just swallowed !!![/b]
log.error("exception calling user Synchronization", t);
}
}
}
}
JTA Spec docs on the beforeCompletion method: Quote:
public void beforeCompletion()
The beforeCompletion method is called by the transaction manager prior to the start of the two-phase
transaction commit process. This call is executed with the transaction context of the transaction that is being
committed. An unchecked exception thrown by a registered Synchronization object causes the transaction to
be aborted. That is, upon encountering an unchecked exception thrown by a registered synchronization
object, the transaction manager must mark the transaction for rollback.
Motivation: I think it would be best if the JDBC syncrhonization implementation did exactly the same as the JTA behaviour.
Fix: Code:
catch (Throwable t) {
log.error("exception calling user Synchronization.beforeCompletion. rolling back.", t);
[b]rollback();[/b]
}
regards, tom.