• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a general doubt in using Left Join Fetch

 
Rahul Babbar
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody please...
 
Rahul Babbar
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody please..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic