• 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

Any reason for Lazy Exception

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Consider the following code





My main method


}

I am getting this exception on System.out.println(user2.getUserName())




It looks like session was closed that's why it happened
But isn't this applicable to the collections only...here I have a simple property which I am fetching which should be fetched eagerly by default

Thanks in advance
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This posts talk about the problem and give 4 solutions: http://uaihebert.com/?p=1383
 
Ryan Raina
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hebert Coelho wrote:This posts talk about the problem and give 4 solutions: http://uaihebert.com/?p=1383



I am still not able to understand it ..only collection should be LAZY fetch but a simple property should be eager by default...
 
Ryan Raina
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ryan Raina wrote:

Hebert Coelho wrote:This posts talk about the problem and give 4 solutions: http://uaihebert.com/?p=1383



I am still not able to understand it ..only collection should be LAZY fetch but a simple property should be eager by default...



I think I have figured this out ..The problem is with load method which always returns a proxy whether for simple property or collection...But if one uses get method it eager fetches simple properties but still gives a proxy for all collections...
Also if ID is not found get will return null while as load will throw an exception..


Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic