zoukankan      html  css  js  c++  java
  • 分析 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,则
         *         ①必须配置事务 
         *         ②必须在配置事务属性时,包含所有的业务方法

         */

  • 相关阅读:
    待完成
    [NOI2006]神奇口袋
    [UVA 10529]Dumb Bones
    概率与期望习题总结
    [SHOI2012]随机树
    [luogu3412]仓鼠找sugar II
    [CF908D]New Year and Arbitrary Arrangement
    [清华集训]小 Y 和恐怖的奴隶主
    [SDOI2015]序列统计
    [luogu3600]随机数生成器
  • 原文地址:https://www.cnblogs.com/qq-757617012/p/4295734.html
Copyright © 2011-2022 走看看