为情所困2017-05-17 10:05:48
SUBSELECT:避免N+1并且不重复数据,但将相关类型的所有实体加载到内存中。
FetchMode.SUBSELECT应该是这样的:
SELECT <employees columns>
FROM EMPLOYEE employees0_
WHERE employees0_.DEPARTMENT_ID IN
(SELECT department0_.DEPARTMENT_ID FROM DEPARTMENT department0_)
FetchMode.SUBSELECT可以显着的减少查询的数量
找到一个讲的很好的文章