Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Difference between Fetch Join and inner join

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Refer below extract from specification , section 4.4.5.
-----------------------------------------------------------------------------------------------------------------------
SELECT d
FROM Department d LEFT JOIN FETCH d.employees
WHERE d.deptno = 1


A fetch join has the same join semantics as the corresponding inner or outer join, except that the related
objects specified on the right-hand side of the join operation are not returned in the query result or otherwise
referenced in the query. Hence, for example, if department 1 has five employees, the above query
returns five references to the department 1 entity.

-----------------------------------------------------------------------------------------------------------------------

I am not clear on above paragraph. The above query will return 5 references when inner join is used or when fetch join is used?

What will be the difference in behavior between below two queries?
a)
SELECT d
FROM Department d LEFT JOIN d.employees e
WHERE d.deptno = 1

b)
SELECT d
FROM Department d LEFT JOIN FETCH d.employees
WHERE d.deptno = 1


Thanks,
Anuj
 
Anuj Singhal
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will a) return just one reference of department object, whereas b) will return 5 references of Dept object?
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
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!