I'm trying to use the elements() function in HQL to get an instance that has exactly the same collection elements from a DB.
This works fine:
Code:
SELECT person FROM Person person
WHERE
EXISTS (
SELECT kitten FROM Kitten kitten
WHERE
kitten.name in ('Moses', 'Shrek')
AND
kitten = all elements(person.cats.kittens)
)
But if there's another collection in the path it doesn't:
Code:
SELECT person FROM Person person
WHERE
EXISTS (
SELECT yarnBall FROM YarnBall yarnBall
WHERE
yarnBall.color in ('Green', 'Red')
AND
yarnBall = all elements(person.cats.kittens.yarnBalls)
)
I thought maybe i need to do something like:
Code:
yarnBall = all elements(elements(person.cats.kittens).yarnBalls)
But that doesn't work (get an exception about an illegal '.')
Is there any way to do this?
Hibernate version: 3.1