<1> getCurrentSession创建的session会和绑定到当前线程,而openSession(重新建立一个新的session )不会。
<2> getCurrentSession创建的线程会在事务回滚或事物提交后自动关闭,而openSession必须手动关闭
<3> getCurrentSession设置本地事务时要,在hibernate.cfg.xml文件里进行如下设置:
<2> getCurrentSession创建的线程会在事务回滚或事物提交后自动关闭,而openSession必须手动关闭
<3> getCurrentSession设置本地事务时要,在hibernate.cfg.xml文件里进行如下设置:
<property name=“hibernate.current_session_context_class”>thread</property>
参考 :http://blog.csdn.net/loveyout/article/details/4193894
来源:oschina
链接:https://my.oschina.net/u/1989867/blog/542264