Search code examples
hibernategrailsgrails-orm

grails method missing exception when trying to find null value in domain


According to the grails doc (found at http://grails.github.io/grails-doc/latest/guide/GORM.html#finders)

Category.findAllByParentCategoryIsNull()

is the proper way to find a Category who's ParentCategory is null.

here's my category domain class

class Category {

    String name
    Category parentCategory

    static constraints = {
        name unique:true
        parentCategory nullable:true
    }
}

for some reason, I'm getting a method missing exception

Caused by MissingMethodException: No signature of method: static groovy.lang.Category.findAllByParentCategoryIsNull() is applicable for argument types: () values: []

Solution

  • groovy.lang.Category is referred instead of Category Domain class which would be in a different package.

    Rectifying the package in the class where Catergory is used would resolve this issue.