简体   繁体   中英

Grails - createCriteria: associations + not + ilike

some how a Criteria: associations + not + ilike does not give a good result. I still get cases with actions that have the status I don't want in the result. Any clue or suggestion for other approaches?

I have this in controller:

def pgp = [:]
pgp.max = params.max?.toInteger() ?: 20;
pgp.offset = params.offset?.toInteger() ?: 0
pgp.max = 20;
def result = Case.createCriteria().list(pgp) {
        actions {
            not {
                and {
                    ilike("status","%CLOSED")
                    ilike("status","%Installed in PRD")
                }
            }
        }
}

This is the relevant Domain snipped:

class Case {

String caseCode
String caseName
String caseType

static hasMany = [ actions : Action ]

I'm on Grails 2.4.4

Your Boolean logic is faulty - the and should be an or . Your current tests will be true for every possible value of status , as any value that passes ilike("status","%CLOSED") will fail ilike("status","%Installed in PRD") and vice versa.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM