2
我有这样HQL加入Grails中
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
真棒,谢谢你啊!我想通了像我张贴后吧:)不幸的是,我现在与另一关系结构类似的问题。小心看一下? http://stackoverflow.com/questions/11113527/hql-joins-in-grails-part-deux – ubiquibacon