0

In Grails, 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!

Đinh Hồng Châu
  • 5,300
  • 15
  • 53
  • 90

2 Answers2

0

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%")
}
hitty5
  • 1,653
  • 12
  • 25
0

Build query on the fly:

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

def res = DomainClass.withCriteria {
  or {
    filter.each { 
      ilike('property', "%$it%")
    }
  }
}
Victor Sergienko
  • 13,115
  • 3
  • 57
  • 91