Hello,
I have very simple question, but I couldn't find answer anywhere.
How can I order the result of Criteria query by the atribute of asociated entity?
For example if you want to order the result of Childs entities by the age of their Mother, where Mother is many-to-one asociated entity.
I succed when I did this by HQL: "from Child child order by child.mother.age asc";
But I need to work with Criteria object, so I need something like this:
Code:
DetachedCriteria crit = DetachedCriteria.forClass(Child.class);
crit.addOrder(Order.asc("mother.age"));
But this doesn't work, hibernate throws exception with the message, that attribute 'mother.age' of class Child is unknown.
Does anybody knows, if this kind of ordering is possible in Criteria queries?
Thanks in advance.