我有这个枚举:
enum CompanyType {
RESTAURANT('R'),
BAR('B'),
NIGHT_CLUB('N')
final String id
CompanyType(String id) {
this.id = id
}
public Boolean isRestaurant() {
this == RESTAURANT
}
public Boolean isBar() {
this == BAR
}
public Boolean isNightClub() {
this == NIGHT_CLUB
}
}
我有一个像这样的域名:
class Company {
String name
String description
CompanyType companyType
}
在我的控制器上,当我尝试按CompanyType列出过滤时,我这样做:
companyList = Company.findAll(params,{companyType.id == selectedCompanyType.id})
我收到此错误消息:
Class
groovy.lang.MissingMethodException
Message
No signature of method: grails.gorm.DetachedCriteria.companyType() is applicable for argument types: (com.memobile.where2go.CompanyController$_tt__index_closure9_closure15) values: [com.memobile.where2go.CompanyController$_tt__index_closure9_closure15@483c17c1]
如果我只放置companyType == selectedCompanyType,我会得到一个空列表......
答案 0 :(得分:0)
我会使用'where'查询:
def companyList = Company.where {
companyType == selectedCompanyType
}.list(params)