Caused by: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags
有3个对象,对象A,对象B,对象C。他们的实体关系为:
1、A中存在List<B>和List<C>,即一个包含另外两个;
2、A中存在List<B>,B中存在List<C>,即传递关系;
存在上面2种情况,并且fetch=eager就会报上面的异常。解决办法:
方式1、将List改成Set;
方式2、将fetch改成lazy方式;
方式3、利用Hibernate注解:@IndexColumn
方式4、利用JPA的注解:@OrderColumn
上面方式3和4原理都一样,而方式3是Hibernate专用的,建议用方式4。
3、利用上面方式3或者4获取到的结果,比如A与B为1对多关系,而B在数据库中有3条符合条件的记录,但是查询出结果A中的List<B>有4个元素,
第一个为null,没搞明白是为什么。
4、一般而言,没有特别的需求,都用Set就好了。
5、我这里纠结是因为dubbo的默认rpc工具hessian的反序列化对Set的支持不友好。所以才有了这么个矛盾的关系。
Caused by: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags的更多相关文章
- cannot simultaneously fetch multiple bags
问题是什么时候出现的呢? 当一个实体对象中包含多于一个non-lazy获取策略时,比如@OneToMany,@ManyToMany或者@ElementCollection时,获取策略为(fetc ...
- Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFac
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springfram ...
- Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
docs.jboss.org文档示例代码:(http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/) sta ...
- SSH框架-Caused by: org.hibernate.MappingException: column attribute may not be used together with <column> subelement
昨晚修改了一些表关系,在相关的hbm.xml文件中做了改动,今天早上起来启动tomcat后,发现项目启动不了,控制台报错: 2015-6-14 9:09:42 org.apache.catalina. ...
- Caused by:org.hibernate.HibernateException:Unable to make JDBC Connection
1.错误描述 Caused by:org.hibernate.HibernateException:Unable to make JDBC Connection[jdbc\:mysql\://loca ...
- Caused by:org.hibernate.MappingNotFoundException:resouce:com/you/model/Monkey.hbm.xml not found
1.错误描述 Caused by:org.hibernate.MappingNotFoundException:resouce:com/you/model/Monkey.hbm.xml not fou ...
- Caused by:org.hibernate.DuplicateMappingException:Duplicate class/entity/ mapping
1.错误描述 java.lang.ExceptionInInitializerError Caused by:org.hibernate.InvalidMappingException:Could n ...
- SSH执行hql报错:Caused by: org.hibernate.hql.ast.QuerySyntaxException: user is not mapped [from user where username = ?]
报错信息: ERROR Dispatcher:38 - Exception occurred during processing request: user is not mapped [from u ...
- Caused by: org.hibernate.HibernateException: identifier of an instance of ... is alterde from
Caused by: org.hibernate.HibernateException: identifier of an instance of ... is alterde from Hi ...
随机推荐
- [LintCode] Roman to Integer 罗马数字转化成整数
Given a roman numeral, convert it to an integer. The answer is guaranteed to be within the range fro ...
- WIN8 MTK驱动不能安装解决办法
1.把鼠标移动到桌面最右下角的位置会出来一个侧边栏,按那个齿轮就是“设置”,会出来个菜单,选择最下边的“更多电脑设置” 注:也可以按快捷键“WIN+I” 2.选择“常规”→“高级启动”→”立即重启“ ...
- bzoj3991: [SDOI2015]寻宝游戏--DFS序+LCA+set动态维护
之前貌似在hdu还是poj上写过这道题. #include<stdio.h> #include<string.h> #include<algorithm> #inc ...
- oracle initialization or shutdown in progress问题解决步骤
今天像往常一样打开电脑,启动plsql工具连接数据库,但是尽然连接不了,报了“oracle initialization or shutdown in progress”的提示信息,从操作系统 ...
- 【iCore3 双核心板】例程二十九:SD_IAP_FPGA实验——更新升级FPGA
实验指导书及代码包下载: http://pan.baidu.com/s/1o7h158m iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...
- HDU 1264 Counting Squares(线段树求面积的并)
Counting Squares Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- JS判断终端设备跳转PC端、移动端相应的URL
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta nam ...
- RESTful简单介绍(入门)
1.1 什么是RESTful http://www.ruanyifeng.com/blog/2011/09/restful.html RESTful架构,就是目前最流行的一种互联网软件架构. ...
- MySQL常用问题解决方法
Q: # table 损坏 Table 'table_name' is marked as crashed and should be repaired A: 恢复数据表的索引:myisamchk - ...
- Java微信公众号开发
微信公众平台是腾讯为了让用户申请和管理微信公众账号而推出的一个web平台.微信公众账号的种类可以分为3种,并且一旦选定不可更改.按照功能的限制从小到大依次为:订阅号.服务号.企业号.个人只能注册订阅号 ...