query specified join fetching, but the owner of the fetched association was not present in the selec
来源:互联网 发布:java easyui使用 编辑:程序博客网 时间:2024/05/24 05:53
错误日志信息:
'deliveryAddressDao': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=c,role=null,tableName=customer,tableAlias=customer1_,origin=delivery_address deliveryad0_,columns={deliveryad0_.customer_id ,className=com.friendcom.dongzuo.entity.Customer}}] [select count(c.customerId) from com.friendcom.dongzuo.entity.DeliveryAddress addr left join fetch addr.customer c where c.customerId=?1]
原因分析:
Hql 如下 :
@Query("select count(addr.deliveryAddressId) from DeliveryAddress addr left join fetch addr.customer c where c.customerId=?1") long findByCustomerIdforTotalSize(int customerId);
此处我希望加载DeliveryAddress下的customer,而我使用了fetch来立即抓取customer,错误就在这里.如果你使用fetch,那么fetch左边的连接对象(拥有者)一定要出现在select后,例如将上面改为select addr ... 这样就会执行正常,因为使用了fetch,Hibernate就会将需要fetch的对象(customer)立即加载在父对象(DeleveryAddress)中,而我的select确只是列出子对象,而拥有者(DelivieryAddress)并没有present(出席在结果集中),那么就会出现以上错误.
总结:
如果使用了fetch,那么拥有者一定要present,也就是对象一定要被加载出来
- query specified join fetching, but the owner of the fetched association was not present in the selec
- query specified join fetching, but the owner of the fetched association was not present in the selec
- query specified join fetching, but the owner of the fetched association was not present in the selec
- Hibernate异常:query specified join fetching, but the owner of the fetched association was not present
- org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the sel
- Hibernate异常:query specified join fetching, but the owner of the fetched association was not present in the select list
- hibernate异常Hibernate异常:query specified join fetching, but the owner of the fetched association was n
- 【解决Hiberate】 query specified join fetching, but the owner of the fetched association..
- org.hibernate.QueryException: query specified join fetching, but the owner of the fetched associatio
- The profile weblogic-maven-plugin specified is not present in the configuration as specified in null
- the message "\$CATALINA_PID was set but the specified file does not exist. Is Tomcat running? Stop
- C# The given key was not present in the dictionary.错误原因及解决办法。
- Unity打包报错the given key was not present in the dictionary
- pid.txt CATALINA_PID was set but the specified file does not exit
- $CATALINA_PID was set but the specified file does not exist. Is Tomcat running? Stop aborted.
- The specified datastore driver ("com.mysql.jdbc.Driver") was not found in the CLASSPATH
- loaded the "***" nib but the view outlet was not set
- loaded the nib but the view outlet was not set
- win7系统忘记开机密码怎么办?
- POJ 3281 Dining(最大流)
- 8-3. 组个最小数
- 找出两个链表的第一个公共节点
- ios中处理时间的类及方法详解
- query specified join fetching, but the owner of the fetched association was not present in the selec
- Javascript 学习 笔记一
- iOS运行出现No application was specified 和 IOS 模拟器未能安装此应用程序
- zoj 3675 状压dp
- 对功率谱的一点理解
- IOS APP 上传到AppStore
- 前台页面优化全攻略(一)
- Install Apache + PHP
- python面试集锦