HibernateDaoSupport 源码
- package org.springframework.orm.hibernate3.support;
- import org.hibernate.HibernateException;
- import org.hibernate.Session;
- import org.hibernate.SessionFactory;
- import org.springframework.dao.DataAccessException;
- import org.springframework.dao.DataAccessResourceFailureException;
- import org.springframework.dao.support.DaoSupport;
- import org.springframework.orm.hibernate3.HibernateTemplate;
- import org.springframework.orm.hibernate3.SessionFactoryUtils;
- public abstract class HibernateDaoSupport extends DaoSupport
- {
- private HibernateTemplate hibernateTemplate;
- // set注入sessionFactory
- public final void setSessionFactory(SessionFactory paramSessionFactory)
- {
- this.hibernateTemplate = createHibernateTemplate(paramSessionFactory);
- }
- //创建HibernateTemplate 俺们就是用这个对象
- protected HibernateTemplate createHibernateTemplate(SessionFactory paramSessionFactory)
- {
- return new HibernateTemplate(paramSessionFactory);
- }
- public final SessionFactory getSessionFactory()
- {
- return ((this.hibernateTemplate != null) ? this.hibernateTemplate.getSessionFactory() : null);
- }
- public final void setHibernateTemplate(HibernateTemplate paramHibernateTemplate)
- {
- this.hibernateTemplate = paramHibernateTemplate;
- }
- public final HibernateTemplate getHibernateTemplate()
- {
- return this.hibernateTemplate;
- }
- protected final void checkDaoConfig() {
- if (this.hibernateTemplate == null)
- throw new IllegalArgumentException("'sessionFactory' or 'hibernateTemplate' is required");
- }
- //创建session
- protected final Session getSession()
- throws DataAccessResourceFailureException, IllegalStateException
- {
- return getSession(this.hibernateTemplate.isAllowCreate());
- }
- protected final Session getSession(boolean paramBoolean)
- throws DataAccessResourceFailureException, IllegalStateException
- {
- return ((!(paramBoolean)) ? SessionFactoryUtils.getSession(getSessionFactory(), false) : SessionFactoryUtils.getSession(getSessionFactory(), this.hibernateTemplate.getEntityInterceptor(), this.hibernateTemplate.getJdbcExceptionTranslator()));
- }
- protected final DataAccessException convertHibernateAccessException(HibernateException paramHibernateException)
- {
- return this.hibernateTemplate.convertHibernateAccessException(paramHibernateException);
- }
- protected final void releaseSession(Session paramSession)
- {
- SessionFactoryUtils.releaseSession(paramSession, getSessionFactory());
- }
HibernateDaoSupport 源码的更多相关文章
- SSH框架总结(环境搭建+框架分析+实例源码下载)
一.SSH框架简介 SSH是struts+spring+hibernate集成的web应用程序开源框架. Struts:用来控制的,核心控制器是Controller. Spring:对Struts和H ...
- 【原】Android热更新开源项目Tinker源码解析系列之三:so热更新
本系列将从以下三个方面对Tinker进行源码解析: Android热更新开源项目Tinker源码解析系列之一:Dex热更新 Android热更新开源项目Tinker源码解析系列之二:资源文件热更新 A ...
- C# ini文件操作【源码下载】
介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函 ...
- 【原】FMDB源码阅读(三)
[原]FMDB源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 FMDB比较优秀的地方就在于对多线程的处理.所以这一篇主要是研究FMDB的多线程处理的实现.而 ...
- 从源码看Azkaban作业流下发过程
上一篇零散地罗列了看源码时记录的一些类的信息,这篇完整介绍一个作业流在Azkaban中的执行过程,希望可以帮助刚刚接手Azkaban相关工作的开发.测试. 一.Azkaban简介 Azkaban作为开 ...
- 【原】Android热更新开源项目Tinker源码解析系列之一:Dex热更新
[原]Android热更新开源项目Tinker源码解析系列之一:Dex热更新 Tinker是微信的第一个开源项目,主要用于安卓应用bug的热修复和功能的迭代. Tinker github地址:http ...
- 【原】Android热更新开源项目Tinker源码解析系列之二:资源文件热更新
上一篇文章介绍了Dex文件的热更新流程,本文将会分析Tinker中对资源文件的热更新流程. 同Dex,资源文件的热更新同样包括三个部分:资源补丁生成,资源补丁合成及资源补丁加载. 本系列将从以下三个方 ...
- 多线程爬坑之路-Thread和Runable源码解析之基本方法的运用实例
前面的文章:多线程爬坑之路-学习多线程需要来了解哪些东西?(concurrent并发包的数据结构和线程池,Locks锁,Atomic原子类) 多线程爬坑之路-Thread和Runable源码解析 前面 ...
- SDWebImage源码解读之SDWebImageDownloaderOperation
第七篇 前言 本篇文章主要讲解下载操作的相关知识,SDWebImageDownloaderOperation的主要任务是把一张图片从服务器下载到内存中.下载数据并不难,如何对下载这一系列的任务进行设计 ...
随机推荐
- css清除默认样式和设置公共样式
/*公共样式--开始*/ html, body, div, ul, li, h1, h2, h3, h4, h5, h6, p, dl, dt, dd, ol, form, input, textar ...
- 024-ActionResult解说
ActionResult是一个抽象类,是Action运行后的回传类型,但是当Action回传ActionResult的时候,其实并不包含这个ActionResult的运行结果,而是包含运行这个Acti ...
- [maven] pom.xml 文件详解
参考资料: http://blog.csdn.net/uohzoaix/article/details/7035307 http://www.cnblogs.com/qq78292959/p/3711 ...
- js 数组的判断
<javascript语言精粹>中的 var is_array = function(value){ return value && //判断值是否为真,不接受null和其 ...
- MySQL索引实现
摘自:http://blog.codinglabs.org/articles/theory-of-mysql-index.html 在MySQL中,索引属于存储引擎级别的概念,不同存储引擎对索引的实现 ...
- 421. Maximum XOR of Two Numbers in an Array——本质:利用trie数据结构查找
Given a non-empty array of numbers, a0, a1, a2, - , an-1, where 0 ≤ ai < 231. Find the maximum re ...
- Gramar
一.And 并列关系(and) in addition / and / similarly / likewise / as well as / besides / furthermore / also ...
- linux-网卡故障
Linux 网络问题解决思路 1.查看 /etc/sysconfig/network-script/ 查看eth0和eth1的配置是否正确 2.查看 /etc/modual.conf 的配置模块是否正 ...
- PostgreSQL数据库系统优点
PostgreSQL 是世界上可以获得的最先进的开放源码的数据库系统, 它提供了多版本并行控制,支持几乎所有 SQL 构件(包括子查询,事务和用户定 义类型和函数), 并且可以获得非常广阔范围的(开发 ...
- [示例]NSDictionary编程题-字典的排序应用(iOS7班)
代码: #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepo ...