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

Était-ce utile?

La 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 << "%") 
    }
}

Autres conseils

Got it ...

or {
      ilike("field", value.encodeAsHTML() << "%") 
      ilike("field", value << "%") "%")
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top