Announcement Announcement Module
No announcement yet.
Multiple Resources Transaction Question Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • davidcnoel
    started a topic Multiple Resources Transaction Question

    Multiple Resources Transaction Question

    I'm a little confused about how Spring handles transactions.

    I have two Hibernate sessions that are associated with two different DB2 databases. My business logic class uses DAO objects that are associated with each of the two Hibernate sessions. When a method on my business logic class throws an exception I want to roll back connections from both resources.

    To do this it sounds like I need to use the JTA Transaction Manager. Is this really required though? It sounds like JTA implementations are provided by a J2EE container but in my case I am not using a J2EE container. I am running in a standalone java environment. Any ideas on how I set this up?


  • smccrory
    I think I recall that the Javadoc for the Hibernate transaction manager says it's OK to combine with Spring JDBC.


    Leave a comment:

  • davidcnoel
    Rob, thanks for the quick response.

    I just realized I had another transaction question.

    In this example I have only one datasource and two DAOs associated with the datasource. One of the DAOs is implemented in Hibernate and the other is implemented in SpringJDBC. Can I get away with using the Hibernate transaction manager because both DAOs use the same resource under the covers or are they treated as different resources and I have to use a JTA transaction manager?

    Thanks again.

    Leave a comment:

  • robh

    Since you are using two databases, you will certainly need to use JTA transactions. Thankfully, JTA is not coupled to use in just a J2EE environment and can be used standalone. Check out JOTM for a standalone JTA TX manager.


    Leave a comment: