0
votes

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

1
I didn't understand what your problem was - injecteer
The issue is that I get a result with all cases. As no criteria have been applied. - BioBier
what if you leave only 1 ilike in your criteria? would it work? - injecteer
well partly. It gives cases that have at least one actions with that status. Is it possibl eto get cases that only have actions with this status? (All other cases are not complete) - BioBier
give some examples, otherwise I can only speculate - injecteer

1 Answers

1
votes

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.