Joined: Mon Apr 14, 2008 1:13 pm Posts: 11
|
This is undoubtedly something stupid on my part and I'm sure this must have been asked before but I can't find the answer... so here goes:
I have two entities, Person and Country. There is a many to one relationship from Person to Country (i.e. a person has a country).
I want to get a list of people sorted by the name of their country.
But with the following criteria I get org.hibernate.QueryException: could not resolve property: country.name
Criteria criteria = session.createCriteria(Person.class);
criteria.addOrder(Order.asc("country.name"));
criteria.list();
Country does indeed have a publicly accessible name property and if remove the addOrder line I can get the country name on objects returned in the list as expected (by calling person.getCountry().getName())
What am I missing?
|
|