문제

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

도움이 되었습니까?

해결책

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

다른 팁

Got it ...

or {
      ilike("field", value.encodeAsHTML() << "%") 
      ilike("field", value << "%") "%")
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top