<!-- 开启线程安全的session配置 -->
1.hibernate.cfg.xml:
<property name="hibernate.current_session_context_class">thread</property>
2.java代码:
然后通过SessionFactory.getCurrentSession()获得
3.注意:
不再需要手动关闭session; 需要开启事务,包括查询。
<!-- 开启线程安全的session配置 -->
1.hibernate.cfg.xml:
<property name="hibernate.current_session_context_class">thread</property>
2.java代码:
然后通过SessionFactory.getCurrentSession()获得
3.注意:
不再需要手动关闭session; 需要开启事务,包括查询。