开发者

GORM: ilke and inList combination

In Grai开发者_StackOverflowls, with DynamicFinder how can we execute a query using ilike along with inList? Or can we use CriteriaBuilder to combine ilike and inList? Thank you!


why do you want do combine ilike and inList? InList is a constraint and defined as follows http://www.grails.org/doc/latest/ref/Constraints/inList.html. So your attribte with this constraint can only hold data defined in this list. e.g.

name(inList:["Frey", "Fred", "Flip"] )

Test.createCriteria.list {
    like("name","F%")
}


Build query on the fly:

def filter = ['a', 'bb', 'c']

def res = DomainClass.withCriteria {
  or {
    filter.each { 
      ilike('property', "%$it%")
    }
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜