title: Trying to implement audit in my Play framework application
body: <p>I've done a fair amount of research to find audit library which integrated well with JPA and Java/Play.</p>
  
  <p>I found nothing simple and ready to use (I'm maybe wrong about this). However I found this :</p>
  
  <p><a href="http://code.google.com/p/simplejpa/wiki/EntityListeners" rel="nofollow noreferrer">http://code.google.com/p/simplejpa/wiki/EntityListeners</a></p>
  
  <p>And I have implemented simple AuditListener class that has two simple methods :</p>
  
  <pre><code>@PrePersist
      public void prePersist(Object object) {
          if(object instanceof MyObj){
              MyObj brand = (MyObj) object;
              Logger.info("waaaa " + br.toString());
          }
      }
  
  @PreUpdate
      public void preUpdate(Object object) {
          if(object instanceof Brand){
              MyObj br = (MyObj) object;
              Logger.info("waaaazaa update" + br.toString());
          }
      }
  </code></pre>
  
  <p>And I'm able to debug the code and I can see that this is working. However I'm supposed to develop some auditing mechanism that later on is going to know what has changed on the certain object.</p>
  
  <p>Ex :</p>
  
  <pre><code>Obj a = new Obj();
  a.name = "My name is T";
  a.save();
  </code></pre>
  
  <p>And this would trigger prepresist, and nothing has changed in this case I can just simply write to my audit table, new object created. However if the update happens :</p>
  
  <pre><code>Obj a = getItFromMyDB;
  a.name "My name has changed";
  a.update();
  </code></pre>
  
  <p>The PreUpdate is triggered. How would I know what the value of this object was before it was updated? </p>
  
  <p>In this preupdate method I get only the new updated object. If I knew how to get the "old" object I could then compare them and save the change in my audit db.</p>