4 Replies Latest reply on Jul 26, 2010 5:18 AM by Levi Strauss

    @ManyToMany: REVTYPE

    Levi Strauss Newbie

      Hi,

       

      i have the two classes Person and Attribut, in short:

       

      @Entity
      @Indexed
      @Table(name="persons")
      public class Person {
       
        private int id;
        private List<Attribute> attributes;
       
       
        @Id
        @DocumentId
        @GeneratedValue
        @Column(name="person_id")
        public int getId() {
         return id;
        }
       
        @ManyToMany
        @JoinTable(
          name="attribute_alloc",
         
      joinColumns={@JoinColumn(name="person_id")},
         
      inverseJoinColumns={@JoinColumn(name="attribute_id")}
          )
        @Audited
        public List<Attribute> getAttributes() {
         return attributes;
        }
       
        // other properties, setters and getters...
      }


      @Entity
      @Indexed
      @Table(name="attributes")
      public class Attribute {
       
        private int id;
        private List<Person> persons;
       
       
        @Id
        @DocumentId
        @GeneratedValue
        @Column(name="attribute_id")
        public int getId() {
         return id;
        }
       
        @ManyToMany
        @JoinTable(
          name="attribute_alloc",
         
      joinColumns={@JoinColumn(name="attribute_id")},
         
      inverseJoinColumns={@JoinColumn(name="person_id")}
          )
        public List<Attribute> getPersons() {
         return persons;
        }
       
        // other properties, setters and getters...
      }


      For these classes the db tables persons, attributes, attribute_alloc, persons_aud, attributes_aud and attribute_alloc_aud were correctly generated.

       

      All works well except the audit for the attributes in Person. In the table attribute_alloc_aud the changes (for example removing an attribute and adding a new one to a person) are tracked correctly, but always marked with the REVTYPE ADD. For example:

       

       

      REVperson_idattribute_idREVTYPE
      1110
      1120
      2110
      2150
      3180

       

       

      Consequence is that the audited person in the last revision has the attributes 1, 2, 5 and 8. Correct would be only 8!

       

      What's wrong?

       

      Thanks a lot!

      Best regards

      Levi