openSession和getCurrentSession的比较
来源:互联网 发布:速达软件数据库密码 编辑:程序博客网 时间:2024/04/30 12:04
http://blog.sina.com.cn/s/blog_6ac4c6cb010182zg.html
在比较openSession和getCurrentSession这两个方法之前,我们先认识一下这两个方法。
在进行配置信息管理时,我们一般进行一下简单步骤:
对于上述的两个方法,有以下区别:
注意 :在实际开发中,往往使用getCurrentSession多,因为一般是处理同一个事务(即是使用一个数据库的情况),所以在一般情况下比较少使用openSession或者说openSession是比较老旧的一套接口了;
对于getCurrentSession 来说,有以下一些特点:
1.用途,界定事务边界
2.事务提交会自动close,不需要像openSession一样自己调用close方法关闭session
3.上下文配置(即在hibernate.cfg.xml)中,需要配置:
(需要注意,这里的current_session_context_class属性有几个属性值:jta
a).thread使用connection 单数据库连接管理事务
b).jta (java
下面是openSession 和 getCurrentSession 简单实例的区别 :
1.openSession方式 :
}
2.getCurrentSession方式 :
}
Student 类代码 :
package com.hibernate.model;
public class Student {
}
- openSession和getCurrentSession的比较
- openSession和getCurrentSession的比较
- openSession和getCurrentSession的比较
- openSession和getCurrentSession的比较
- openSession和getCurrentSession的比较
- openSession和getCurrentSession的比较
- openSession和getCurrentSession 比较
- 比较openSession和getCurrentSession
- java openSession和getCurrentSession的比较
- openSession 和getCurrentSession的区别
- opensession()和getcurrentsession()的联系
- getCurrentSession()和openSession()的区别
- getCurrentSession 和 openSession的区别
- openSession 和getCurrentSession的区别
- OpenSession和GetCurrentSession的区别
- openSession 和getCurrentSession的区别
- 9.Hibernate OpenSession&getCurrentSession的比较
- OpenSession()和getCurrentSession的联系和区别
- Android测试详解_1-Best Practices for Testing-介绍
- 正则表达式(适用于oracle及linux)
- 零基础myeclipse下springBoot+maven+thymeleaf的开发(1)
- 哈希表及哈希表查找相关概念
- 关于Xutils网络请求重试的问题
- openSession和getCurrentSession的比较
- scanf的注意点
- 实现简单输入支付密码的输入
- 第一个jdbc例子
- java实现敏感词过滤
- 对随机10个数求和(2)
- VC++ EDIT控件的SetLimitText()用法
- Vsync从HWC到APP的传递过程
- B 树、B+ 树、B* 树