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 

相关文章:

  • 2021-06-17
  • 2021-10-25
  • 2021-08-10
  • 2022-12-23
  • 2021-07-05
  • 2022-12-23
  • 2021-05-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-23
  • 2021-06-09
  • 2021-10-10
  • 2022-02-26
  • 2022-12-23
相关资源
相似解决方案