title: How to wrap an object change in my own transaction and incorporate it with Hibernate to JTA?
body: <p>I have a web-app, which I deploy on Tomcat 6 and it uses Hibernate.
  It receives messages on a JMS queue which trigger changes both to my DB, via Hibernate and to an Object of mine (<code>Agent</code>).<br>
  The web-requests also access the DB, via Hibernate, and access the shared object (there's a <code>ConcurrentHashMap&lt;AgentId,Agent&gt;</code> held by a singleton).<br>
  My problem is that I have a JMS message which changes several different <code>Agent</code>s and several tables and I need the changes in the <code>Agent</code>s to be available if and only if the DB transaction completed successfully. In addition I do not want to employ read locks as that is too much of a performance hazard for me.<br>
  I was thinking of <strong>somehow</strong> implementing the <code>XAResource</code> interface for my singleton and then use JTA to manage both my singleton and my Hibernate transaction.<br>
  What do you think? Does it sound reasonable? Am I way off?  </p>
  
  <p>If any additional details are needed please don't hesitate to ask<br>
  Ittai</p>