Hibernate-openSession与getCurrentSession区别
来源:互联网 发布:sql语句高级查询 编辑:程序博客网 时间:2024/06/04 22:47
openSession 每次使用都是打开一个新的session,使用完需要调用close方法关闭session;如果使用openSession而没有手动关闭,多次之后会导致连接池溢出(Connection对象不会被释放)
getCurrentSession 是获取当前session对象,连续使用多次时,得到的session都是同一个对象,这就是与openSession的区别之一 ;
一般在实际开发中,往往使用getCurrentSession多,因为一般是处理同一个事务,所以在一般情况下比较少使用openSession;
使用getCurrentSession需要在配置文件中配置
如果是本地事务(jdbc事务)
<property name="hibernate.current_session_context_class">thread </property>
如果是全局事务 (jta事务)
<property name="hibernate.current_session_context_class">jta</property>
0 0
- Hibernate-openSession与getCurrentSession区别
- 【Hibernate】 - openSession与getCurrentSession区别
- Hibernate getCurrentSession 与 openSession() 的区别
- Hibernate 之getCurrentSession 与 openSession() 的区别
- hibernate openSession()与getCurrentSession()的区别
- Hibernate 之getCurrentSession 与 openSession() 的区别
- Hibernate getCurrentSession 与 openSession() 的区别
- hibernate之openSession()与getCurrentSession()的区别
- Hibernate 中getCurrentSession 与 openSession() 的区别
- Hibernate getCurrentSession 与 openSession() 的区别
- Rhyme/Hibernate getCurrentSession()与openSession()的区别
- hibernate openSession() 与 getCurrentSession()
- getCurrentSession()与openSession() 区别
- getCurrentSession与openSession区别
- getCurrentSession与openSession区别
- openSession与getCurrentSession区别
- openSession()与getCurrentSession()区别
- openSession()与getCurrentSession()区别
- _beginthreadx
- Activity Liftcycle
- ios开发系统自带推送(ios自学笔记)
- Leetcode|Median of Two Sorted Arrays
- this指针
- Hibernate-openSession与getCurrentSession区别
- 剑指offer-替换空格
- Makefile中常用的函数
- 使用ssh公钥密钥自动登陆linux服务器
- ReactJS学习笔记八:动画
- 黑马程序员——数组
- POJ 2785 4 Values whose Sum is 0(折半枚举)
- java SpringAOP拦截Controller,Service实现日志管理(自定义注解的方式)
- 【Effective C++ 读书笔记】条款03: 尽量使用 const