I have a class Client. I want to be able to audit the changes of property of this class(not entire class - just it's properties).
public class Client {
private Long id;
private String firstName;
private String lastName;
private String email;
private String mobileNumber;
private Branch companyBranch;
actually this is very easy to audit the whole entity with @Audited annotation.
But what I want is to audit this changes using my class structure.
here is my desired result class:
public class Action {
private String fieldName;
private String oldValue;
private String newValue;
private String action;
private Long modifiedBy;
private Date changeDate;
private Long clientID;
the result should look like this:
fieldName + "was changed from " + oldValue + "to" + newValue + "for" clientID +"by" modifiedBy;
- mobileNumber was changed from 555 to 999 for Bill Gates by George.
The reason I'm doing this is that I need to store this changes into DB under Action table - because I will be Auditing properties from different Entities and I want to store that together and then have a ability to get them when I need.
How can I do this?
Thanks