6 Replies Latest reply on Sep 20, 2011 9:58 AM by sebp

    Auditing the not-owning side of a many-to-one relation

    sebp Newbie

      Hi,

      I have a problem creating revisions of the not-owning side of a many-to-one relation.

       

      Example:

       

      I have a many-to-one relation from entity B to entity A. Entity B looks like this:

       

      @Audited

      @Entity

      public class B {

          @ManyToOne

          @JoinColumn(name = "fk_a", nullable = false)

          private A a;

          ...

      }

       

      Entity A is not aware of B, meaning that there is no @OneToMany annotation in entity A. Even if revision_on_collection_change is set to true there is no new revision of A create when A is added or removed from B.

       

      If I add a one-to-many relation from A to B:

       

      @Audited

      @Entity

      public class A {

          @OneToMany(mappedBy="a")

          List<B> b;

          ...

      }

       

      then it works. Each time an A is added to B a new revision from A and B is created. I wan to have exactly this behaviour but without modelling the one-to-many relationship on A. Is that possible?