title: Is there a way to track changes of an entity?
body: <p>I have an entity. This entity is modified within a transaction. But at some point I want to know the changes to this entity that were made during the transaction. The reason for that is to trigger an differential export of the changes to the entity. I already developed this "solution":</p>
  
  <pre><code>public void triggerExport(A a)
  {
      em.detach(a);
      A result = em.find(A.class, a.internId);
  
      doExport(a, result);
      em.merge(a);
  
  }
  </code></pre>
  
  <p>I'm not sure if this really is a practicable way to do this. It causes extra database interaction for each comparsion of this entity. What do you think? Is there a better way?</p>