xSlok
xSlok

Reputation: 599

Grails - Find by equal and different in the statement?

I'm triying to find all objects with a field equal something and another field not equal something, I tried this:

Aluno.withCriteria {
            eq("ra" == params.ra)
            ne("id" != params.id)
}

but i got this error:

No signature of method: beans.AlunoController.eq() is applicable for argument types: (java.lang.Boolean) values: [false]
Possible solutions: is(java.lang.Object), any(), grep(), raw(java.lang.Object), each(groovy.lang.Closure), use([Ljava.lang.Object;). Stacktrace follows:
Message: No signature of method: beans.AlunoController.eq() is applicable for argument types: (java.lang.Boolean) values: [false]
Possible solutions: is(java.lang.Object), any(), grep(), raw(java.lang.Object), each(groovy.lang.Closure), use([Ljava.lang.Object;)

any ideas?

thanks!

Upvotes: 1

Views: 250

Answers (1)

Jeff Scott Brown
Jeff Scott Brown

Reputation: 27245

If you want to use a criteria query, you can do this:

Aluno.withCriteria {
    eq 'ra', params.ra
    ne 'id', params.id
}

You could also do something like this:

Aluno.where {
    ra == params.ra
    id != params.id
}

Upvotes: 4

Related Questions