*
The moose likes Object Relational Mapping and the fly likes fetch as {select|join} not working as expected - hibrnate3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "fetch as {select|join} not working as expected - hibrnate3" Watch "fetch as {select|join} not working as expected - hibrnate3" New topic
Author

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

Naresh Chaurasia
Ranch Hand

Joined: May 18, 2005
Posts: 356
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.

SCJP 1.4, SCWCD1.4, OCA(1Z0-007)
Naresh Chaurasia
Ranch Hand

Joined: May 18, 2005
Posts: 356



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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: fetch as {select|join} not working as expected - hibrnate3
 
Similar Threads
Unknown entity class: java.lang.Integer
hibernate3 : help find out the error
Problem with many to one Mapping
Hibernate_listing database values
Probme in Many-to-One mapping