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

Wrong audit data of ElementCollection attribute of map

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects versions: 5.0.12, 5.1.12, 5.2.17, 5.1.14, 5.3.0.Final
    • Fix versions: 5.3.2
    • Components: hibernate-envers
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

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

      Description

      For example.

      public class TestEntity {
          @Id
          private int id;
          @ElementCollection
          private Map<String, Emb> embs1;
      }
      
      @Embeddable
      public class Emb {
         private String value;
         public Emb(value) {
              this.value = value;
         }
      }
      
      TestEntity e = new TestEntity();
      e.id = 1;
      e.embs1 = new HashMap<>();
      e.embs1.put("a", new Emb("value1"));
      e.embs1.put("b", new Emb("value2"));
      em.persist(e);
      

      In TestEntity table:

      id
      1

      In TestEntity_embs1

      TestEntity_id emb1_KEY value
      1 a value1
      1 b value2

      In TestEntity_embs1_AUD

      REV REVTYPE TestEntity_id emb1_KEY value REVEND REVEND_TSTMP
      1 0 1 a value1 NULL NULL
      1 0 1 b value2 NULL NULL

      All is ok. but if i edit the entity like this:

      TestEntity e = em.find(TestEntity.class, 1);
      e.put("a", "value3")
      

      In TestEntity_embs1_AUD

      REV REVTYPE TestEntity_id emb1_KEY value REVEND REVEND_TSTMP
      1 0 1 a value1 2 2018-05-21 15:18:26.8850000
      1 0 1 b value2 2 2018-05-21 15:18:26.8850000
      2 0 1 a value3 NULL NULL
      2 0 1 b value2 2 2018-05-21 15:18:26.8850000
      2 2 1 a value1 NULL NULL
      2 2 1 b value2 NULL NULL

      If I want to find the audit data of TestEntity with id 1, it return that:

      [
          {
              id: 1
              embs1: {
                  a: "value3"
              }
          },
          {
              id: 1
              embs1: {
                  a: "value1",
                  b: "value2"
              }
          }
      ]
      
      {b: "value2}

      is missing in the latest reversion.

      If I change the data in datebase by sql to these:

      REV REVTYPE TestEntity_id emb1_KEY value REVEND REVEND_TSTMP
      1 0 1 a value1 2 2018-05-21 15:18:26.8850000
      1 0 1 b value2 2 2018-05-21 15:18:26.8850000
      2 0 1 a value3 NULL NULL
      2 0 1 b value2 NULL NULL
      2 2 1 a value1 2 2018-05-21 15:18:26.8850000
      2 2 1 b value2 2 2018-05-21 15:18:26.8850000

      All is ok. I think it is a serious bug. it destory the function of audit of ElementCollection.

        Attachments

          Issue links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: