Back Forum Reply New

Which TransactionManager with a JDBC and Hibernate ?

Hello,

I would appreciate it if you could give me some suggestions  

I need to use quot;JDBCquot; and quot;Hibernatequot; in a transactional context :
- sometimes together in the same transaction ;
- sometimes not together in different transactions.

Which TransactionManager should I use ?

I suppose I need at least HibernateTransactionManager in order to work properly whith Hibernate. But, can I use it for supporting transactionnal features with methods using quot;JDBCquot; ? Or, Should I configure my JDBC transactions singly ?

Thank you

Miaina


Originally Posted by Miaina_Hello,

I would appreciate it if you could give me some suggestions  

I need to use quot;JDBCquot; and quot;Hibernatequot; in a transactional context :
- sometimes together in the same transaction ;
- sometimes not together in different transactions.

Which TransactionManager should I use ?

I suppose I need at least HibernateTransactionManager in order to work properly whith Hibernate. But, can I use it for supporting transactionnal features with methods using quot;JDBCquot; ? Or, Should I configure my JDBC transactions singly ?

Thank you

Miaina

If you wanna to have your transaction managed by sping you have 3 choices:
JdbcTransactionManager, HibernateTransactionManager or JtaTrnasactionManager.

If you plan to mix JDBC and hibernate we can eliminate the first one. So you can choose between HibernateTransactionManager and JtaTransactionManager.

It depends if you plan to have multiple (more than one) transaction resources i.e DB, JMS.

Whatever you choose remember to flush session after hibernate operations prior to JDBC calls.

Actually HibernateTransactionManager fulfils the required conditions :

sp...onManager.html
This transaction manager is appropriate for applications that use a single Hibernate SessionFactory for transactional data access, but it also supports direct DataSource access within a transaction (i.e. plain JDBC code working with the same DataSource). This allows for mixing services which access Hibernate and services which use plain JDBC (without being aware of Hibernate)!

All is in the javadoc  , next time I'll check there before asking such basic questions.

Thank you for your help.

Ciao,

Miaina

Now i read this topic.
Thanks Miaina for the question.
Thanks miluch for the answer.
It's useful for me.

Note:
Right now I am trying to return spring.
¥
Back Forum Reply New