-
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;
-
-
- public final void setSessionFactory(SessionFactory paramSessionFactory)
- {
- this.hibernateTemplate = createHibernateTemplate(paramSessionFactory);
- }
-
- 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");
- }
-
- 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());
- }
-
相关阅读:
这个帖子主要总结数据库备份方面的问题
Visual C#.Net 网络程序开发Socket篇
数据库设计说明书参考模板
用Visual C#开发WinForm的应用程序
在ASP.NET页中读取文本文件
如何通过 SQL Server 链接服务器和分布式查询使用 Excel
ER概念模型
SQL Server 存储过程的分页方案比拼
读出某一个目录的文件和文件夹
Linux中的定时任务简单操作实例
-
原文地址:https://www.cnblogs.com/doudou618/p/4323534.html
Copyright © 2020-2023
润新知