【发布时间】:2021-10-21 00:57:56
【问题描述】:
我正在尝试升级 spring 版本 (4.3) 和 hibernate 版本 (5.4),但出现“没有正在进行的事务”异常,我正在使用 HibernateTransactionManager,并且我尝试将 hibernate.transaction.coordinator_class 设置为“ jta'以及'jdbc'。我的配置如下
<bean id="MyTransactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="myAppSessionFactory"/>
</bean>
<bean id="myAppSessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean" lazy-init="true">
<property name="mappingLocations">
<list>
<value>classpath:/mappings/UserGroupMembershipPOJO.hbm.xml</value>
<value>classpath:/mappings/UserGroupPOJO.hbm.xml</value>
<value>classpath:/mappings/UserDetailsPOJO.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.use_outer_join">false</prop>
<prop key="hibernate.jdbc.fetch_size">5</prop>
<prop key="hibernate.jdbc.batch_size">0</prop>
<prop key="hibernate.transaction.coordinator_class">jta</prop>
</props>
</property>
<property name="dataSource">
<ref bean="myDataSource"/>
</property>
</bean>
【问题讨论】:
标签: spring hibernate transactions upgrade hibernate-5.x