• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between Fetch Join and inner join

 
Anuj Singhal
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic