The audit interceptor was a great start (thanks Rob) - but it didn't
quite meet all of my needs. Some existing entities have an updated_date
- I don't want an audit record for those!
I defined an annotation DoNotAudit:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface DoNotAudit { }
and then modified the logChanges method to add (after
transient/static/final Field check):
// ignore annotated fields
if(fields[ii].isAnnotationPresent(DoNotAudit.class))
continue fieldIteration;
Then classes that implement Auditable can use the annotation to indicate
fields that should not be audited, e.g.
@DoNotAudit private Date updatedDate;
Hope this helps!
Robin |