Spring框架学习[HibernateTemplate对Hibernate的封装](三)

2014-11-24 03:05:48 · 作者: · 浏览: 7
nslator, sessionHolder); } //判断是否允许返回给定的Session if (!allowCreate && !isSessionTransactional(session, sessionFactory)) { closeSession(session); throw new IllegalStateException("No Hibernate Session bound to thread, " + "and configuration does not allow creation of non-transactional one here"); } return session; }

通过上面Spring对Hibernate Session管理的源码分析,我们了解到Spring已经将Hibernate Session的获取与关闭,Session的事务处理,以及Session与线程资源绑定等操作做了封装统一管理,为应用使用Hibernate提供了方便。