This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate Entity Beans in HTTP Session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Entity Beans in HTTP Session" Watch "Hibernate Entity Beans in HTTP Session" New topic

Hibernate Entity Beans in HTTP Session

Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
So I would like to store an entity bean, User in session. However, the lazily loaded properties will not be automatically loaded and I am getting LazyInitializationException when pulling the user back from the session on subsequent requests. What is the best method of dealing with this? I guess it would be ok to call a method (if there is one) that would go ahead and pull all lazily loaded members (to a depth of 1 I guess). I am using Spring HibernateDaoSupport / HibernateTemplate to access Hibernate.

Also, I do have OpenSessionInViewFilter configured. But, I suspect that even that will not fix this problem.
SCJP 1.4
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17249

Whenever you use detached objects you need to

1) make sure all the data you need is there before sending the object to the client,


2) when the object is sent back to the server from the client, you need to merge it.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
wood burning stoves
subject: Hibernate Entity Beans in HTTP Session
Similar Threads
what is lazy initialization in hibernate
Lazy loading exception in presentation layer, what's the nicest way to avoid them?
saving entity with a lazy property
@Basic(fetch = FetchType.LAZY) does not work
reusing sessions across multiple method calls