PDA

View Full Version : OpenSessionInView and jboss TransactionManager


kbaum
Aug 14th, 2004, 11:14 AM
My application is currently configured to use the OpenSessionInView Filter in single session mode. Everything was working perfectly until I changed from the default hibernate transaction manager over to the Jboss implementation. For some reason it is creating a new session for each database access and closing the session.
This is resulting in LazyInitialization exceptions.

Is there an obvious configuration change I am missing when switching over to the Jboss container transactions?

Thanks.

Karl

Colin Sampaleanu
Aug 15th, 2004, 04:43 PM
Your post doesn't actually give enough details, but I presume you switched from using Spring's HibernateTransactionManager, to using Spring's JTATransactionManager.

The main diference between these two setups is that in the former, a new Hibernate Session will be created together with the transaction, and bound to the current thread and associated with that transaction. Then any nested HibernateTemplate usage would pick that up. With the latter, the first usage of a HibernateTemplate (with the allowCreate flag set to true) would create a new session, and only then associate it with the current thread/transaction. To get the exact same behaviour, you would also have to add a HibernateInterceptor into the transaction definition. But all this changes is when the one session is created and bound, and doesn't explain your behaviour.

What you are describing sounds almost like the OpenSessionInView filter is not kicking in, _and_ transactional wrapping itself is not kicking in. Changing from one transactionmanager to another should not affect this in any way. I would look at your config and logs more closely.

Regards,

alesj
Oct 19th, 2004, 04:17 AM
Was this issue ever solved? Since I have (I believe) the same problem: http://forum.springframework.org/showthread.php?t=10910.

Thanx, Ales