Hibernate 4.3.5到4.0.1异常org.hibernate.loader.MultipleBagFetchException

时间:2015-06-25 10:08:22

标签: hibernate spring-mvc tomcat weblogic java-7

我正在努力将应用程序从Tomcat 8移动到Weblogic 10.3.6。我们正在使用的技术堆栈:

  1. Spring:4.1.5.RELEASE
  2. Hibernate:4.3.5
  3. 数据库:Postgres
  4. 在Tomcat 8应用程序运行良好,但是当我尝试在Weblogic 10.3.6上进行部署时,由于应用程序正在使用JPA 2.1,所有应用程序都开始失败。在Weblogic 10.3.6上,它默认支持JPA 1,并且有一个JPA 2的补丁。

    现在为了适应我们的应用程序,我试图通过将Hibernate 4.3.5降低到4.0.1来回到JPA 2.0。

    并删除" javax.persistence.Transactional"和" CriteriaDelete"来自代码。

    现在我正在尝试在Weblogic中部署代码,我得到了内存"我将修复后者。

    后来我尝试在Tomcat 8中部署代码,它抛出异常:

    Caused by: javax.persistence.PersistenceException: [PersistenceUnit: abc] Unable to build EntityManagerFactory
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
        at org.springframework.orm.jpa.vendor.SpringHibernateEjbPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateEjbPersistenceProvider.java:51)
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
        ... 21 more
    Caused by: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags
        at org.hibernate.loader.BasicLoader.postInstantiate(BasicLoader.java:93)
        at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:118)
        at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:70)
        at org.hibernate.loader.entity.EntityLoader.<init>(EntityLoader.java:53)
        at org.hibernate.loader.entity.BatchingEntityLoader.createBatchingEntityLoader(BatchingEntityLoader.java:131)
        at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:2323)
        at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:2346)
        at org.hibernate.persister.entity.AbstractEntityPersister.createLoaders(AbstractEntityPersister.java:3612)
        at org.hibernate.persister.entity.AbstractEntityPersister.postInstantiate(AbstractEntityPersister.java:3598)
        at org.hibernate.persister.entity.SingleTableEntityPersister.postInstantiate(SingleTableEntityPersister.java:1013)
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:422)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)
        at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
        ... 27 more
    

    请注意,在降级Hibernate之前,该应用程序运行良好。

1 个答案:

答案 0 :(得分:0)

我修好了。这主要是由于实体类中的多个fetchtype.Eager造成了问题。您可以在中找到有关修复的完整信息 “http://blog.eyallupu.com/2010/06/hibernate-exception-simultaneously.html