Access previous entity on update operations
<p>I'm looking for the most idiomatic way to inspect what changes are being made during an update operation through an entity chain managed by Spring Data Rest.</p>

<p>My current use case is that I want to update the last time a password was modified. My domain object has two fields, a password and a modification time. I want my REST api to just have to set the password and I will detect if its a new one and update the modification time. I would prefer to not have my frontend know if it has to set the modification time. I would also prefer to not create a database trigger.</p>

<p>I have tried creating a <code>HandleBeforeSave</code> event that tries to query the existing domain object and compare it to the one passed into the event handler. Unfortunately they are the exact same object so I can't detect the difference between them. I have tried doing the query through both the Spring Data repository and through an <code>EntityManager</code>. I'm using Hibernate 5 as my backend.</p>

<p>When stepping through the <code>patchItemResource</code> method on <code>RepositoryEntityController</code>, the result of <code>payload.getContent()</code> reflects the entire entity, even if I only patched one field, with the updates applied. I can't tell if this is done by Jackson or if the <code>PersistentEntityResource</code> is handling it somewhere. If anyone knows the code flow that does the object merging that would be helpful?</p>