0
我有兩個類Person和Attribut,簡而言之:@ManyToMany:REVTYPE僅ADD
@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...
}
這些類的分貝表者,屬性被正確生成attribute_alloc,persons_aud,attributes_aud和attribute_alloc_aud。
除了對Person中的屬性進行審計之外,所有的工作都很好。在表attribute_alloc_aud中,正確跟蹤更改(例如,刪除屬性並向人員添加新屬性),但始終用REVTYPE ADD標記。例如:
- REV;爲person_id; attribute_id; REVTYPE
- 1; 1; 1;
- 1; 1; 2;
- 2; 1; 1;
- 2; 1; 5;
- 3; 1; 8;
後果是,被審計人在最後一次修訂具有的屬性1,2,5和8正確的將只有8!
怎麼了? 非常感謝! 最好的問候
列維
謝謝!這是一個非常有用的提示! – Levis 2010-08-02 14:41:16