码迷,mamicode.com
首页 > 其他好文 > 详细

SessionFactory的openSession与getCurrentSession区别

时间:2014-07-26 00:31:16      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:使用   os   strong   文件   数据   io   re   c   

SessionFactory

1 用来产生和管理sesssion

2 通常情况下,每个应用只需要一个SessionFactory,除非要访问多个数据库的情况

3 openSession()与openSession()

(1) openSession()总是创建新的session,需要手动close().

(2)getCurrentSession()事务提交则自动关闭.从上下文环境中获得session,如果当时环境中不存就创建新的.如果环境中存在就使用环境中的,而且每次得到的都是同一个session(在session提交之前,提交之后就是新的了).用途:界定事务边界.

所谓的上下文参见配置文件

<property name="current_session_context_classs">thread</property>

取值范围 jta | thread | managed | custom.Class 

SessionFactory的openSession与getCurrentSession区别,布布扣,bubuko.com

SessionFactory的openSession与getCurrentSession区别

标签:使用   os   strong   文件   数据   io   re   c   

原文地址:http://www.cnblogs.com/seven7seven/p/3868459.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!