inner/outer join in hibernate

本文深入分析了Hibernate 3.0版本对外连接的支持情况,特别是针对theta-style和ANSI-style外连接的区别。通过具体实例展示了如何在当前环境下正确使用外连接,并解释了在尝试使用标准的ANSI-style外连接时遇到的异常及其原因。最后,提供了转换为支持的写法的解决方案。

摘要生成于 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

智能体格

你的鼓将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值