I want to use the DetachedCriteria's list method with a domain with nested properties and order by one of the attributes in one of those properties.
I'm trying creating an alias criteria.createAlias("user", "user")
and then listing:
def userRoleList = criteria.list(max: params.length, offset: params.start,sort: sort, order: orderDir)
I have these classes:
class UserRole implements Serializable {
...
User user
Role role
...
}
class User implements Serializable {
..
String username
String password
boolean enabled
...
}
And I want to order by username or if it's enabled or not, but it keeps saying
org.hibernate.QueryException: could not resolve property: user.username of: ...model.security.UserRole
all the time, is there any way to do this properly?