Closed ctzen closed 3 months ago
You experience UnexpectedRollbackException
because an exception has crossed a transactional boundary (the inner call to transactionTemplate.execute
), and therefore, the transaction is marked as rollback-only.
In any case, Transaction Management is provided by Spring Framework and the issue belongs into Spring Framework if you have further questions.
A synthetic (typical?) merge operation handling OptimisticLockException:
The above works fine if there is no active transaction at the time of entry.
Causes an UnexpectedRollbackException Transaction silently rolled back because it has been marked as rollback-only.
Why would the same code behaves differently depending on if there is an existing active transacton? Is this a bug? or I am using transactions wrongly?
Attached sample project to demonstrate the behaviour. tx-issue.tar.gz