1 Reply Latest reply on Oct 28, 2012 1:24 PM by adamw

    Incorect audit data when deleting entity from owner collection

    pawel-k

      Hi,

       

      I have a problem with audit data of one entity. Lets say I have following situation:

       

       

      class A {

       

         @ManyToMany(mappedBy="someAValues")

         Set<B> someBValues;

       

      ....

       

      }

       

       

      class B {

         @ManyToMany(fetch=Lazy)

         @JoinTable(name="A_B", joinColumns="...." inverseJoinColumns="...")

         Set<A> someAValues;

       

      ....

      }

       

      Now, the case is that I would like to delete one of A entity from the someAValues collection so what I do is:

       

      1. I get the B entity (lets name it b),

      2. I do b.someAValues.remove(someAValueToRemove)

       

      The data in db is saved correctly but when I look at the audi data for A it seams that its broken. It lookls like all fields are null, the revtype column is being set to modify...

       

      After some debugin I found that it is caused beacuse of the access type of the properties which is by default "field" what means that values are being taken directly without calling getters and setters... Because the collection of someAValues is lazy it contains only proxy elements with all fields being set to null (values are stored in underlying target entity instance)... This causes that direct acces to the fields returns null... If the access type is set to "property" then getters and setters are invoked and all looks fine.

       

      Is there any solution for that? I would rather not set the access type to properties.

       

      BR