Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Weird Transaction problem
PostPosted: Wed May 16, 2012 11:01 pm 
Newbie

Joined: Tue Jul 19, 2005 1:28 pm
Posts: 14
Hi,

I am facing a weird transaction problem with Spring and Hibernate. Here are the transaction settings:

Method A - (PROPAGATION_REQUIRED, readOnly)
Method B - (PROPAGATION_REQUIRED, readOnly) - returns objects( Object A, which contains collection of child objects)
Method C - (PROPAGATION_REQUIRED, readOnly)

Method A is the main method that queries for a set of objects using Method B, iterates through the objects and any associations and may use Method C for any other processing.

The problem is that all methods work perfectly OK, but when I try to access child objects of the objects returned by Method B, I get LazyInitialization exception because of closed session. However, if I change Method B to PROPAGATION_SUPPORTS, there are no exceptions and I am able to access the child objects.

What is the difference between PROPAGATION_REQUIRED and PROPAGATION_SUPPORTS? I enabled debug on the transactions and see that Method A and B are participating in a transaction with both REQUIRED and SUPPORTS case. However, with REQUIRED, a new session is created for Method B and is closed when Method B exits. While with SUPPORTS, the session is not closed.

I really appreciate if someone can help me out with this. If there is any other way to do it so that I dont get Lazy Exceptions, also would be greatly appreciated.

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.