iBatis BaseDAO

package com.test.dao;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
public class BaseDAO<E> extends SqlMapClientDaoSupport{
    //查询多条信息
    @SuppressWarnings("unchecked")
protected List<E> select(String statementName,E Objectparameter) throws Exception{
        List<E> list ;
        list = this.getSqlMapClientTemplate().queryForList(statementName,Objectparameter);
        return list;
    }
    //查询一条信息
    protected int selectSingle (String statementName,E Objectparameter) throws Exception{
       Object obj = this.getSqlMapClientTemplate().queryForObject(statementName,Objectparameter);
       int max =0;
       if(obj != null) {
           max = (Integer) obj;
       }
        return max;
    }
   
    //删除信息
    protected int delete(String statementName,E parameterObject) throws Exception{
        int flag = 0;
        flag = this.getSqlMapClientTemplate().delete(statementName, parameterObject);
        return flag;
    }
   
    //增加信息
    protected int insert(String statementName, E parameterObject)throws Exception{
     
        int flag = 0;
        Object obj = this.getSqlMapClientTemplate().insert(statementName, parameterObject);
        if(obj != null){
            flag = (Integer) obj;
        }
        return flag;
    }
    //更新信息
    protected int update(String statementName,E parameterObject) throws Exception{
        int flag = 0;
        flag = this.getSqlMapClientTemplate().update(statementName, parameterObject);
        return flag;
    }
   
}

你可能感兴趣的:(ibatis)