I'm well aware of the "problem" of session context and the issue w/ calling a 
lazy collection outside of that context in Hibernate.

What I'm looking for is advice - some simple insight into techniques to get 
around the limitations in EJB3/Hibernate lazy collections to make life easier, 
if possible.

I realize that if I'm calling a single object in the stateless session bean, I 
can get the lazy collection by simply calling the size() method of the 
collection...and then return it to the view and life is good.

However, what if I've got a hierarchy like this:

Product -> List -> List

So I've got a Product that has many Configurations, each Configuration can have 
many Prices....a one-to-many w/ each having its own one-to-many.

My particular headache happens when I call a List and I need to display the 
Price for each product....will I have to loop through each Product, call size() 
on the List, then loop through each Configuration and call size() on List??

Before JBoss 4.0.4.GA (RC1, CR2) I had eager fetching for both the 
Configuration and the Price collections and it seemed to work...but obviously 
something changed in GA to prevent that since it throws an exception on my when 
deploying the app.

I got around this when learning Hibernate by simply not using the object 
hierarchy that is queried automatically and just calling separate lists by the 
parent object's ID value...but that just generates even more queries.

Is there some way to make the session run longer in the container so it's 
available to the lazily-loaded collections?  Again, forgive me for my 
ignorance, I'm just shooting in the dark.

When I started off on learning EJB3 I assumed there'd be some magic in the 
container to prevent lazy-loading session management issues like I experienced 
in plain Hibernate (outside of a J2EE container.)

Any advice would be greatly appreciated, thanks!  My new EJB3 O'Reilly book is 
on the way but until then, please advise!

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3948167#3948167

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3948167


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to