This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java and have Dr. Raoul-Gabriel Urma & Richard Warburton on-line!
See this thread for details.
Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

a general doubt in using Left Join Fetch

 
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..
 
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!