SUBSELECT: avoids N+1 and does not duplicate data, but loads all entities of related types into memory.
FetchMode.SUBSELECT should look like this:
SELECT <employees columns>
FROM EMPLOYEE employees0_
WHERE employees0_.DEPARTMENT_ID IN
(SELECT department0_.DEPARTMENT_ID FROM DEPARTMENT department0_)
FetchMode.SUBSELECT can significantly reduce the number of queries
SUBSELECT: avoids N+1 and does not duplicate data, but loads all entities of related types into memory.
FetchMode.SUBSELECT should look like this:
FetchMode.SUBSELECT can significantly reduce the number of queries
I found a very good article