1 Reply Latest reply on Mar 24, 2011 3:01 AM by Adam Warski

    @ManyToMany relationship question

    r s Newbie

      Hello,

       

      I have a @ManyToMany relationship between User and Role.

      public class User{

      ...

          @Audited

          @ManyToMany(fetch = FetchType.LAZY)

          @JoinTable(name = "user_role_link", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))

          private Set<Role> userRoles = new HashSet<Role>();

      ...

      }

       

      public class Role{

           ...

          @Audited

          @ManyToMany(fetch=FetchType.LAZY)

          @JoinTable(name = "user_role_link", joinColumns = @JoinColumn(name = "role_id"), inverseJoinColumns = @JoinColumn(name = "user_id"))

          private Set<User> users = new HashSet<User>();

      ...

      }

       

      This generates user_aud table, role_aud table and user_role_link_aud table.

      I want for a user revision to know if a role was added or removed at that revision. How can I do that? I didn't find any way to query the user_role_link_aud table.