1
是否有可能做的HQL语句时访问的关系表?如何在Grails中执行executeQuery时访问关系表?
作为一个例子,我有3个表:帐户,承诺,account_commitment。而且,利用这些领域中产生:
class Account {
static hasMany = [ commits : Commitment ]
String name
}
class Commitment {
static hasMany = [ actors : Account ]
String description
}
我最终和实际的SQL查询是这样的:
SELECT
b.id,
account_name,
d.nid,
d.title
FROM
account_commitment a, // is this available in HQL?
account b,
commitment c,
content_type_act d
where
d.nid = 3332
and a.account_id = b.id
and a.act_id = c.id
and c.act_id = d.nid
我相信HQL只允许有效的类域。由于关系表是自动生成的,这在HQL中可能吗?
谢谢。
是,它似乎很。我只是改变了架构,并能够有更好的查询。谢谢回复。 – firnnauriel 2010-04-23 17:23:08