Hibernate query specified join fetching ...

本文探讨了Hibernate中使用左连接查询(join fetch)时遇到的具体错误及其解决方案。错误信息提示查询指定的左连接获取(join fetching),但被获取关联的所有者未出现在select列表中。文章提供了去除fetch选项后的效果说明。

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

写道
hql.append(" from DutyCallover t left join fetch t.duty where 1=1 ");

 

 

Hibernate报错:

query specified join fetching, but the owner of the fetched association was not present in the select list

 

参考:
http://www.hibernate.org/250.html?cmd=prntdoc

 

写道
Furthermore, a query that specifies join fetching, but the owner of the fetched association was not present in the select list throws an exception now: "select b from A join fetch a.bees b" - this query makes no sense, remove the "fetch".

 

去掉fetch就可以,但是返回的每个Page.resultList对象是二维数组,index为0是目标对象DutyCallover,index为1是它的关联对象DutyInfo.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值