-->
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.  [ 4 posts ] 
Author Message
 Post subject: ThreadLocal - when to close session
PostPosted: Tue Jul 12, 2005 4:05 pm 
Newbie

Joined: Thu Jul 07, 2005 1:51 pm
Posts: 15
A bit of a hibernate newbie here, so bear with me if I'm missing something completely obvious - I'm using the ThreadLocal pattern suggested in the documentation in a Hibernate/Struts app.

I'm trying to implement a fast paging strategy for large datasets. This means that I'm unsure about the usefulness of closing the session after each Struts Action finishes executing - however regardless of that, I'm having trouble with my associated, lazy-loaded objects.

It seems that if I manually close the session right before returning from my Struts Action class, I get exceptions from the lazy loaded classes that I'm trying to show on my JSP page.

But if I don't close the session, I eventually get memory space errors.

Is there a simple way to deal with this issue?


Top
 Profile  
 
 Post subject: Re: ThreadLocal - when to close session
PostPosted: Tue Jul 12, 2005 4:08 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
contec wrote:
A bit of a hibernate newbie here, so bear with me if I'm missing something completely obvious - I'm using the ThreadLocal pattern suggested in the documentation in a Hibernate/Struts app.

I'm trying to implement a fast paging strategy for large datasets. This means that I'm unsure about the usefulness of closing the session after each Struts Action finishes executing - however regardless of that, I'm having trouble with my associated, lazy-loaded objects.

It seems that if I manually close the session right before returning from my Struts Action class, I get exceptions from the lazy loaded classes that I'm trying to show on my JSP page.

But if I don't close the session, I eventually get memory space errors.

Is there a simple way to deal with this issue?


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


Top
 Profile  
 
 Post subject: Re: ThreadLocal - when to close session
PostPosted: Tue Jul 12, 2005 4:10 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
pksiv wrote:


One thing I do differntly is that I don't commit the transaction in the filter.

I have implemented a Manager layer which handles all transactions. I found this important so that I could control where the user is routed too after a failure.

If you commit in the filter, Struts has already relinquished control of the request.


Top
 Profile  
 
 Post subject: Re: ThreadLocal - when to close session
PostPosted: Tue Jul 12, 2005 4:50 pm 
Newbie

Joined: Thu Jul 07, 2005 1:51 pm
Posts: 15
pksiv wrote:


Ahh, that's beautiful. Exactly what I was looking for.


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