grails - Grails在域类中使用findAll

标签 grails gorm

我可以从该域类中调用该域类上的findAll吗?

class MyClass {

    Parents parent
    ///...

    def onLoad(){     
        MyClass.findAll('from MyClass where parent:=parent',[parent:parent]);
    }
} 

当我尝试时,我得到一个没有签名的方法findAll可用于MyClass错误。

最佳答案

我认为您的问题不是从域类中调用findAll

您似乎遇到了一些语法问题...

您可能想要的是:

MyClass.findAll('from MyClass m where m.parent=:parent', [parent:parent])

findAll documentation

要么
MyClass.findAllByParent(parent)

findAllBy documentation

关于grails - Grails在域类中使用findAll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30247015/

相关文章:

grails - Grails的事务性后台作业

java - Grails域类字符串列表不存在

grails - 在GORM中按周/月/年分组

grails - 显示登录成功消息弹出窗口

grails - 如何外部化Grails数据配置

没有 session 的Grails

grails - 实体未保存

grails - 使用Realm + RABBIT MQ进行Groovy Httpbuilder身份验证

grails - 如何增加每页的默认行数?

grails - 能否从域中的belongsTo访问值?