Passing Enum List to Criteria

前端 未结 2 1101
一个人的身影
一个人的身影 2021-01-14 10:05

I have a domain Payment

class Payment {
  String name
  PaymentType paymentType
}

PaymentType is an ENUM

to search

相关标签:
2条回答
  • 2021-01-14 10:41

    @ataylor:

    I am not really sure.. but shouldnt it be

    def results = Payment.createCriteria().list { 'in' ('paymentType',new params.paymentType.collect{PaymentType.valueOf(it)}) }

    or you'll be getting an error

    groovy.lang.MissingPropertyException: No such property: params for class: grails.orm.HibernateCriteriaBuilder

    0 讨论(0)
  • 2021-01-14 10:49

    If paymentType is an array, you can do something like this:

    def results = Payment.createCriteria().list {
       'in' ('paymentType', params.paymentType.collect{PaymentType.valueOf(it)})
    }
    
    0 讨论(0)
提交回复
热议问题