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的主要任务是把一张图片从服务器下载到内存中.下载数据并不难,如何对下载这一系列的任务进行设计 ...
随机推荐
- OneProxy wiki上线了
文档的敏捷开发方式,希望把文档做好. http://www.onexsoft.com/dokuwiki/doku.php?id=oneproxy
- 谈谈JPA-03-基本注解
@Entity @Entity 标注用于实体类声明语句之前,指出该Java 类为实体类,将映射到指定的数据库表.如声明一个实体类 Customer,它将映射到数据库中的 customer 表上. @T ...
- Windows下Git的安装及配置
Git的BASH Git的为Windows提供了用于命令行运行的一个仿真BASH的Git.习惯LINUX和UNIX环境的你,可以在该BASH环境中输入“git”命令来完成各种版本控制的操作. 简介 G ...
- mouseover,mouseenter,mouseleave,mouseout
mouseover和mouseout对应 //鼠标移入移出触发该元素及子元素 mouseenter和mouseleave对应 //鼠标移入移出只触发该元素 看完例子即可知道其区别: mouseover ...
- Mybatis 学习-1
本次MyBatis基础实例教程主要讲述MyBatis在项目中的配置方法,实体对象的关系映射.关联关系,以及如何实现一个BaseDao的功能 实例数据库的表结构 CREATE TABLE `blog_u ...
- C++格式化输入输出
要实现格式化输入输出,程序需要包含 iostreams 标准标头 <iomanip> 以定义几个各自采用单个参数的操控器. 备注: 其中每个操控器都返回重载 basic_istream&l ...
- 详细解读Jquery各Ajax函数
$.get(),$.post(),$.ajax(),$.getJSON() 一,$.get(url,[data],[callback]) 说明:url为请求地址,data为请求数据的列表,callba ...
- Extjs 视频教程
---恢复内容开始--- 网易云课堂 <尚学堂_Ext视频教程> login.html <html> <head> <meta http-equiv=&quo ...
- bat产生随机数并复制文件及生成文件列表
有这样一个场景:我需要将同一个文件复制为上千个文件,并且文件名应为随机数.为了简单起见,不想写程序,直接写个BAT来,方便,简单,易用: 1. 搞定用BAT产生32位随机数,存为变量并使用,保存以下代 ...
- UVALive 7297 Hounded by Indecision BFS
题目链接:Hounded by Indecision 题意:map中给出小偷的位置,警察的位置.警察有一只狗,开始的时候警察和狗一起行动,也就是看做一个格子,当警察遇见小偷走过的格子时,狗就会嗅到它的 ...