illegal attempt to dereference collection
来源:互联网 发布:hive元数据查看大小 编辑:程序博客网 时间:2024/05/17 04:08
首先说一句:是版本的问题!
在多对多或者多对一,从一中查找多中查询某些语句时容易出现
我写的hql为:
from Department as d where d.employees.name='Tom';
运行时出现异常:org.hibernate.QueryException: illegal attempt to dereference collection
是因为:在上面的HQL语句中,Department的关联实体employees是一个集合,而不直接是一个Employee实体。
在Hibernate3.2.2以前的版本,Hibernate会对关联实体自动使用隐式的inner join,
也就是说如下SQL语句不会有任何问题 :from Department as d where d.employees.name='Tom';
从Hibernate3.2.3以后,Hibernate改变了这种隐式的inner join的策略
对于如下这条语句:
from Department as d where d.employees.name='Tom';
如果employees是普通组件属性,或单个的关联实体,则Hibernate会自动生成隐式的inner join
如果myEvents是也一个集合,那么对不起!系统将会出现 org.hibernate.QueryException: illegal attempt to dereference collection异常。
据Hibernate官方说法:
这样可以让这使得隐含关联更具确定性(原文:This makes implicit joins more deterministic )。
推荐这样写:
from Department as d inner join fetch d.employees e where e.name='Tom';
- illegal attempt to dereference collection
- illegal attempt to dereference collection
- illegal attempt to dereference collection
- illegal attempt to dereference collection(转载的)
- org.hibernate.QueryException: illegal attempt to dereference collection
- org.hibernate.QueryException: illegal attempt to dereference collection 异常
- 解决org.hibernate.QueryException illegal attempt to dereference collection 异常错误
- 解决org.hibernate.QueryException illegal attempt to dereference collection 错误异常
- Exception in thread "main" org.hibernate.QueryException: illegal attempt to dereference collection
- Illegal attempt to associate a collection with two open session
- org.hibernate.HibernateException: Illegal attempt to associate a collection
- Illegal attempt to associate a collection with two open sessions
- Illegal attempt to associate a collection with two open sessions;
- Illegal attempt to associate a collection with two open sessions
- Illegal attempt to associate a collection with two open sessions.
- org.hibernate.HibernateException: Illegal attempt to associate a collection
- attempt to dereference a generic a pointer
- Hibernate 异常: Illegal attempt to associate a collection with two open sessions
- 基于js的网页计算器实现
- hdu 3783 ZOJ
- spring框架知识
- Core Animation研究系列 : CATransform3D
- 黑马程序员------2015.6.17java基础--异常--package---线程
- illegal attempt to dereference collection
- PDO query和execute区别
- tcpdump抓包并保存成cap文件
- BCG静态编译且支持中文
- 20150617-Python冒泡排序
- 完美的代价
- 在hibernate中如果一对多关联,并以多的一方的参数作为条件则必须使用
- [9] MQTT,mosquitto,Eclipse Paho---MQTT消息格式之SUBACK(消息订阅应答)消息分析
- 每天一个linux命令(48):watch命令