org.springframework.transaction.TransactionSystemException: Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: Transaction not successfully started
先看看SessionFactory.getCurrentSession与openSession的区别 开始用的: Session session = this.getHibernateTemplate().getSessionFactory().getCurrentSession(); 好多文章里都说只需在Spring配置<bean id="sessionFactory"...---><property name="hibernateProperties"> 中加入 <prop key="hibernate.current_session_context_class">thread</prop>就可以解决,试了没用. 修改后的: Session session = this.getHibernateTemplate().getSessionFactory().openSession(); Transaction tran=session.beginTransaction(); ...... finally 问题解决 |