现在的位置: 首页 > 综合 > 正文

inner/outer join in hibernate

2013年10月09日 ⁄ 综合 ⁄ 共 723字 ⁄ 字号 评论关闭

From:
inner/outer join in hibernate

hibernate目前(3.0) 只支持theta-style的外连接,标准的ANSI-style外连接暂不支持

ANSI-style的外连接是什么样子?

select template
from CoTemplate  template left outer join CoTempField field  on template=field.comp_id.coTemplate
where  field.comp_id.coField.fieldId=7//这里field用了复合主键

目前这种写法hibernate会跑出如下异常:

org.hibernate.QueryException: outer or full join must be followed by path expression....

会抛出如上异常的还包括inner join、right join

目前hibernate能够支持的写法如下

select template
from CoTemplate  template,CoTempField field
where template *= field.comp_id.coTemplate
and field.comp_id.coField.fieldId=7

//*=表示左联接、=*表示右连接
好像hibnernate3目前拒绝fix this bug

参考:http://opensource.atlassian.com/projects/hibernate/browse/HHH-190

http://www.jboss.com/index.html?module=bb&op=viewtopic&t=60864&view=next

抱歉!评论已关闭.