`

六、CoreApi

 
阅读更多

1、SessionFactory的openSession和getCurrentSession

① openSession永远都是打开一个新的Session,而getCurrentSession在事务没提交之前永远都是从上下文中获取同一个Session。但事务提交后,就是获取一个新的Session。(上下文是通过<property name="current_session_context_class">thread</property>来指定的)

② openSession得到的session用完之后需要close,而getCurrentSession不需要,在事务提交之后自动close。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics