Spring註解配置交易管理——問題,spring註解配置事務

來源:互聯網
上載者:User

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註解

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.