つまり、Person と Attribut の 2 つのクラスがあります。
@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...
}
これらのクラスでは、db テーブルの person、attributes、attribute_alloc、persons_aud、attributes_aud、および attribute_alloc_aud が正しく生成されました。
個人の属性の監査を除いて、すべてがうまく機能します。テーブル attribute_alloc_aud では、変更 (たとえば、属性を削除して個人に新しい属性を追加するなど) は正しく追跡されますが、常に REVTYPE ADD でマークされます。例えば:
- 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
その結果、前回のリビジョンで被監査者は属性 1、2、5、および 8 を持っています。正しいのは 8 だけです!
どうしたの?どうもありがとう!よろしくお願いします
レヴィ