• 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

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
 
Everybody's invited. Even this 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