zoukankan      html  css  js  c++  java
  • session详解

    获的session对象的方式:

      1.openSession

      2.getCurrentSession

    如果使用getCurrentSession需要在hibernate.cfg.xml文件中进行配置:

      如果是本地事务(jdbc事务):<property name="hibernate.current_session_context_class">thread</property>

      如果是全局事务(jta事务):<property name="hibernate.current_session_context_class">jta</property>

    openSession与getCurrentSession的区别

      1.getCurrentSession在事务提交或者回滚之后会自动关闭,而openSession需要手动关闭。如果使用openSession而没有手动关闭,多次之后会导致连接池溢出。(getCurrentSession每次获得session是一样的,openSession获得的是不同的)

      

  • 相关阅读:
    服务器常用端口
    xml处理类
    水印的代码
    Asp.net常用的51个代码(非常实用)
    poj 2453
    MOD
    LIS(最长上升子序列)
    POJ各题算法分类(转)
    poj 1496&1850
    poj 1423
  • 原文地址:https://www.cnblogs.com/jasonlixuetao/p/5928380.html
Copyright © 2011-2022 走看看