zoukankan      html  css  js  c++  java
  • OpenSession与getCurrentSession的区别

    getCurrentSession 使用当前的Session

    OpenSession  创建一个行的Session

    1.getCurrentSession创建的Session会更当前线程绑定,而OpenSession不会。

    2.getCurrentSession创建的线程会在事物提交或回滚的时候自动关闭,而OpenSession必须得手动关闭。

    在Hibernagte中使用getCurrentSession中有这两种配法:

      1.(本地事物)对单个数据库进行操作,也就是只针对一个事物(jdbc事物)

       <property name="current_session_context_class">thread</property>

      如果没有会报异常:

      

      2.(全局事务)多个数据库之间进行操作,并且只能在一个事物中操作(jta事务)

      <property name="current_session_context_class">jta</property>

  • 相关阅读:
    C#泛型
    C#接口
    C#委托和事件
    Unity Ray 射线
    C#学习基础
    Graph | Eulerian path
    Careercup | Chapter 8
    Leetcode | Pow(x, n)
    Leetcode | Gray code
    分布式缓存
  • 原文地址:https://www.cnblogs.com/szj-ang/p/6629143.html
Copyright © 2011-2022 走看看