0 Replies Latest reply on Jul 17, 2015 9:46 AM by mvetter

    How can I force Envers to write the contents of a join column

    mvetter

      Hi, this is my problem:

      My Entity:

      @Entity

      @Audited

      @Table(name = "GLOBAL_PARTY", uniqueConstraints = @UniqueConstraint(name = "UK_GLOBAL_PARTY", columnNames = { "GPKENN" }))

      public class GlobalParty {

             @EmbeddedId
             private GlobalPartyId gpKenn;

      @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL,  orphanRemoval = true)
            
      @JoinColumn(name="GPKENNS", nullable = false, insertable = true, updatable = true)           
             @
      NotAudited
             private Set< GlobalParty2Associate> associates = new HashSet<>();

       

      }

      has a – as seen above - a OneToMany Relation to something called  GlobalParty2Associate.

      This relation is set to “not Audited”, but the related Entity is Audited:

       

      @Entity

      @Audited

      @DiscriminatorValue("80001")

      public class GlobalParty2Associate extends GlobalParty2GlobalParty

       

       

      The Parent:

       

      @Entity

      @Audited

      @Table(name = "GLOBAL_PARTY_GLOBAL_PARTY")

      @Inheritance(strategy=InheritanceType.SINGLE_TABLE)

      @DiscriminatorColumn(name="GPRELATION", discriminatorType=DiscriminatorType.STRING)

      public abstract class GlobalParty2GlobalParty implements Serializable{

             @Id

             @GeneratedValue

             protected Long id;

       

             @Embedded

             @AttributeOverride(name="gpKenn", column = @Column(name="GPKENNS", nullable = false, insertable = false, updatable = false ))

             private GlobalPartyId subject;

       

             @Embedded

             @AttributeOverride(name="gpKenn", column = @Column(name="GPKENNO"))

             private GlobalPartyId object;

            

             @Column(name = " GPRELATION ", insertable=false, updatable=false )

             protected String predicate;

       

       

       

      Long story short:

      My “one” Entity has a key called GPKENN,

      Which is used in the “many” Entity as Field “GPKENNS”, in Java called “subject”.

       

      Envers – auditing works fine, I have a Table GLOBAL_PARTY_AUD filled properly,

      And GLOBAL_PARTY_GLOBAL_PARTY_AUD likewise.

       

      Only one problem:

      The column GPKENNS in GLOBAL_PARTY_GLOBAL_PARTY_AUD is never filled.

      All attempts to achieve that by altering the used annotations failed so far.


      Can someone help me or has experienced a similar problem?

      Matthias Vetter, Frankfurt