单例模式的SessionFactory与getCurrentSession()的使用

getCurrentSession()得到的session的好处。 (1)currentSession和当前线程绑定。 (2)currentSession在事务提交后自动关闭。java 须要在 hibernate.cfg.xml 中添加的配置web <property name="hibernate.current_session_context_class">thread</property>
相关文章
相关标签/搜索