0 Replies Latest reply on Jan 20, 2014 3:36 PM by Pawel D

    Load many-to-many relations.

    Pawel D Newbie



      I have an entity A with a many-to-many relation (with join table A-B) to entity B. I'm auditing only the A and A-B tables.


      The problem is following: when loading the last revision of A, envers loads also the last revisions of A-B for a given A record. In a result the loaded A entity contains also the removed B entities assignments which shouldn't be there.


      How to load A entity without removed A-B mappings?


      The A entity:


      class A {

           @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)

           @ManyToMany(fetch = FetchType.LAZY)

           @JoinTable(name = "A-B", ...)

           private Set<B> bSet;



           private long version;



      Problem occured on Jboss EAP 6.1.0



      We managed to fix it:

      Entity B should also be audited and Hibernate's session.merge() method should be used to update entity (we used session.save()).


      Message was edited by: Pawel D