我有这样的关系
class Foo {
static hasMany = [bars: Bar, things: Thing]
}
class Bar {
// Has nothing to tie it back to Foo or anything else of importance
}
class Thing {
// Has nothing to tie it back to Foo or anything else of importance
}
我有一个实例Thing
。 我想获得的所有实例Bar
是与所有实例相关联Foo
了与实例相关联的Thing
,我有。
我使用的Grails executeQuery
方法几次,但我的查询不起作用。
这是一个工作查询,将得到的所有实例Foo
有关的实例Bar
。 我希望我所需要的查询将看起来非常相似,我只是有麻烦与HQL连接。
SELECT DISTINCT f FROM Foo f INNER JOIN f.bars bars WHERE bars =:bars