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

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

        
3条回答
  •  北恋
    北恋 (楼主)
    2021-01-30 06:58

    Auditing the target entity and its relations are two separate things. So it depends on what you need. From Hibernate Envers - Easy Entity Auditing documentation:

    If you want to audit a relation, where the target entity is not audited (that is the case for example with dictionary-like entities, which don't change and don't have to be audited), just annotate it with @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED). Then, when reading historic versions of your entity, the relation will always point to the "current" related entity.

提交回复
热议问题