And what if the failure is recoverable?
Failure in which component? If you speak about the last code example, of course, some exception within the transaction may be recoverable, but that does not change anything about the pattern.
Also, in general... JTA and JDBC-based-transactions arent the same. As much as we try to keep the behavior the same, they simply are not.
Well if it is possible to make them closer, we should... that's what this JIRA is about (though I'd rather say 'correct in common sense' than 'JTA-like'). Or do you intend to have different behaviour for JDBC than:
-
every transaction eventually ends with commit xor rollback
-
commit/rollback consist of running all synchronizations' beforeCompletion, resource=JDBC commit/rollback and then all synchronizations' afterCompletion
-
exception thrown from beforeCompletion (or anything before resource commit) results in rollback
|