basicdao.java

来自「移动彩信管理平台」· Java 代码 · 共 116 行

JAVA
116
字号
package com.my7g.zj.mobile.mms.sys;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.hibernate.Session;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate3.HibernateTemplate;

/**
 * 
 * @author csc
 * 
 * 基础的数据处理dao类 因为业务层的数据访问大大大于业务逻辑所以不提供针对各个表提供数据访问dao类 而采用统一的dao基础公共类
 * 所有的底层实现类均抛出了 RuntimeException 供异常捕捉
 */
public class BasicDao {

	protected DaoSupport daoSupport = null;

	protected JdbcTemplate jdbcTemplate = null;

	/**
	 * @return the daoSupport
	 */
	public DaoSupport getDaoSupport() {
		return daoSupport;
	}

	public void setDaoSupport(DaoSupport daoSupport) {
		this.daoSupport = daoSupport;
	}

	public Serializable save(Object arg0) {
		return this.daoSupport.save(arg0);
	}

	public void saveOrUpdate(Object arg0) {
		this.daoSupport.saveOrUpdate(arg0);
	}

	public void saveOrUpdateAll(Collection arg0) {
		this.daoSupport.saveOrUpdateAll(arg0);
	}

	public void update(Object vo) {
		this.daoSupport.update(vo);
	}

	public void delete(Object vo) {
		this.daoSupport.delete(vo);
	}

	public void delete(Class c, Serializable s) {
		this.daoSupport.delete(c, s);
	}

	public List find(String hql) {
		return this.daoSupport.find(hql);
	}

	public List find(String arg0, Object[] arg1) {

		return this.daoSupport.find(arg0, arg1);
	}

	public Object get(Class c, Serializable s) {
		return this.daoSupport.get(c, s);
	}

	public List find(String hql, int maxResult, int firstRow) {
		return this.daoSupport.find(hql, maxResult, firstRow);
	}

	public Long getResultCount(String hql){
		
		return this.daoSupport.getResultCount(hql);
	}
	
	public Object getUniqueResult(String hql){
		
		return this.daoSupport.getUniqueResult(hql);	
	}
	
	
	

	/**
	 * 得到一个hibernate的session
	 * 
	 * @return
	 */
	public Session getSession() {
		return this.daoSupport.getaSession();
	}

	/**
	 * 得到HibernateTemplate(不推荐使用)
	 * 
	 * @return
	 */
	public HibernateTemplate getHibernateTemplate() {
		return this.daoSupport.getaHibernateTemplate();
	}

	public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?