<1> getCurrentSession建立的session会和绑定到当前线程,而openSession(从新创建一个新的session )不会。
<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 session