Announcement Announcement Module
Collapse
No announcement yet.
Mixing Hibernate Transactions and JDBC Transactions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mixing Hibernate Transactions and JDBC Transactions

    Hello, It's just a thought, haven't tried yet. Is it possible to mix both transaction managers? Let's say I have JDBC and Hibernate DAOs. And one of my services I have:

    hibernateDAO.insert(user);
    jdbcDAO.insert(auth, user);

    what if the jdbc throws an exception, is it ok to set the first one to rollback? how do I set more than one transaction manager?

    Regards

  • #2
    Yes, if you use Spring's HibernateTransactionManager it will work with both JDBC and Hibernate transactional operations. You just need one transaction manager. You can easily verify this behaviour with a transactional test case extending AbstractTransactionalDataSourceSpringContextTests from spring-mock.jar. For example, you can modify the Hibernate test cases for the Spring PetClinic sample app.

    Comment


    • #3
      Thanks Mr Johnson, This is what I'm trying here. I have only one transactionalManager (HibernateTransactionalManager) and all my test cases descend from AbstractTransactionalDataSourceSpringContextTests. The problem is only Hibernate gets persisted. I do call setComplete() on the tests I want it to be persisted. Could it be any other thing I forgot to implement?

      Regards

      Vinicius Carvalho

      Comment

      Working...
      X