• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate Entity Beans in HTTP Session

 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic