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

Hibernate-Envers has incoherent behavior for modified flag when create new Entity

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.12, 5.1.5, 5.2.9
    • Fix Version/s: 5.2.10
    • Component/s: hibernate-envers
    • Labels:
      None
    • Environment:
      Hibernate 5.1, Postgresql, Spring
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • backPortable:
      Backport?
    • Last commented by a user?:
      true

      Description

      When creating a new Entity and then inserting her in the associated table, the values of the modified flag (column that can be added with org.hibernate.envers.global_with_modified_flag = true ) are unpredictibles.

      When you persist the entity at the end of the modification simply like this :

      Entite entite = new Entite();
      
      entite.setId("xxxxxxxxxxxx");
      
      entite.setDate(new Date());
      
      entityManager.persist(entite);
      

      The principle seem to be this one :

      • each property that is fill with some value get a modified flag to true, every property that remain null get a false modified flag (so here date_mod = true)

      But if in the same transaction, you make some changes after the persist's call, like this :

      Entite entite = new Entite();
      
      entite.setId("xxxxxxxxxxxx");
      
      entite.setDate(new Date());
      
      entityManager.persist(entite);
      
      entite.setSecondField("Hello");
      
      entityManager.merge(entite);
      

      Than it's like the modifications made before the persist are forgotten, and Hibernate-Envers apply the precedent principle only to the changes made between the persist and the update.

      So we get date_mod = false , and second_field_mod = true.

      It would be nice to have a coherent behavior on the whole changes that are made inside one transaction, and so that the precedent principle be applied to every changes.

      Thx

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: