Spring annotation configuration Transaction Management-problems, spring annotation configuration transactions
Configure in the context:
<! -- Configure the annotation-driven Spring MVC controller programming model. --> <Bean id = "transactionManager" class = "org. springframework. orm. hibernate4.HibernateTransactionManager "> <property name =" sessionFactory "ref =" sessionFactory "/> </bean> <tx: annotation-driven transaction-manager =" transactionManager "/>
Note:
1. If the configuration is complete, an error is returned --
java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()....
Solution --
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
ConnectionProvider
Returned
SessionFactoryImplementor.getConnectionProvider()
. Use the latest Spring version, or use Hibernate 4.2, and it shocould run better.
(
For example:
You use Spring 3.2.5, which is not in line with the latest Hibernate 4.3.3 version. Hibernate 4.3 does decide to change the ConnectionProvider SessionFactoryImplementor. getConnectionProvider () returned by the package (). Use the latest spring version, or use Hibernate 4.2, it should be better run.
)
2. If Spring transaction management is not configured for your project, the error is --
org.hibernate.HibernateException: No Session found for current thread
3. Error --
org.hibernate.HibernateException: No Session found for current thread
Solution --
Check whether you have added the @ Transactional annotation to the class that processes the business.