PDA

View Full Version : Session Close problem in Manager methods while using Two Phase Commit transactions.



yturhan
06-19-2007, 04:38 PM
Hi,

I have a problem with hibernate session when using Two Phase Commit transactions.

I use Spring.Data.TxScopeTransactionManager object as platform transaction manager and diferent sessionfactory objects for each different databases and different DAO objects associated with different session factories. I want to control hibernate sessions within manager methods, like HibernateTransactionManager but the hibernate session close inside the manager methods when I use Spring.Data.TxScopeTransactionManager object.

Is there any way to keep alive the hibernate session until manager methods return when using
two phase commit transactions?

Mark Pollack
06-26-2007, 03:42 PM
Hi,

Can you describe more what you mean by "I want to control hibernate sessions within manager methods, like HibernateTransactionManager but the hibernate session close inside the manager methods when I use Spring.Data.TxScopeTransactionManager object."

If you are using HibernateTemplate in your code, then it will bind a session to the thread when first accessing the Session property in HibernateTemplate via a call to SessionFactoryUtils.DoGetSession. A listener is registered with the transaction manager so that when the transaction commits the session will be flushed.

There is example code in the src distribution, Spring.Data.NHibernate.Integration.Tests.2005, file MultipleDbTests.cs that maybe of help.

Cheers,
Mark