我有典型的 Spring Security 域类布局(Person、Authority 和连接表 PersonAuthority)。我进行了以下查询,但我不知道如何建立正确的标准来获取只有特定权限的人(最后一个“if”块)。
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;
}
对于这个查询,我得到org.hibernate.QueryException: could not resolve property: authority