面试很重要!!!获取session的方法有两种: 第一种是SessionFactory.getCurrentSession,第二种种是SessionFactory.openSession (1)openSession每次都是新建一个Session;需要close() (2)getCurentSess ...
分类:
Web程序 时间:
2016-03-31 09:33:30
阅读次数:
211
俗话说,自己写的代码,6个月后也是别人的代码……复习!复习!复习!涉及的知识点总结如下: Hibernate的内部执行过程(CRUD) 对象的状态及其转换图和例子 使用JUnit测试 使用getCurrentSession代替openSession ThreadLoacl对象 享元模式 sessio
分类:
Web程序 时间:
2016-03-11 01:14:34
阅读次数:
403
解决No Hibernate Session bound to thread 背景交代 在使用this.getHibernateTemplate().getSessionFactory().getCurrentSession()方法获取session时报以下异常信息: org.hibernate.H
分类:
Web程序 时间:
2016-02-04 11:28:32
阅读次数:
147
前言:1 getCurrentSession创建的session会和绑定到当前线程,而openSession不会。 2 getCurrentSession创建的线程会在事务回滚或事物提交后自动关闭,而openSession必须手动关闭 这里getCurrentSession本地事务(本地事务...
分类:
编程语言 时间:
2015-11-27 19:09:18
阅读次数:
159
Spring管理hibernate查询方法
HQL语句查询
this.getHibernateTemplate().getSessionFactory().getCurrentSession()
.createQuery("").uniqueResult();//null或者一个对象
Criteria查询
this.getHibernateTemplate().getSessionFactory().getCurrentSes..
分类:
编程语言 时间:
2015-11-12 18:17:17
阅读次数:
248
在另一篇播客我写到了,SessionFactory需要关注两个方法,即: openSession 和 getCurrentSession i. openSession 每次都是新的,需要close ii. getCurrentSession 从上下文找,如果有,用旧的,如果没有,...
分类:
Web程序 时间:
2015-10-03 23:03:33
阅读次数:
166
SessionFactory: a) 用来产生和管理Session b)通常情况下每个应用只需要一个SessionFactory c)除非要访问多个数据库的情况 d) 关注两个方法即: openSession 和 getCurrentSession i. openSession ...
分类:
Web程序 时间:
2015-10-03 19:27:58
阅读次数:
115
(转自:百度知道)看是怎么获得session的。方法1: 通过配置监听器后,在Dao中用getCurrentSession获取(内部原理。。。。),此时无需管理session的关闭与否;方法2: 在Dao中通过getSession获取,使用后必须关闭session。不关闭session的...
分类:
Web程序 时间:
2015-09-30 23:28:06
阅读次数:
519
hibernate.current_session_context_class博客分类:hibernateHibernateSpring多线程配置管理thread遇到过的问题:情景1:在使用SessionFactory的getCurrentSession方法时遇到如下错误,经过检查,原因如下:是因为...
分类:
Web程序 时间:
2015-09-29 18:32:15
阅读次数:
228
由openSession、getCurrentSession和HibernateDaoSupport浅谈Spring对事物的支持 Spring和Hibernate的集成的一个要点就是对事务的支持,openSession、getCurrentSession都是编程式事务(手动设置事务的提交、回滚)中....
分类:
编程语言 时间:
2015-09-18 18:19:43
阅读次数:
167