djanca wrote:
thanx a lot, that helped in the case which i described.
But it doesn't work in the case of more deep references e.g. over one table.
Example:
Table Task and dependent table Participant and its dependent table UserRole.
And now i want to display all tasks also with the atribute roleName (column of the UserRole table) and sort by this attribute. Is it possible to do so with the same or similar technique? I was not sucessfull with that...
thanx for any hint
Ok, I guess I know what you wanna do, the following code does sort the result by the roleName attribtue you described above.
Code:
Criteria crit = session.getSession().createCriteria(Task.class).createAlias("participant","part").createAlias("part.userrole", "role");
crit.add(Restrictions.eq("",new Long(24))); // do your query...
cirt.addOrder(Order.asc("role.roleName"));
crit.list(); //or cirt.uniqueResult();
yours simon