传递枚举清单标准
问题描述:
我有一个域付款传递枚举清单标准
class Payment {
String name
PaymentType paymentType
}
PaymentType是一个ENUM
来搜索特定的支付类型的所有款项简单
def results = Payment.createCriteria.list = {
'in' ('paymentType', PaymentType.valueOf(params.paymentType))
}
怎么能我处理这种情况时,我想要搜索所有支付对多个支付类型,即如果params.paymentType是一个数组?
答
如果paymentType是一个数组,你可以这样做:
def results = Payment.createCriteria().list {
'in' ('paymentType', params.paymentType.collect{PaymentType.valueOf(it)})
}
答
@ataylor:
我真的不知道..但不应该说,它是
def results = Payment.createCriteria().list { 'in' ('paymentType',new params.paymentType.collect{PaymentType.valueOf(it)}) }
或者你会得到一个错误
groovy.lang.MissingPropertyException: No such property: params for class: grails.orm.HibernateCriteriaBuilder
非常感谢ataylor的回复:) – 2010-11-25 12:07:50