【问题标题】:Grails: How to use executeQuery with embedded objectGrails:如何将 executeQuery 与嵌入对象一起使用
【发布时间】:2013-03-14 15:39:06
【问题描述】:

我有一个嵌入了子对象的对象:

class Parent {
    Child child

    static embedded  ['child']
}

class Child {
    String name
}

我想使用 executeQuery(因为在我的实际情况下,我不能使用 Where 查询或创建条件)。在不切换到标准的情况下如何做到这一点?

【问题讨论】:

    标签: grails hql


    【解决方案1】:

    试试:

    Parent.executeQuery("FROM Parent parent WHERE parent.child.name = 'FOO'")
    

    编辑:

    刚刚注意到,您需要为嵌入对象添加静态声明:

    static embedded  ['child']
    

    也许这样可以解决问题...

    【讨论】:

    • 是的,这是我原帖的错误,我会改正的
    猜你喜欢
    • 1970-01-01
    • 2015-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-11
    • 2021-03-13
    • 1970-01-01
    相关资源
    最近更新 更多