Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Hibernate 2: getting lazy exception after trying to get a collection from a transient object

 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am getting lazy exception after trying to get a collection property from a transient object. This object was retrieved in a session that is already closed. So I opened the new session and did sess.update on this object but this didn't help.
what did help is getting the id of this object and doing.

This is no elegant in my opinion. So why sess.update does not help and is there any other way then retrieving the object again by it;s id?

Thanks.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi John Landon,

the Session.get() method returns an uninitialized proxy of the requested entity. To not cause a LazyInitializationException you could "touch" the proxy within the session by deliberately calling one of its methods which forces proxy initialization. You could also choose Session.load() which returns an initialized instance.

CU
Froestel
 
John Landon
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Andreas Erber wrote:Hi John Landon,

the Session.get() method returns an uninitialized proxy of the requested entity. To not cause a LazyInitializationException you could "touch" the proxy within the session by deliberately calling one of its methods which forces proxy initialization. You could also choose Session.load() which returns an initialized instance.

CU
Froestel



thanks but load does not help
 
What a stench! Central nervous system shutting down. Save yourself tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic