title: How to save old and new values of columns into Audit table using Spring Data JPA
body: <p>I am using <code>Spring Boot</code>, with <code>Spring Data JPA</code> and <code>MS Sql server2014</code> database for process of saving and updating the entity(javax.persistence) into tables.</p>
  
  <p>As per the requirement we need to audit the every column of all the tables. So i created new table as "Audit" with the respective columns. But I not sure how to save the old and new values and other columns.</p>
  
  <p>Is there any seperate api in spring to support this functinality? </p>
  
  <pre><code>create table Audit
  (
    Id INT NOT NULL PRIMARY KEY,
    TableName VARCHAR (100)
    ColumnName VARCHAR (100)
    RowId INT,
    OldValue VARCHAR (100),
    NewValue VARCHAR (100),
    Type VARCHAR (100),
    ChangedDate DATETIME,
    ChangedBy VARCHAR (100),
  );
  </code></pre>
  
  <p>where "Type" indicates the type of DML operation and "Old value &amp; New value" columns saves pervious and existing values of columns in parent table.</p>
  
  <p>Can I know the best approach to auditing the entity i.e save and update the old and new values along with other relative fields into Audit table.</p>