So what would be the right way to efficiently fetch all associated object matching certain criteria?
...and actually this statement:
Quote:
I would insist that the query above should return Cat objects with all the kittens regardless of their weight as long as at least one kitten for the cat has body weight that exceeds 10
is wrong for the following query:
--
from Cat as cat
left join cat.kittens as kitten
WHERE kitten.bodyWeight > 10.0
--
We will get all cats that have kittens with kitten.bodyWeight > 10.0 and cat.kittens set will be loaded ONLY with kittens matching the criteria. The problem is that without clearing session cache it is impossible to do the following query:
--
from Cat as cat
left join cat.kittens as kitten
WHERE kitten.bodyWeight > 20.0
--
Andrei