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

Audit tables storing incorrect discriminator value when using JOINED entity inheritance.

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      Using the following entity configuration:

      ParentEntity.java
      @Entity
      @Audited
      @Inheritance(strategy = InheritanceType.JOINED)
      @DiscriminatorColumn(name = "type")
      public abstract class ParentEntity {
        @Id 
        @GeneratedValue
        private Integer id;
        private String type;
        /** getter/setters **/
      }
      
      ChildEntity.java
      @Entity
      @Audited
      @DiscriminatorValue("child")
      public class ChildEntity extends ParentEntity {
        private String name;
        /** getter/setters **/
      }
      

      Hibernate will insert *child* as the discriminator value on the ORM side; however, the fully qualified class name of the audited entity will be used in the envers audit tables.

      insert 
      into
          ParentEntity_AUD
          (REVTYPE, type, id, REV) 
      values
          (?, 'org.hibernate.test.stackoverflow.StackoverflowTest$ChildEntity_AUD', ?, ?)
      09:08:25,631 TRACE BasicBinder:64 - binding parameter [1] as [INTEGER] - [0]
      09:08:25,632 TRACE BasicBinder:64 - binding parameter [2] as [BIGINT] - [1]
      09:08:25,632 TRACE BasicBinder:64 - binding parameter [3] as [INTEGER] - [1]
      

      In Hibernate 4.3.11.Final, this wasn't observed and the actual configured discriminator value was used instead. This also introduces a column width problem as column width is configured based on the expected configured values, which are often far shorter than the fully qualified name; causing insertion failures on the Envers side.

        Attachments

          Issue links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: