title: Refreshing entity after database trigger
body: <p>I want to update some fields of an entity and then return the updated entity. The corresponding table has a update trigger which sets the current timestamp in a column (I'd like to do this on a database level and not via JPA).</p>
  
  <p>First I use the entitymanager's find() method to retrieve the existing entity via its ID and then update some fields using the entity's setters. However when I return the entity, the update column/field of my Java entity was not updated, even though it was updated in the database table through the update trigger.</p>
  
  <p>I've tried the entitymanager's refresh() method after setting the changed values, but it seems that this voids all my changes (probably since the entity has not been committed yet?).</p>
  
  <p>1) Is there a better way to get the correct values other than letting the transaction commit and then retrieve the entity again using find()?</p>
  
  <p>2) I'm not really sure how to annotate the "last changed" column in my entity. What is the best way to annotate a field, that is only changed by a database trigger? Right now I'm using (since I only want the database trigger to update this field):</p>
  
  <pre><code>@Column(name = "last_changed", nullable = false, insertable = false, updatable = false)
  </code></pre>
  
  <p>Does anyone have some helpful input on this? Any help is appreciated, thanks!</p>