I have four tables:
RootNode // Will return multiple root nodes
SubNode // Will return one sub node per root node
SubNodeChildren1 // Will return multiple for each sub node
SubNodeChildren2 // Will return multiple for each sub node
and a similar entity structure:
RootNode -> SubNode -> SubNodeChildren1
-> SubNodeChildren2
I need one query that will return all the RootNodes
in the table with its SubNode
and SubNode
children initialized. The SubNode
is eagerly fetched, but the SubNode
children is lazy fetched.
I know how to write a query that will LEFT OUTER JOIN FETCH
the immediate children of a table and initialize them accordingly. However, I have no idea of how to grab the children of a table that is eagerly fetched from the top-level table.
I have tried something like:
SELECT rn FROM RootNode AS rn LEFT OUTER JOIN FETCH rn.SubNode.SubNodeChildren1
but, this always gives me an error that the owner is not part of the SELECT.
Any help is greatly appreciated.