I'm displaying lists of persisted objects in html grids in which the user can click on the columns to pick which property they want to order by.
This all works just fine until one of the columns displayed is a sub property on a child, then I can't seem to create the ordering and instead get Exceptions:
if I try to do:
Code:
criteria.addOrder(Order.asc("child.name"));
I get the Exception:
Code:
net.sf.hibernate.QueryException: could not resolve property: child.name of: package.Parent
at net.sf.hibernate.persister.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:99)
at net.sf.hibernate.expression.AbstractCriterion.getColumns(AbstractCriterion.java:69)
at net.sf.hibernate.expression.Order.toSqlString(Order.java:73)
at net.sf.hibernate.loader.CriteriaLoader.<init>(CriteriaLoader.java:149)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3430)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:353)
if I try to do (which I think is basically the same as above?):
Code:
criteria = criteria.createAlias("child", "kid");
criteria.addOrder(Order.asc("kid.name"));
I get the Exception:
Code:
net.sf.hibernate.QueryException: could not resolve property: kid.name of: package.Parent
at net.sf.hibernate.persister.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:99)
at net.sf.hibernate.expression.AbstractCriterion.getColumns(AbstractCriterion.java:69)
at net.sf.hibernate.expression.Order.toSqlString(Order.java:73)
at net.sf.hibernate.loader.CriteriaLoader.<init>(CriteriaLoader.java:149)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3430)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:353)
if I try to do:
Code:
criteria = criteria.createCriteria("child");
criteria.addOrder(Order.asc("name"));
I get the Exception:
Code:
java.lang.UnsupportedOperationException: subcriteria cannot be ordered
at net.sf.hibernate.impl.CriteriaImpl$Subcriteria.addOrder(CriteriaImpl.java:139)
Is there a way to do this and I'm just not doing it correctly or is this simply not supported no matter what?
I'm using the latest v21branch from CVS as of this posting.
Any help would be greatly appreciated.
Thank-you.
P.S. I can order by sub properties of components, just not children.