• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Entity Beans in HTTP Session

 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic