-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: LazyInitializationException crept in after upgrading
PostPosted: Mon Nov 06, 2006 3:35 pm 
Newbie

Joined: Tue Sep 05, 2006 10:39 am
Posts: 13
I have a fairly extensive application now on the project I am working on and I have just completed the upgrade to Hibernate 3.2 from 3.1.2. To be exact, I should say 'almost' completed, because I am dealing with this one last hurdle standing in the way of checking in all the upgrade changes (I upgraded Spring Webflow too).

I am now seeing LazyInitializationExceptions when I access collections in the JSPs.

Please could someone point me to the most likely culprit that I must have inadvertently removed or disabled in my configuration that could be causing this?

Some of my objects I fetch via criteria queries, where I don't do any lazy loading on the objects. The objects causing the problem are fetched by id and stored in the request scope by the actions for use with lazy loading in the JSPs.

I was using the Spring OpenSessionInView aspect interceptor, so I tried changing to the OpenSessionInViewFilter, and I can see that it is in the filter stack of the exception.

I stripped out Acegi and transactions to take the config back to the bare bones.

Where should I be looking?

Thanks
Adam


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 10:23 pm 
Newbie

Joined: Tue Apr 11, 2006 1:28 pm
Posts: 6
I remember reading somewhere that lazy was changed to true by default. (of course I could just be dreaming it)

You could add to your mapping files lazy="false" wherever you have a collection and that should cure the problem..


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 6:08 am 
Newbie

Joined: Tue Sep 05, 2006 10:39 am
Posts: 13
Nothing about changing the default lazy setting in the changelogs. It might have been from 2.x to 3.x I guess.

I gave you a credit on the basis that your comments spurred me into action to move on with this issue which has been eating up my time. I shall work around it for now, and try not to let it gnaw away at my mind all day.

Why isn't OpenSessionInView working? That is the question. What is interfering with it?

Whether lazy="" is set to true or false is irrelevant to the problem at hand. What else could effect it?

What could be closing the hsession early?

Could I have these beans left in the http session from some earlier request? Perhaps during the upgrade I changed some Spring MVC settings or Spring Webflow settings that resulted in such a change.

Anything else?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 10:37 am 
Newbie

Joined: Tue Apr 11, 2006 1:28 pm
Posts: 6
I don't know what would cause the session to close early for your application, but I when I ran in to this I switched to a single session model. I know the Hibernate team doesn't recommend it, but it works well in my application environment. Of course, I am working with applications dedicated to a single user and not a web page or JSP.

You did have my curiosity aroused though... So I did a little more research. I am sure you have seen this page already, but it talked alittle about the problem you are having.

http://www.hibernate.org/43.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 10:48 am 
Newbie

Joined: Tue Sep 05, 2006 10:39 am
Posts: 13
Thanks for the link, but I've visited it quite alot already.

I found the issue. Spring webflow have introduced the post-redirect-get pattern into all their web framework actions - meaning that my action where I retrieved my Hib object then sent a redirect to the browser before going to the JSP. Hence the hsession being closed.

I read about the redirect earlier, but it failed to sink in that it would directly affect the Hsession.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

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.