What's the difference between @NotAudited and RelationTargetAuditMode.NOT_AUDITED in Hibernate EnVers?

前端 未结 3 1368
一向
一向 2021-01-30 06:53
@NotAudited
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
@OneToMany(mappedBy = \"booking\")
@OrderBy(\"bookingOrder\")
private List

        
3条回答
  •  清酒与你
    2021-01-30 06:56

    @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) has only one usage: When you have audited entity owning the relationship to not audited entity and you want info in audit data about the id of not audited entity. Let's say that CustomerBooking is audited and Hotel class is not audited. You have two choices for Hotel field:@NotAudited (in which case you will not have info about hotel in historical data at all) or @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) in which case you will have always the latest state of Hotel in audit data. Note that if Hotel was audited RelationTargetAuditMode.NOT_AUDITED will just be ignored (you will have historical data for Hotel). @NotAudited means "I just don't care for this field in historical data" (it won't be saved, relationship will be null, you won't see it when looking historical data about CustomerBooking)

提交回复
热议问题