Hibernate中的opensession与SessionFactory.getcurrentSession原理机制
来源:互联网 发布:程序员面试自我介绍 编辑:程序博客网 时间:2024/06/08 18:44
1 OpenSession : 手动打开,需手动关闭.[所以代码中充斥着try catch --sf.openSession --打开事务,提交-回滚 finall关闭session的代码]
以下为ThreadLocal的参考资料2 threadlocal : hibernate给出的提示. 在HibernateUtil工具类中,new出threadlocal ,放入opensession.这样可以使当前线程绑定session.
使用后需关闭session,将threadlocal中session变量置为null .
3 getCurrentSession: hibernate3的新特性. 无需手动关闭session,自动获取当前线程的session,若无则新建之. 需在配置文件中配置thread属性.表明和当前线程绑定.
参考网友资料,getCurrentSession模式,内部开启了session自动提交的功能且使用getCurrentSession的session,及时做load操作,也需要打开事务.
使用后需关闭session,将threadlocal中session变量置为null .
3 getCurrentSession: hibernate3的新特性. 无需手动关闭session,自动获取当前线程的session,若无则新建之. 需在配置文件中配置thread属性.表明和当前线程绑定.
参考网友资料,getCurrentSession模式,内部开启了session自动提交的功能且使用getCurrentSession的session,及时做load操作,也需要打开事务.
0 0
- Hibernate中的opensession与SessionFactory.getcurrentSession原理机制
- hibernate中的SessionFactory的openSession与getCurrentSession
- 【Hibernate】SessionFactory中的getCurrentSession()和openSession()的区别
- hibernate 的SessionFactory的getCurrentSession 与 openSession() 的区别
- (hibernate之一)Sessionfactory的getCurrentSession与openSession的区别
- hibernate 的SessionFactory的getCurrentSession 与 openSession() 的区别
- hibernate中SessionFactory.opensession()与getcurrentsession()的区别
- hibernate 的SessionFactory的getCurrentSession 与 openSession() 的区别
- hibernate 的SessionFactory的getCurrentSession 与 openSession() 的区别
- hibernate的SessionFactory的getCurrentSession 与 openSession() 的区别
- hibernate 的SessionFactory的getCurrentSession 与 openSession() 的区别
- hibernate openSession() 与 getCurrentSession()
- Hibernate SessionFactory openSession vs getCurrentSession vs openStatelessSession
- SessionFactory.getCurrentSession与openSession的区别
- SessionFactory.getCurrentSession与openSession的区别
- SessionFactory.getCurrentSession与openSession的区别
- SessionFactory.getCurrentSession与openSession的区别
- SessionFactory.getCurrentSession与openSession的区别
- 学习鸟哥的Linux私房菜笔记(7)——文件查找与文件管理1
- mysql数据库迁移到SQLServer2008(hibernate 配置)
- 新浪微博回调地址redirect_url(授权回调页)的设置格式
- lua笔记
- SQLite 学习 1
- Hibernate中的opensession与SessionFactory.getcurrentSession原理机制
- stdexcept 头文件中定义的标准异常类
- 巴斯卡三角形
- nologin user
- Windows平台下Python多版本安装总结
- Linux exec函数族分析
- JSP 图片转换
- Android学习之路一
- Openstack-G版单机