You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When reading through JpaLocalTxnInterceptor#invoke we can see the following comment:
//everything was normal so commit the txn (do not move into try block above as it// interferes with the advised method's throwing semantics)try {
txn.commit();
} finally {
//close the em if necessaryif (null != didWeStartWork.get() ) {
didWeStartWork.remove();
unitOfWork.end();
}
}
This is a patently false assumption when considering persistence methods that follow another schema. Example:
@Transactional
public NiceResponse<EntityType> create(EntityType instance) {
try{
try {
entityManager.persist(instance);
entityManager.flush();
return NiceResponse.success(instance);
} catch (PersistenceException ex) {
// unwrap to find actual cause and use that to find out what happened
entityManager.getTransaction().rollback(); // this is theoretically optional
thow ex.getCause();
}
} catch (ConstraintViolationException ex) {
return NiceResponse.failure("Some useful error message", ex);
}
// possibly further catch blocks
}
Commiting the transaction after this method will throw an Exception all error cases, simply because the transaction has been rolled back already, but there's no Exception thrown to early-exit invoke.
The text was updated successfully, but these errors were encountered:
When methods marked @transactional initiated a rollback without
throwing an exception, the Interceptor threw an exception with
either "Transaction not active" or "Transaction marked for rollback only"..
Fixesgoogle#1136
When reading through
JpaLocalTxnInterceptor#invoke
we can see the following comment:This is a patently false assumption when considering persistence methods that follow another schema. Example:
Commiting the transaction after this method will throw an Exception all error cases, simply because the transaction has been rolled back already, but there's no Exception thrown to early-exit
invoke
.The text was updated successfully, but these errors were encountered: