尝试从4.3.11升级到hibernate 5.2.9.目前使用的是hibernate native api.在pom.xml中添加依赖项后,运行单元测试时出现以下错误:
通过字段'sessionFactory'表示不满意的依赖; 嵌套异常是org.springframework.beans.factory.BeanCreationException:创建类路径资源[testApplicationContext.xml]中定义的名为'sessionFactory'的bean时出错:init方法的调用失败; 嵌套异常是org.hibernate.loader.MultipleBagFetchException:无法同时获取多个包
我有一个testApplicationContext.xml,其中包含以下内容:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="org.xxxx.xxxx.xxxx.model"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.use_sql_comments">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
Run Code Online (Sandbox Code Playgroud)
我将sessionFactory和transactionManager从hibernate4更新为hibernate5.
pom.xml:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.9.Final</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
据我所知,错误消息暗示加载多个急切加载的集合时出现问题.但是,我从知道这个,使用Hibernate的相关注释和休眠支持新版本的这种使用情况.
有人可以帮忙吗?谢谢
归档时间: |
|
查看次数: |
916 次 |
最近记录: |