Search code examples
grailsgrails-orm

GORM querying: findAllByPropertyNotInList or findByPropertyNotInList do not exist, any equivalency?


The next code works:

self query1 = DomainClassExample.findAllByPropertyInList("hi","bye")

But if I add Not, the dynamic finder does not exist (it DOES exists: check the answer):

self query2 = DomainClassExample.findAllByPropertyNotInList("hi","bye")

I want to get all the DomainClassExample which don't have the property "hi" or "bye". Is there any dynamic finder for that purpose? Should I use the Where Query. How?


Solution

  • In Grails 1.3.9, given the following domain:

    class User {
        String username
        ....
    }
    

    this works in our application without any issues:

    def userList = User.findAllByUsernameNotInList(["user1@testdomain.com","user2@anotherdomain.com"])