Question

I have a class & I am using createCriteria to fetch the record.

DomainClass.createCriteria().list(max: max, offset: offset) {
...
        ilike("field", value.encodeAsHTML() << "%") 
        ilike("field", value << "%") 
}

So it should fetch records matching for both

Was it helpful?

Solution

Mutliple ilikes work just fine in a criteria. However, based on your comments it sounds like you are looking for an OR instead of an AND and you can do so like this:

DomainClass.createCriteria().list(max: max, offset: offset) {
...
    or {
        ilike("field", value.encodeAsHTML() << "%") 
        ilike("field", value << "%") 
    }
}

OTHER TIPS

Got it ...

or {
      ilike("field", value.encodeAsHTML() << "%") 
      ilike("field", value << "%") "%")
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top