So I have A to B to C, where A to B is 1:n and B to C is 1:n. I would like to retrieve all C which are predicated on some property of A. Hence the query I'd like to run would look something like:
Code:
select c from A as a inner join fetch a.collection_of_b as b inner join fetch b.collection_of_c as c where a.prop = 'predicate value'
Now I get an exception saying that the owner of the collection is not in the select list. I have (what I believe to be) an identical query (from the perspective of the results) in this:
Code:
from C as c inner join fetch c.parent_b as b inner join b.parent_a as a where a.prop = 'predicate value'
An almost identical query to the first, but no fetches. Returns the proper results but...it executes far too many queries.
Code:
select c from A as a inner join a.collection_of_b as b inner join b.collection_of_c as c where a.prop = 'predicate value'
However, option 2 is extremely undesirable as a result of the SQL that is actually executed...any ideas on what to do?