hibernate关于session的关闭实例解析
|
本文研究的主要是hibernate关于session的关闭,具体如下。
Student student = new Student();
student.setName("Jan");
student.setAge("22");
student.setAddress("广东省肇庆市");
Session session =HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.save(student);
session.flush();
session.getTransaction().commit();
1、getCurrentSession()与openSession()的区别?
2、使用
在 SessionFactory 启动的时候, Hibernate 会根据配置创建相应的 CurrentSessionContext ,在 许多时候出现 <property name="hibernate.current_session_context_class">thread</property> 系统在 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
