I have typical Spring Security domain class layout (Person, Authority and join table PersonAuthority). I made following query, but I don't know how to build properly criteria for fetching persons that have only specific authorities (last 'if' block).
public static def query(Map params=[:]){
def criteria = Person.createCriteria();
def rows = criteria.list(max:params.max,offset:params.offset){
order(params.column?:"id",params.order?:"asc")
if(params.id){
idEq (params.id as Long);
}
if(params.username){
ilike "username","%"+params.username+"%"
}
if(params.email){
ilike "email","%"+params.email+"%"
}
if(params.accountLocked){
eq "accountLocked",Boolean.valueOf(params.accountLocked)
}
if(params.enabled){
eq "enabled",Boolean.valueOf(params.enabled)
}
if(params.passwordExpired){
eq "passwordExpired",Boolean.valueOf(params.passwordExpired)
}
if(params.authorities){
inList "authority",params.authorities;
}
}
return rows;
}
For this query I get org.hibernate.QueryException: could not resolve property: authority