File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

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.


http://www.goodercode.com
SCJP 1.4
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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,

and

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

Mark


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