/**
*
* org.hibernate.HibernateException: No Session found for current thread
* 分析:getCurrentSession()和当前事务有关系
*
* Spring hibernate 事务的流程
*
* 1.在方法开始之前
* ①.获取Session
* ②.把Session 和当前线程绑定,这样就可以在Dao中 使用SessionFactory 的
* getCurrentSession() 方法来获取Session 了
* ③.开启事务
*
* 2.执行业务方法
* 1)出现异常
* ①.回滚事务
* 2)正常结束
* ①.提交事务
* finally{
* ②.和当前线程绑定的Session解除绑定
* ③.关闭Session
* }
*
* 结论:
* 只要使用getCurrentSession()来获取Session,则
* ①必须配置事务
* ②必须在配置事务属性时,包含所有的业务方法
*/
相关文章
- thread 属性">
thread 属性 - Spring报错——Scope 'session' is not active for the current thread
- spring+hibernate整合:报错org.hibernate.HibernateException: No Session found for current thread
- org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
- hibernate在使用getCurrentSession时提示no session found for current thread
- 关于spring3中No Session found for current thread!and Transaction的配置和管理(转)
- SSH框架新线程下执行数据库持久化时 No Session found for current thread
- struts2.3.16+spring4.0.6+hibernate4.3.5整合出现的No Session found for current thread
- org.hibernate.HibernateException: No Session found for current thread