为情所困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可以顯著的減少查詢的數量
找到一篇講的很好的文章