@ManyToMany:REVTYPE هو فقط إضافة
-
28-09-2020 - |
سؤال
لدي فئتين شخص Attribut باختصار:
@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 الجداول الأشخاص ، والصفات ، attribute_alloc, persons_aud, attributes_aud و attribute_alloc_aud تم بشكل صحيح ولدت.
كل شيء يعمل بشكل جيد باستثناء مراجعة الصفات في الشخص.في الجدول attribute_alloc_aud التغييرات (على سبيل المثال إزالة سمة وإضافة واحدة جديدة إلى شخص) يتم تتبع بشكل صحيح ، ولكن دائما ملحوظ مع REVTYPE إضافة.على سبيل المثال:
- 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 فقط!
ما هو الخطأ ؟ شكرا جزيلا!مع أطيب التحيات
ليفي
المحلول
قد يكون هذا ربما عند التحديث جمع في ManyToMany قد يكون التخلص من جمع ثم إضافة مجموعة جديدة.
لا تنتمي إلى StackOverflow