hibernate - 尝试在域中查找空值时,grails方法缺少异常

标签 hibernate grails gorm

根据grails doc(位于http://grails.github.io/grails-doc/latest/guide/GORM.html#finders)

Category.findAllByParentCategoryIsNull()

是查找ParentCategory为null的类别的正确方法。

这是我的类别域名类(class)
class Category {

    String name
    Category parentCategory

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

由于某种原因,我遇到了一个缺少方法的异常
Caused by MissingMethodException: No signature of method: static groovy.lang.Category.findAllByParentCategoryIsNull() is applicable for argument types: () values: []

最佳答案

引用groovy.lang.Category而不是Category域类,该类将在其他程序包中。

纠正使用Catergory的类中的程序包将解决此问题。

关于hibernate - 尝试在域中查找空值时,grails方法缺少异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28255232/

相关文章:

mysql - Hibernate 条件示例查询获取多条记录

hibernate - 如何解决 "Unable to resolve attribute [organizationType.id] against path"异常?

Grails i18n 来自数据库但默认返回文件

grails - 在不删除现有表的情况下更改Grails GORM格式

grails - Grails GORM按CASE语句排序

sql - JPA @ElementCollection 生成奇怪的唯一键

Plat Framework 1.2.7 升级到 1.5.2 后出现 MySQLIntegrityConstraintViolationException

oracle - Grails何时向对象分配ID?

Grails 3.1 无法添加库

ajax - Grails 通过向对象的键添加方括号 [] 来错误地解释发布的 JSON 数据