Spring注解配置事务管理——问题,spring注解配置事务
在上下文中配置:
<!-- 配置注解驱动的Spring MVC控制器编程模型。 --> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:annotation-driven transaction-manager="transactionManager" />
注意:
1.如果配置完成报错——
java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()....解决方案——
You're using Spring 3.2.5, and it's not compatible with the latest Hibernate 4.3.3 version that you're using. Hibernate 4.3 indeed decided to change the package of the
ConnectionProvider returned
by SessionFactoryImplementor.getConnectionProvider().
Use the latest Spring version, or use Hibernate 4.2, and it should run better.(
有道翻译一下:
你使用Spring
3.2.5,这不符合最新的Hibernate 4.3.3你使用的版本。Hibernate 4.3确实决定改变包的返回的ConnectionProvider SessionFactoryImplementor.getConnectionProvider()。使用最新的春季版本,或使用Hibernate
4.2,它应该更好的运行。
)
2.如果你的项目没有配置Spring事务管理,一般处理与数据库相关业务时报错误为——
org.hibernate.HibernateException: No Session found for current thread
3.报错——
org.hibernate.HibernateException: No Session found for current thread解决方案——
看看你是否在处理业务的类上加上了@Transactional注解
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。