Hibernate SessionFactory中openSession和getCurrentSession方法的区别
来源:互联网 发布:ps软件如何下载 编辑:程序博客网 时间:2024/05/17 03:11
1. 前者打开一个新的,后者当前有session的话,则是使用当前的session,没有的话则创建一个新的;
2. 如果使用前者获得一个session的话,需要手动关闭session,使用后者,当事务提交,session会自动关闭,如果再关闭session则会报如下异常:Session has already closed;
3. sf.getCurrentSession方法需要在hibernate.cfg.xml做如下配置:
<propertyname="current_session_context_class" >thread</property>
没有配置的话会报如下异常:org.hibernate.HibernateException:No CurrentSessionContext configured!
- Hibernate SessionFactory中openSession和getCurrentSession方法的区别
- Hibernate SessionFactory中openSession和getCurrentSession方法的区别
- sessionFactory().getCurrentSession()和sessionFactory().openSession的区别
- Hibernate里sessionFactory的openSession()和getCurrentSession()的区别
- hibernate中SessionFactory.opensession()与getcurrentsession()的区别
- 【Hibernate】SessionFactory中的getCurrentSession()和openSession()的区别
- hibernate中openSession()方法和getCurrentSession()方法的区别
- hibernate中关于SessionFactory对象中opensession()和getCurrentSession()的区别
- Hibernate中openSession 和 getCurrentSession 的区别
- Hibernate 中 openSession()和getCurrentSession() 的区别
- hibernate中 openSession和getCurrentSession的区别
- hibernate中opensession和getCurrentSession的区别
- sessionFactory.openSession()和sessionFactory.getCurrentSession()区别
- hibernate 的SessionFactory的getCurrentSession 与 openSession() 的区别
- hibernate 的SessionFactory的getCurrentSession 与 openSession() 的区别
- hibernate 的SessionFactory的getCurrentSession 与 openSession() 的区别
- hibernate 的SessionFactory的getCurrentSession 与 openSession() 的区别
- hibernate的SessionFactory的getCurrentSession 与 openSession() 的区别
- 宏的妙用(但不要滥用)
- 谈一谈网络编程学习经验
- VS2008LINK : fatal error LNK1000: Internal error during IncrBuildImage
- 组合数打印
- linux rhel6.2 解决 git 使用错误:fatal: Unable to find remote helper for 'https'
- Hibernate SessionFactory中openSession和getCurrentSession方法的区别
- C++ 类的成员初始化
- 编程之美--快速查找满足条件的两个数
- 自己写内存泄露检测库
- poj1157 LITTLE SHOP OF FLOWERS
- hdu 2845
- TCP/IP 第17章 TCP传输控制协议
- Hibernate Session中get()和load()方法的区别
- ZOJ Problem Set - 3655 Alice and Bob