欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

hibernate exception (cannot simultaneously fetch multiple bags)

程序员文章站 2022-03-02 15:36:31
...

 

 

 

org.hibernate.loader.MultipleBagFetchException: 
cannot simultaneously fetch multiple bags at org.hibernate.loader.BasicLoader.postInstantiate(BasicLoader.java:94) 
at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:119) 
at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:71) 
at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:54) 
at org.hibernate.loader.entity.BatchingEntityLoader.createBatchingEntityLoader(BatchingEntityLoader.java:133) 
at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:1914) 
at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:1937) 
at org.hibernate.persister.entity.AbstractEntityPersister.createLoaders(AbstractEntityPersister.java:3205) 
at org.hibernate.persister.entity.AbstractEntityPersister.postInstantiate(AbstractEntityPersister.java:3191) 
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:348) 
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872) 
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906) 
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57) 
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)

 

解决:

改变FetchMode为@Fetch(FetchMode.SUBSELECT),即发送另外一条select语句抓取前面查询到的所有实体对象的关联实体

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

捐助开发者 

在兴趣的驱动下,写一个免费的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(支持支付宝和微信 以及扣扣群),没钱捧个人场,谢谢各位。

 

个人主页http://knight-black-bob.iteye.com/


hibernate exception (cannot simultaneously fetch multiple bags)hibernate exception (cannot simultaneously fetch multiple bags)hibernate exception (cannot simultaneously fetch multiple bags)
 
 
 谢谢您的赞助,我会做的更好!

相关标签: hibernate exception