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

Envers: Column of Embedded missing in Audit Table

    Details

      Description

      NOTE: THE "FIX" THAT WAS APPLIED FOR THIS ISSUE WAS INCORRECT, AND WAS COMPLETELY REVERTED BY HHH-9194 Closed IN THE SAME HIBERNATE ORM RELEASE. PLEASE SEE HHH-9193 Closed FOR MORE INFORMATION.

      I have a simple Audited TestClass with two Embedded Attributes:

          @Embedded
          @AttributeOverrides({@AttributeOverride(name = "code", column = @Column(name = "THE_TEST"))})
          private TestCode testCode = TestCode.TEST;
      
          @Embedded
          @AttributeOverrides({@AttributeOverride(name = "code", column = @Column(name = "THE_CODE")),
                  @AttributeOverride(name = "codeArt", column = @Column(name = "THE_CODEART"))})
          private Code genericCode;
      

      In the irst case, the column named "THE_TEST" is missing in the Audit Table. The Second attribute is ok.

      The class TestCode where the Column is missing:

      @Embeddable
      public class TestCode extends AbstractCode {
      
          public static final int _TEST = 1;
         
          public static final TestCode TEST = new TestCode(_TEST);
       
          public TestCode(int code) {
              super(code);
          }
      
          // Needed for @Embeddable
          protected TestCode() {
              super(UNDEFINED);
          }
      
          @Override
          @Transient
          public String getCodeart() {
              return "TestCode";
          }
      

      and it's superclass:

      @MappedSuperclass
      @Access(AccessType.FIELD)
      public abstract class AbstractCode {
      
          /** Initial Value */
          protected static final int UNDEFINED = -1;
      
          private int code = UNDEFINED;
      
          protected AbstractCode() {
              this(UNDEFINED);
          }
      
          /**
           * Constructor with code
           */
          public AbstractCode(int code) {
              this.code = code;
          }
      
          public abstract String getCodeart();
      
          public int getCode() {
              return code;
          }
      }
      

      this is the embedded that works fine:

      @Embeddable
      public class Code extends AbstractCode {
       
          private String codeArt;
          
          public Code(int code, String codeArt) {
              super(code);
              this.codeArt = codeArt;
          }
      
          // Needed for @Embeddable
          protected Code() {
              this (UNDEFINED, null);
          }
      
          @Override
          public String getCodeart() {
              return codeArt;
          }
      }
      

      when I add @Audited to the class TestClass it works; but I think this should not be necessary.

        Attachments

        1. envers_embed.zip
          7 kB
        2. Table_AUD.PNG
          20 kB
        3. Table.PNG
          19 kB

          Issue links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: