hibernate3.3.2学习笔记---getCurrentSession()与openSession()
2016-09-29 17:50
459 查看
每次openSession()都会新产生一个Session,用完后需要close(),已经用的很少了。
而getCurrentSession()会先看是否当前环境已经有Session,若有,直接拿过来用,若是没有,则重新生成一个,建议用这个方法。
<property name="current_session_context_class">thread</property> 设置Session的上下文, 这句表示在当前线程找Session,从数据库寻找它的事务。
有时还设置为 jta 从分布式建立Session,需要ApplicationServer的支持。
而getCurrentSession()会先看是否当前环境已经有Session,若有,直接拿过来用,若是没有,则重新生成一个,建议用这个方法。
<property name="current_session_context_class">thread</property> 设置Session的上下文, 这句表示在当前线程找Session,从数据库寻找它的事务。
有时还设置为 jta 从分布式建立Session,需要ApplicationServer的支持。
相关文章推荐
- 【JavaEE学习笔记】Hibernate_06_注解开发,getCurrentSession(),映射关系
- Hibernate框架学习(第三讲)---openSession 和getCurrentSession的区别
- getCurrentSession 与 openSession() 的区别及hibernate lazy加载异常
- (hibernate之一)Sessionfactory的getCurrentSession与openSession的区别
- Hibernate中的openSession(),getSession() 和 getCurrentSession() 的区别
- hibernate 的SessionFactory的getCurrentSession 与 openSession() 的区别
- Hibernate关于openSession和getCurrentSession的理解
- Hibernate 之getCurrentSession 与 openSession() 的区别
- hibernate 的SessionFactory的getCurrentSession 与 openSession() 的区别
- Hibernate getCurrentSession 与 openSession() 的区别
- hibernate中session的产生方式(openSession、getCurrentSession)
- Hibernate4之getCurrentSession和openSession
- hibernate的session判断-openSession和getCurrentSession
- Hibernate 之getCurrentSession 与 openSession() 的区别
- hibernate 的SessionFactory的getCurrentSession 与 openSession() 的区别
- hibernate 的openSession和getCurrentSession的区别
- Hibernate getCurrentSession 与 openSession() 的区别
- 【转】Spring与Hibernate集成中的session问题(getSession()、getCurrentSession()与openSession() )
- 【学习】opensession 与getCurrentsession的区别
- (hibernate之一)Sessionfactory的getCurrentSession与openSession的区别