HQL: Fetch Join Collections from Eager Table

前端 未结 2 1897
借酒劲吻你
借酒劲吻你 2021-02-16 00:12

I have four tables:

RootNode // Will return multiple root nodes 
SubNode // Will return one sub node per root node
SubNodeChildren1 // Will return multiple for e         


        
2条回答
  •  不思量自难忘°
    2021-02-16 00:58

    In order to get the query working, I had to do an INNER JOIN FETCH instead of a LEFT OUTER JOIN FETCH on the eager entity:

    SELECT rn FROM RootNode AS rn INNER JOIN FETCH rn.SubNode AS sn LEFT OUTER JOIN FETCH sn.SubNodeChildren1 LEFT OUTER JOIN FETCH sn.SubNodeChildren2 ...
    

    To be honest, I'm still not exactly sure why it's working with an INNER JOIN FETCH vs a LEFT OUTER JOIN FETCH, but it definitely is working exactly as I need it to.

提交回复
热议问题