-->
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.  [ 6 posts ] 
Author Message
 Post subject: Session Thread Local
PostPosted: Fri Mar 26, 2004 9:53 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 7:59 am
Posts: 24
Please Help! I using Webpshere 4.03 and Struts 1.1 and don't have the luxury of using Serlet Filters... can someone explain how to use the hibernate session correctly.

I'm planning on using the thread local pattern, however my problem is that without Servlet Filters how can I ensure that the session is closed at the end of the request/response cycle?

Do I have to use the not recommended Auto timeout approach?

Any assistance would be appreciated.

Thanks. Pete


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 8:36 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 7:59 am
Posts: 24
I guess no one has a solution? So how's this sound place the hibernate session in the HttpSession ensuring that transactions disconnect and reconnect as required.

I assume use of disconnect and reconnect will work for lazy instantiation, i.e can you lazily instantiate when a session is disconnected? If not what's the solution.

Any help/advice would be gratefully apprecaited.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 8:41 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You need some kind of interceptor that at least closes/disconnects the Session after the view is rendered. A disconnected Session can't be used for lazy loading, of course.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 9:04 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 7:59 am
Posts: 24
Agreed, but that is the crux of the problem, how best to achieve this if you don't have the benefit of the Spring framework interceptors or Servlet filters?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 9:06 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Then initialize all the data you need in a particular view before closing the Session by either using a runtime eager fetching strategy ("fetch join" in HQL, FetchMode in Criteria) or Hibernate.initialize().

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 10:23 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
I have used ThreadLocals for "old" struts with "old" servelt containers without problems:

public class MyServlet extends ActionServlet {


public void service(...

{

//DO BEFORE

super.service( ...

//DO AFTER


}

}


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