In Hibernate Envers, both @NotAudited and RelationTargetAuditMode.NOT_AUDITED are used to exclude entities or fields from being audited, but they are applied in different contexts and have different levels of granularity.
@NotAudited:@NotAudited is an annotation that you can apply to specific fields within your entity class to exclude those fields from being audited.Example:
@Entity @Audited public class MyEntity { @Id @GeneratedValue private Long id; private String auditedField; @NotAudited private String nonAuditedField; // getters and setters } In the example above, nonAuditedField is marked with @NotAudited, so changes to this field will not be audited.
RelationTargetAuditMode.NOT_AUDITED:RelationTargetAuditMode is used to specify the audit mode for related entities in one-to-many and many-to-many relationships.RelationTargetAuditMode.NOT_AUDITED is used to exclude related entities from being audited. When you set this mode, changes to the related entities won't be tracked by Envers.Example:
@Entity @Audited public class ParentEntity { @Id @GeneratedValue private Long id; @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL) private List<ChildEntity> children; // getters and setters } @Entity @Audited public class ChildEntity { @Id @GeneratedValue private Long id; @ManyToOne private ParentEntity parent; // Other fields // getters and setters } In this example, @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) is applied to the children field in ParentEntity. This means that changes to the related ChildEntity instances won't be audited when changes are made to the ParentEntity.
To summarize, @NotAudited is used at the field level to exclude specific fields from auditing, while RelationTargetAuditMode.NOT_AUDITED is used at the relationship level to exclude related entities from auditing in one-to-many and many-to-many relationships.
mysql-error-1170 sonarqube-scan xsd.exe array.prototype.map android-datepicker aws-step-functions keylistener layout-xml ora-00904 bind