分析 org.hibernate.HibernateException: No Session found for current thread

/**
     *
     * 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,则
     *         ①必须配置事务 
     *         ②必须在配置事务属性时,包含所有的业务方法

     */

原文地址:https://www.cnblogs.com/qq-757617012/p/4295734.html