openSession与getCurrentSession的区别
来源:互联网 发布:义乌小商品开淘宝 编辑:程序博客网 时间:2024/06/06 04:49
Hibernate有两种方式获得session,分别是:
openSession和getCurrentSession
他们的区别在于
1. 获取的是否是同一个session对象
openSession每次都会得到一个新的Session对象
getCurrentSession在同一个线程中,每次都是获取相同的Session对象,但是在不同的线程中获取的是不同的Session对象
2. 事务提交的必要性
openSession只有在增加,删除,修改的时候需要事务,查询时不需要的
getCurrentSession是所有操作都必须放在事务中进行,并且提交事务后,session就自动关闭,不能够再进行关闭
阅读全文
0 0
- getCurrentSession 与 openSession() 的区别 getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession()与openSession()的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- openSession与getCurrentSession的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别 .
- getCurrentSession 与 openSession() 的区别
- openSession与getCurrentSession的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession与openSession的区别
- getCurrentSession()与openSession()的区别
- java.io.Serializable浅析
- MySQL学习参考
- JDBC基础
- 获取在sessionStorage的JSON数据。和JSON数组的数据。
- 传递依赖的范围
- openSession与getCurrentSession的区别
- 【牛客网】合唱团
- 结合SpringDataJPA中的PagingAndSortingRepository和 JpaSpecificationExecutor接口实现大数据量的数据分页查询
- 矩阵面积
- 云技术的应用让移动游戏大放异彩
- Html学习笔记2:基本格式、标签、超链接
- Spring boot—logback日志构建
- Chapter 8 基于实例的学习
- ShortestUnsortedContinuousSubarray