-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: @ManyToMany: REVTYPE is only ADD
PostPosted: Fri Jul 23, 2010 3:33 pm 
Newbie

Joined: Fri Jul 23, 2010 3:26 pm
Posts: 1
Hi,

i have the two classes Person and Attribut, in short:
Code:
@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(mappedBy="attributes")
  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:

REV; person_id; attribute_id; REVTYPE
1; 1; 1; 0
1; 1; 2; 0
2; 1; 1; 0
2; 1; 5; 0
3; 1; 8; 0

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.