写一个类继承SqlMapClientDaoSupport,然后我们就可以用他的一些方法了:
public class IbatisDao extends SqlMapClientDaoSupport{
/**
* 查询单条记录
* @param statementName
* @return
*/
public Object queryForObject(String statementName){
return this.getSqlMapClientTemplate().queryForObject(statementName);
}
/**
* 根据条件查询单条记录
* @param statementName
* @param parameterObject
* @return
*/
public Object queryForObject(String statementName, Object parameterObject){
return this.getSqlMapClientTemplate().queryForObject(statementName, parameterObject);
}
/**
* 查询列表
* @param statementName
* @return
*/
public List queryForList(String statementName){
return this.getSqlMapClientTemplate().queryForList(statementName);
}
/**
* 根据查询条件查询列表
* @param statementName
* @return
*/
public List queryForList(String statementName, parameterObject){
return this.getSqlMapClientTemplate().queryForList(statement, parameterObject);
}
/**
* 分页
* @param statementName
* @param skipResults 开始
* @param maxResults 记录数
* @return
*/
public List queryForList(String statement ,int skipResults, int maxResults){
return this.getSqlMapTemplate().queryForList(statement,skipResults,maxResults);
}
/**
* 带条件的分页
* @param statementName
* @param skipResults 开始
* @param maxResults 记录数
* @return
*/
public List queryForList(String statementName, Object parameterObject, int skipResults, int maxResults){
statementName = dealModelName(statementName);
return this.getSqlMapClientTemplate().queryForList(statementName,parameterObject,skipResults,maxResults);
}
/**
* 插入
* @return
*/
public void insert(String statementName){
this.getSqlMapClientTemplate().insert(statementName);
}
public void insert(String statementName, Object parameterObject){
this.getSqlMapClientTemplate().insert(statementName,parameterObject);
}
/**
* 更新
* @return
*/
public int update(String statementName){
this.getSqlMapClientTemplate().update(statementName);
}
/**
* 更新
* @return
*/
public int update(String statement, Object parameterObject){
this.getSqlMapTemplate().update(String statemente, parameterObject);
}
/**
* 删除
* @return
*/
public int delete(String statement){
this.getSqlMapTemplate().delete(statement);
}
/**
* 删除
* @return
*/
public int delete(String statement, Object parameterObject){
this.getSqlMapTemplate().delete(statement, parameterObject);
}
/**
* 查询Map
* @return
*/
public Map queryForMap(String statement,String keyProperty,String valueProperty){
return this.getSqlMapClientTemplate().queryForMap(statement,null,keyProperty,valueProperty);
}
/**
* (带参数)查询Map
* @return
*/
public Map queryForMap(String statement, Object parameterObject, String keyProperty, String valueProperty){
return this.getSqlMapClientTemplate().quetyForMap(statement,parameterObject,keyProperty,valueProperty);
}
}