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
|