• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

lazy loading not working in hibernate 3

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,









and my entity objects:





when i run following statement it fetching child/referenced objects too which i dont want







any suggestions where things going wrong? please suggest.

Regards
Kishore
 
Ranch Hand
Posts: 123
Firefox Browser Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where did you get the data you used to print below?



If it is from the same 'event' object instance returned by hibernate, and if at that moment that object is still managed by hibernate, you will inadvertently load the data.
 
kishore mang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kathleen,

appreciate for your quick response, even i removed toString() in all classes still able to see
in debug view the event object and its all child objects loaded with all values set.

So i am sure that returned session.get() which is event is loaded all its child objects.
This means eclipse debug view loading all referenced child objects?

Regards
Kishore
 
Kathleen Angeles
Ranch Hand
Posts: 123
Firefox Browser Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it is possible that is the eclipse debug mode that loads it.

Quite dirty, but just to see that those data are really lazily-loaded: disable the debug mode of eclipse, after getting the 'event' object from hibernate, terminate or close the hibernate session, then try display the supposed-to-be lazily-loaded data. You should get an exception or null, showing that it was never loaded by hibernate.
 
kishore mang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you are right!!!
after session closed in eclipse debug mode i can see message about all referenced objects
as "com.sun.jdi.InvocationException occurred invoking method", means referenced data not loaded.

i never expected that eclipse debug mode causing referenced data get loaded by parent.
 
bacon. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic