解决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 在这里有 ...
随机推荐
- [Selenium]Eclipse hangs at 57% in debug mode with TestNG tests
案例1: I am very thankful to saish and cbeust for the solution. I went through the similar issue with ...
- part1:13-linux编译器GCC
Gcc特点 Gcc基本用法 1.gcc的概念 GCC(GNU Compiler Collection,GNU编译器套装),是一款由GNU开发的编程语言编译器.GCC原名为GNU C 语言编译器,因为它 ...
- 2018.09.19 atcoder AtCoDeer and Election Report(贪心)
传送门 很有意思的一道贪心. 就是每次翻最小的倍数来满足条件. 代码: #include<bits/stdc++.h> #define ll long long using namespa ...
- 2018.08.29 NOIP模拟 table(拓扑排序+建图优化)
[描述] 给出一个表格,N 行 M 列,每个格子有一个整数,有些格子是空的.现在需要你 来做出一些调整,使得每行都是非降序的.这个调整只能是整列的移动. [输入] 第一行两个正整数 N 和 M. 接下 ...
- nginx集群tomcat,session共享问题
tomcat-redis-session-manager版本: apache-tomcat-8.0.32.nginx-1.13.12.redis_3.2.1 github地址: https://git ...
- hdu-1251(string+map)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1251 思路:重点是用gets输入,而且用a[20],不能直接输入string类型的. #include ...
- HDU 2504 又见GCD (最大公因数+暴力)
题意:是中文题. 析:a和c的最大公因数是b,也就是说,a和c除了b就没有公因数了.再说就是互质了. 所以先把a除以b,然后一个暴力n,满足gcd(a, n) =1,就结束,就是n倍的c. 代码如下: ...
- PrefixHeader.pch 在工程中的使用
1) 新建一个pch文件 2) 在 工程 Build Settings 中搜索 header 将Precompile Prefix Header 置为YES 2) 选中pch文件, 将右侧相对路径 ...
- (转)EF Power tool用法
转自:http://msdn.microsoft.com/zh-cn/data/jj593170.aspx 命令摘要 安装 EF Power Tools 后,将提供以下上下文菜单项.本演练将详细讨论这 ...
- hbase使用MapReduce操作3(实现将 fruit 表中的一部分数据,通过 MR 迁入到 fruit_mr 表中)
Runner类 实现将 fruit 表中的一部分数据,通过 MR 迁入到 fruit_mr 表中. package com.yjsj.hbase_mr; import org.apache.hadoo ...