Uploaded image for project: 'Hibernate ORM'
  1. HHH-10807

Flushing EntityManager with rollback only transcation causes error

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects versions: 5.2.0
    • Fix versions: 5.2.1
    • Components: hibernate-core
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      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.

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: