我有两个课程和归因,简称

@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; vertpe
  • 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!

怎么了? 非常感谢! 最好的问候

levi

有帮助吗?

解决方案

可能可能是在您更新多蒙甲中的集合时,您可能会清除收集,然后添加新集合。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top