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.

The following code reproduces the problem:

em.getTransaction().begin(); em.getTransaction().setRollbackOnly(); em.flush(); // exception here em.getTransaction().rollback();

This code was working on 5.1.

Activity

Show:
Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created June 6, 2016 at 5:08 PM
Updated June 30, 2016 at 4:22 PM
Resolved June 29, 2016 at 4:43 PM