Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to fetch lazily loaded entities?

 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a entity Dept within Employee entity. The Dept entity is set to lazy loading.

Any idea on how to do a emp.getDept() in the web tier when the DAO has long closed the session after the Employee was fetched?

Update: I am using Hibernate3 with Spring 2.0
[ November 25, 2008: Message edited by: nitin pai ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like the Session per request pattern is what you are after. Have a read of this.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!