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

Multiple revisions are created during a single transaction with FlushMode COMMIT

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.0
    • Fix Version/s: 5.2.10
    • Component/s: hibernate-envers
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Worked in:
    • Last commented by a user?:
      true

      Description

      When the FlushMode is set to commit, a manual flush during a transaction leads to multiple audit revision to be created.

      Consider the following example:

      EntityManager em = getEntityManager();
      em.getTransaction().begin();
      int revisionNumber = getAuditReader().getCurrentRevision( SequenceIdRevisionEntity.class, true ).getId();
      em.flush();
      StrTestEntity entity = new StrTestEntity( "entity" );
      em.persist( entity );
      em.getTransaction().commit();
      

      In the example the persisted entity should have the same revision number ass the revision number obtained before the flush. However, the entity will be assigned to a new revision number.

      It seems that the AuditProcess does check for FlushMode COMMIT instead of FlushMode MANUAL. This has been introduced with 5.2.

        Attachments

          Issue links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: