OpenSession和GetCurrentSession的区别
来源:互联网 发布:中国网络战部队 编辑:程序博客网 时间:2024/05/17 09:20
1>性能区别:
OpenSession效率非常低,每次请求可能会执行多个功能,每个功能都是使用OpenSession,这样会反复的连接数据库,效率低
getCurrentSession首先从当前线程中查询是否有可用的session,如果有直接拿来使用,如果没有,新打开一个,并把他放入当前线程中
2>事务对其影响的差别:
getCurrentSession如果有事务,并且事务提交,则session关闭.
OpenSession事务是否关闭对其没有影响
3>怎样利用getCurrentSession解决OpenSession的问题:
可以将第一次生产的session(getCurrentSession)放入到当前线程中,以方便后期使用.
直接在 hibernate.cfg.xml配置
<!-- 配置getCurrentSession 可以获取当前线程-->
<property name="current_session_context_class">thread</property>
<property name="current_session_context_class">thread</property>
阅读全文
0 0
- openSession 和getCurrentSession的区别
- getCurrentSession()和openSession()的区别
- getCurrentSession 和 openSession的区别
- openSession 和getCurrentSession的区别
- OpenSession和GetCurrentSession的区别
- openSession 和getCurrentSession的区别
- openSession和getCurrentSession区别
- opensession 和getcurrentsession区别
- openSession和getCurrentSession区别
- opensession和getCurrentSession区别
- openSession和getCurrentSession区别
- OpenSession()和getCurrentSession的联系和区别
- hibernate 的openSession和getCurrentSession的区别
- Hibernate openSession() 和 getCurrentSession的区别
- hibernat中getCurrentSession 和openSession的区别
- Hibernate openSession() 和 getCurrentSession的区别
- Hibernate中openSession 和 getCurrentSession 的区别
- openSession和getCurrentSession的区别 thred jta
- Maven命令
- P3741 honoka的键盘
- hdu1056 堆积木
- 线性秘密共享方案(LSSS)构造与解密
- 中兴笔试---拉姆学单词
- OpenSession和GetCurrentSession的区别
- 数学建模--粒子群算法模版
- CCF201403-2窗口
- JS中各种this指向问题
- BZOJ 3555 [Ctsc2014]企鹅QQ
- P1321 单词覆盖还原
- buildAsset分析(一)——AssetUnit
- 翻转数组(判断递增递减问题)
- Java 编译后的class文件覆盖注意要点