單例模式的SessionFactory與getCurrentSession()的使用

getCurrentSession()得到的session的好處。 (1)currentSession和當前線程綁定。 (2)currentSession在事務提交後自動關閉。java 須要在 hibernate.cfg.xml 中添加的配置web <property name="hibernate.current_session_context_class">thread</property>
相關文章
相關標籤/搜索