【发布时间】:2012-06-20 04:22:15
【问题描述】:
我有这样的关系
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 的实例。 我想获取与我拥有的Thing 实例相关联的所有Foo 实例相关联的Bar 实例。
我已经多次使用 Grails executeQuery 方法,但我的查询不起作用。
这是一个有效的查询,它将获取与Bar 实例相关的所有Foo 实例。我希望我需要的查询看起来非常相似,我只是遇到了 HQL 连接问题。
SELECT DISTINCT f FROM Foo f INNER JOIN f.bars bars WHERE bars =:bars
【问题讨论】: