Audit Property change - Spring MVC+ JPA
<p>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).</p>

<pre><code>public class Client {
private Long id;
private String firstName;
private String lastName;
private String email;
private String mobileNumber;
private Branch companyBranch;
</code></pre>

<p>actually this is very easy to audit the whole entity with @Audited annotation.</p>

<p>But what I want is to audit this changes using my class structure.</p>

<p>here is my desired result class:</p>

<pre><code>public class Action {
private String fieldName;
private String oldValue;
private String newValue;
private String action;
private Long modifiedBy;
private Date changeDate;
private Long clientID;
</code></pre>

<p>the result should look like this:</p>

<p>fieldName + "was changed from " + oldValue + "to" + newValue + "for" clientID +"by" modifiedBy;</p>

<ul>
<li>mobileNumber was changed from 555 to 999 for Bill Gates by George.</li>
</ul>

<p>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. </p>

<p>How can I do this?</p>

<p>Thanks</p>