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

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

    Matthias Vetter Newbie

      Hi, this is my problem:

      My Entity:



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

      public class GlobalParty {

             private GlobalPartyId gpKenn;

      @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL,  orphanRemoval = true)
      @JoinColumn(name="GPKENNS", nullable = false, insertable = true, updatable = true)           
             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:





      public class GlobalParty2Associate extends GlobalParty2GlobalParty



      The Parent:




      @Table(name = "GLOBAL_PARTY_GLOBAL_PARTY")


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

      public abstract class GlobalParty2GlobalParty implements Serializable{



             protected Long id;



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

             private GlobalPartyId subject;



             @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,



      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