inner/outer join in hibernate

本文探讨了Hibernate 3.0对外连接的支持情况,指出其仅支持theta-style风格的外连接,并不支持ANSI-style风格。文章通过具体的SQL示例说明了在尝试使用不支持的ANSI-style外连接时Hibernate抛出的异常,并给出了符合Hibernate 3.0规范的正确写法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值