getCurrentSession 与 openSession() 的区别
来源:互联网 发布:探索者软件 编辑:程序博客网 时间:2024/05/20 03:41
调用hibernate的session的问题getCurrentSession 与 openSession() 的区别
该项目设计为 一个 item 下有多个 question ,而一个question 下有多个 answer 。因此,需多次循环查询数据库。
测试时,数据库连接池的最大数及最小数都设为 1.
测试发现,为getHibernateTemplate().getSessionFactory().openSession()时,web 页面无法正常显示(白板),此时别的业务逻辑如果需要连接数据库则都不能执行;查询 log4j 日志发现,没有打印出openSession()所在方法的sql。 后来改为 getHibernateTemplate().getSessionFactory().getCurrentSession()则web 页面显示正常。
getCurrentSession () 使用当前的session
openSession() 重新建立一个新的session
在一个应用程序中,如果DAO 层使用Spring 的hibernate 模板,通过Spring 来控制session 的生命周期,则首选getCurrentSession ()。
0 0
- getCurrentSession 与 openSession() 的区别 getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession()与openSession()的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- openSession与getCurrentSession的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession 与 openSession() 的区别 .
- getCurrentSession 与 openSession() 的区别
- openSession与getCurrentSession的区别
- getCurrentSession 与 openSession() 的区别
- getCurrentSession与openSession的区别
- getCurrentSession()与openSession()的区别
- Seoquake参数解释和如何使用
- cvReshape比cvTranspose,cvGetRow,cvSetRow
- Android 图像缩略图及压缩图像
- 《自由从何而来》 读书笔记
- ASP.NET编写代码时出现“意外的字符”该怎么处理
- getCurrentSession 与 openSession() 的区别
- HDU 1875 畅通工程再续
- string 转 CString,CString 转 string
- Strutes2框架常量加载顺序
- Qt编译错误:GL/gl.h:No such file or directory
- 在Qt中如何使用QtDesigner创建的UI文件(一)
- JAVA自动创建多层文件目录
- linux启动流程分析
- 在Qt中如何使用QtDesigner创建的UI文件(二)