• 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

fetch as {select|join} not working as expected - hibrnate3

 
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have following code:




I am setting fetch as {select|join}. In both cases the get the following output in the following loop:

if(e2!=null)
{
System.out.println("not null"); //line1
//System.out.println(e2.getFirstname()); //line2
}

and no select query is being fired on db.

My understanding is that in case of fetch="select", the proxy is loaded so the select query is not being fired. But in case fetch="join" eager loading should take place and select query should be fired immediately when instance is loaded from session. In none of the cases no selet query if fired.





Please clarify. Thanks.
 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



In case i uncomment line2 the following query is fired irrespective of fetch as {select|join}

System.out.println("not null"); //line1
System.out.println(e2.getFirstname()); //line2
reply
    Bookmark Topic Watch Topic
  • New Topic