Hi,
while porting our application from JDO to Hibernate, we're wondering whether the Criteria api would be powerful enough to allow generic querying involving objects not navigable from the root class (the HQL api can do this and we'll stick with it if it's the only way).
For instance : If we have a class Cats and another, called Paternity, with a collection of Cats as "children" and a Cats instance as "parent" to represent who is the parent of kittens (The model is a legacy from the old developments so we have to stick with it).
If I'm looking for all Cats whose the grand parent is named 'kitty', we could write it in HQL (or so we think) as :
Code:
select catChild
from Cats catChild, Paternity paternity1, Paternity paternity2
where paternity1.parent.name = 'kitty'
and paternity1.children.contains(paternity2.parent)
and paternity2.children.contains(catChild)
When trying with the Criteria api, no matter which root class we're trying with, there is something which isn't navigable FROM the root class (but which is navigable TO). It looks like we can't introduce extra class in the from clause and should stick with only one there. Is it true or does the Criteria api allow to do this kind of request and if so, how ?
Thanks in advance
Olivier