-->
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.  [ 3 posts ] 
Author Message
 Post subject: Sesssion and the web-tier
PostPosted: Wed May 12, 2004 3:36 pm 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
If we have a web-tier fetching/saving and updating Persistent objects, currently I'm thinking of doing the following:

1. Servlet makes a call to a business services object (Struts action).

2. BS Object opens a Hibernate session
3. BS Object fetches the object from the DB
4. BS Object closes session
5. Returns them to the JSP.

For Objects with no relationship this would work very well.

However with objects having 0 or more children, if I use a lazy="true" in the mapping, how would this work?

2 scenarios:
1. Say in the JSP, I try to access the child , since there's no session available it's going to throw me a "Closed Session" error.

2. There's another request to show the child of the parent returned, and the BS Object opens a new session and tries to load the children. In this case again I would first load the parent which would not load the child and then force it to load the children before returning to my JSP?

I'm nto sure if I've made myself clear but my basic question is how does "lazy=true" work with the web-tier in such situations.

Thanks,

Anand


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 12, 2004 4:22 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you can force the collection to be loaded at the second request by
select a from A as a left FETCH join a.collection


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 12, 2004 4:26 pm 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
Yes that is defnly an option. However is there a way for me to change the property of "lazy" the second time so that I don't lazy-load the children?

The reason I ask this is that if I have to FETCH then I'll have to have those queries in my XML and I'm trying to walk away from the same.

Thanks,

-Anand


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