Flushing EntityManager with rollback only transcation causes error
Description
After upgrading from hibernate 5.1 to 5.2 my tests started failing after calling EntityManager.flush() inside a transaction with the following exception: javax.persistence.TransactionRequiredException: no transaction is in progress
But in fact, there is a transaction active, although the RollbackOnly flag is on. When a transaction is marked for rollback only, it should throw an exception while trying to commit, but not when trying to flush the pending operations in the EM.
After upgrading from hibernate 5.1 to 5.2 my tests started failing after calling EntityManager.flush() inside a transaction with the following exception:
javax.persistence.TransactionRequiredException: no transaction is in progress
But in fact, there is a transaction active, although the RollbackOnly flag is on.
When a transaction is marked for rollback only, it should throw an exception while trying to commit, but not when trying to flush the pending operations in the EM.
The following code reproduces the problem:
This code was working on 5.1.