aspose file tools*
The moose likes Object Relational Mapping and the fly likes a general doubt in using Left Join Fetch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "a general doubt in using Left Join Fetch" Watch "a general doubt in using Left Join Fetch" New topic
Author

a general doubt in using Left Join Fetch

Rahul Babbar
Ranch Hand

Joined: Jun 28, 2008
Posts: 210
Hi,

I did a simple HQL query like.

where the lazy was set as true in header.
The query returned me 5 rows because the SQL query that was fired was
"select header0_.HEADER_ID as HEADER1_0_0_,
details1_.DETAIL_ID as DETAIL1_1_1_,
details1_.HEADER_ID as HEADER2_1_1_,
details1_.HEADER_ID as HEADER2_0__,
details1_.DETAIL_ID as DETAIL1_0__
from HEADER header0_
left outer join DETAIL details1_
on header0_.HEADER_ID=details1_.HEADER_ID where header0_.HEADER_ID=1"

What i needed was to get only 1 header record, from where i could getDetails() to get the 5 records.
An alternative way of doing(what i needed) was to put lazy="false" and query like "Select h from Header h"...
However, i dont want to use lazy="false"(because i will not always be eagerly loading the details)
I had heard that using Fetch was an alternative to using lazy="false".

So, is there a way that i can use Fetch in the above case and get no of results as 1(from where i can get the 5 records) instead of getting 5 records separately.

Thanks


Rahul Babbar
Rahul Babbar
Ranch Hand

Joined: Jun 28, 2008
Posts: 210
Anybody please...
Rahul Babbar
Ranch Hand

Joined: Jun 28, 2008
Posts: 210
Anybody please..
 
 
subject: a general doubt in using Left Join Fetch