-->
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.  [ 2 posts ] 
Author Message
 Post subject: LazyLoading, SessionPerView and Cocoon
PostPosted: Thu Sep 09, 2004 12:57 pm 
Newbie

Joined: Fri Aug 13, 2004 5:00 pm
Posts: 3
Location: Germany
Hi there,

I'M using hibernate 2.1.6 in a cocoon-based Webapplication.
We are unlucky to have a User, retrievd by hibernate stored in the cocoon-session. So we have to re-store that user into the hibernateSession of the current request by calling
Code:
lock(currentUser, LockMode.NONE);

. That far everything works.
But now we have some JXSites (kind of JSP) where we have to retrieve several objects provided by an "Action". Some times we then get an error:
ERROR - Failed to lazily initialize a collection - no session or session was closed
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed

I know where the Problem is: My Action uses a Cocoon (=> also an Avalon-) Component to create a new hibernateSession for each request. And when cocoon (better avalon) decides that the work is done for that Action it "dispose()"es my Action and the HibernaeSession is closed. But it should last for just a few more seconds to remain opened till that JX-Page has been processed.
Because we are under heavy pressure I did that quick+dirty thing:
I leave the HibernateSession opened and put it into the HttpSession. So it remains opened. If there is another request the first thing i do is to get the HibernateSession from the HTTPSession and close it.
But sometime the user ends her session. And so I get at the console:
unclosed connection
finalizing unclosed session with closed connection

My questions are:
- Does somebody know a better way to this (except closing the HibernateSession inside these JXTemplates - this is unfortunatly impossible)
- Do you think that our way is "dangerous". This means is it critical to have several opened and unused hibernateSessions which are closed automaticaly by hibernate itself? That one is the most important question for me.

So please tell me whether I have to rebuild everything or if I could take this solution and have to live with these outputs and a bit wasted ressources.

Thanks in advance!

Helge


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 2:02 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
check "open session in view"
you should use a servlet filter

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.