Grails:如何对嵌入式对象使用executeQuery
我有一个嵌入子对象的对象:Grails:如何对嵌入式对象使用executeQuery,grails,hql,Grails,Hql,我有一个嵌入子对象的对象: class Parent { Child child static embedded ['child'] } class Child { String name } 我想使用executeQuery(因为在我的实际情况中,我不能使用Where查询或create条件)。如何在不切换到标准的情况下做到这一点?试试: Parent.executeQuery("FROM Parent parent WHERE parent.child.name
class Parent {
Child child
static embedded ['child']
}
class Child {
String name
}
我想使用executeQuery(因为在我的实际情况中,我不能使用Where查询或create条件)。如何在不切换到标准的情况下做到这一点?试试:
Parent.executeQuery("FROM Parent parent WHERE parent.child.name = 'FOO'")
编辑:
刚刚注意到,您需要为嵌入式对象添加一个静态声明:
static embedded ['child']
也许这样就可以了……是的,这是我原来的帖子中的一个错误,我会改正的