我試圖審計一個實體,但我不想審計它的關係。如果我在@ManyToOne關係中放置了@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED),這可以工作,並且我沒有任何異常,但是當我嘗試在@onetomany中使用param mappedby定義的相同註釋時,我有除此之外,我說我必須審計其他實體。Hibernate envers:RelationTargetAuditMode.NOT_AUDITED vs @NotAudited
例子:
@Table(name = "OWNERS")
@Entity
@EntityListeners(AuditingEntityListener.class)
@Audited
public class Owner {
...
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
@ManyToOne(fetch=FetchType.LAZY)
private User user;
...
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
private Set<Pet> pets = new HashSet<Pet>();
...
}