title: How to log Spring transaction content
body: <p>There have been various posts of logging the activity (start, commit &amp; rollback) of Spring's transaction manager. However, I recently came across a deadlock issue for which logging just the activity isn't enough. </p>
  
  <p>The fundamental issue in our code is a messy usage of transaction propagations REQUIRED and REQUIRES_NEW. There are so many method calls back- and forth that we end up with a lot of transactions stacked onto each other. Alas, the code base is huge and the solution urgent... (We all know what this is.)</p>
  
  <p>The issue was a deadlock because code was added to query entities in a transaction that were sub-sequentially modified in another transaction. Spring spits out an exception telling the update of entity X times out because it's locked. Now, Knowing this is nice, but how does one find the faulty code: The query which does the early locking.</p>
  
  <p>My question (at last) : Is there a way to log the entities being added to a transaction ? This way I can specifically look for transactions locking the entity Spring is complaining about.</p>
  
  <p>Thanks ! :-)</p>