首页 > 编程语言 > 详细

Spring注解配置事务管理——问题

时间:2015-04-11 11:48:03      阅读:304      评论:0      收藏:0      [点我收藏+]

在上下文中配置:

<!-- 配置注解驱动的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注解

Spring注解配置事务管理——问题

原文:http://blog.csdn.net/u013474104/article/details/44993231

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!