解决org.hibernate.QueryException illegal attempt to dereference collection 异常错误
今天做项目的时候,有两个实体:款式、品牌两者关系是多对多的关联关系,实现的功能是:通过选择款式,显示出该款式的所有品牌。HQL语句如下:
运行时出现这个异常错误:org.hibernate.QueryException: illegal attempt to dereference collection 。
通过查资料发现,在上面的HQL语句中,Brand的关联实体styles是一个Set集合,而不是一个Style实体。在 Hibernate3.2.2以前的版本,Hibernate会对关联实体自动使用隐式的inner join,也就是说使用上面的HQL语句是毫无问题的。
但是在Hibernate3.2.2版本以后,Hibernate改变了这种策略。它使用如下策略来关联实体。
同样对于上面的HQL语句。如果styles是一个单个的关联实体或者是一个普通的属性,那么hibernate就会自动使用隐式的inner join。但是如果styles 是一个集合,那么对不起,统将会出现 org.hibernate.QueryException: illegal attempt to dereference collection异常。 对于解决方案就是,要么你退回hibernate3.2.2版本以前,要么使用如下形式的HQL语句:
解决org.hibernate.QueryException illegal attempt to dereference collection 异常错误的更多相关文章
- 【Hibernate】Illegal attempt to associate a collection with two open sessions
今天在用Hibernate对对象进行修改操作的时候报了这个错. 之前一直没什么错误,但是今天修改了一下表结构,增加了一个OneToMany的映射. 所以在我获取对象,重新set一个变量之后就报了这个错 ...
- 解决xorm逆向mssql报datetime2不兼容的异常错误
xorm作为golang开发者的一大利器,深受大家的喜爱,可是最近在逆向mssql的时候,报了这么一个错误: 最后找了半天发现xorm没有预置DateTime2类型,经过几番折腾,在xorm源码的en ...
- 常见Hibernate报错处理:出现“org.hibernate.QueryException: could not resolve property”和 is not mapped和could not locate named parameter错误的解决
正确写法: @Override @SuppressWarnings("unchecked") public List<Device> queryOSDevice(Str ...
- weblogic 下异常 org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken
项目之前在 Tomcat 环境下一直都正常运行,今天应客户要求需要迁移到 webLogic 10.3.6 下, 部署后竟然抛出了 org.hibernate.QueryException: Class ...
- nested exception is org.hibernate.QueryException: could not resolve property
SSH框架出现了下面的错误: nested exception is org.hibernate.QueryException: could not resolve property 检查了hbm.x ...
- org.hibernate.QueryException: could not resolve property
org.hibernate.QueryException: could not resolve property HibernateSQLXML org.hibernate.QueryExcepti ...
- atitit. 解决org.hibernate.SessionException Session is closed
atitit. 解决org.hibernate.SessionException Session is closed #--现象:: org.hibernate.SessionException ...
- org.hibernate.QueryException: could not resolve property: address of:
Hibernate: select count(*) as y0_ from test.course this_ org.hibernate.QueryException: could not res ...
- 同时操作两个数据库:报错Illegal attempt to associate a collection with two open sessions
今天我在一个操作两个数据库的SSH里 同时插入1条数据 报错 Illegal attempt to associate a collection with two open sessions 在这里有 ...
随机推荐
- 匹配数字、字母和?%&=-_这几个符号的正则表达式
/^[\w\?%&=\-_]+$/ 说明:(1) \w 代表 0-9a-zA-Z 即数字.字母 (2) \?%&=\-_ 匹配?%&=-_,而正则中?代表0个或1个,因为是特殊 ...
- 用户体验要好,App动画得这么做
以下内容由Mockplus团队翻译整理,仅供学习交流,Mockplus是更快更简单的原型设计工具. 在用户体验设计方面,App动画的设计和添加,带给设计师无限的创造空间的同时,也成为设计师群体最具 ...
- 社交类APP原型模板分享——微信
微信是一款社交类的APP应用——聊天软件,支持多人群聊. 交互效果主要有滚动内容界面.选择组件触发按钮状态变化.点击下拉展开列表.点击弹出面板等交互操作. 本原型由国产原型工具-Mockplus制作完 ...
- @Id 和 @column 注解 使用注意
当@Id写字啊 field 上时 ,如过 把 @column 写在 getter 方法上 ,会出现错误 或者不起作用 Unknown column 'gecompanys0_.sourcec' in ...
- Alien::BatToExeConverter 模块应用
## DOS 下批量任务转换成exe二进制可执行文件 Convert a DOS Batch Script to an Executable Alien::BatToExeConverter::ba ...
- Mybatis传值为空需要配置JdbcType来解决吗?(XML文件不需要配置JdbcType)
1,解决思路,配置自定义的语言驱动,重写自己的Paramethander package cn.com.servyou.gxdqy.tool.xmlhelper; import org.apache. ...
- c++编程思想里面的错误(可能c++标准变了,所以以前的东西没有更新)
第一卷 第五章 5.3友元 下面的代码是<c++编程思想>里面的代码, struct X; struct Y{ void f(X*); }; struct X{ private: int ...
- nodejs的优点
nodejs主要用于搭建高性能的web服务器,优点如下: 可以解决高并发,它是单线程,当访问量很多时,将访问者分配到不同的内存中,不同的内存区做不同的事,以快速解决这个线程.就像医院的分科室看病人.效 ...
- hdu-1207(规律推导)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1207 思路: 可以按照类似汉诺塔的推导形式来推导, 首先,有四个柱子,a,b,c,d. (1)a的x个 ...
- 创建template模板
创建一个自己常用的快捷键的模板. 1.选择window-->preferrence--搜索temp--java 2.点击new 3.根据自己的习惯起一个名字 4.比如syso 5.语法不会,就找 ...