Thanks abg1979,
I figured that out just before the weekend so didn't get a chance to post back. I appreciate the reply. Now I'm running into a problem with the sorting on these sub-criteria. I have something like the following:
Code:
DetachedCriteria criteria = DetachedCriteria.forClass (Company.class);
criteria.add (Restrictions.ilike ("name", m_searchValue));
DetachedCriteria addressCriteria = criteria.createCriteria ("address");
addressCriteria.addOrder (isAscending () ? Order.asc ("city") : Order.desc ("city"));
When I do the criteria.getExecutableCriteria(session).list() Hibernate throws an exception stating the following:
Code:
Caused by: org.hibernate.QueryException: could not resolve property: city of: Company
The "address" property of Company is a mapped class of type Address with a subproperty of city. But it looks like rather than trying to apply the ordering on the address property it's trying to find a city property in the Company class. Since that doesn't exist it throws the exception.
Any ideas? Is this a bug with DetachedCriteria?