File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 17276

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 - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Hibernate Entity Beans in HTTP Session
It's not a secret anymore!