数据库操作基类设计2
public List<T> queryAll() // 查询Domain所有记录
{
String statementName = entitySimpleClassName + ".queryAll";
return getSqlMapClientTemplate().queryForList(statementName);
}
public T queryById(String id) // 根据对象id查询Domain
{
String statementName = entitySimpleClassName + ".queryById";
return (T)getSqlMapClientTemplate().queryForObject(statementName, id);
}
public int update(T t)
{
String statementName = entitySimpleClassName + ".update";
return getSqlMapClientTemplate().update(statementName, t);
}
public int deleteById(String id)
{
String statementName = entitySimpleClassName + ".deleteById";
return getSqlMapClientTemplate().delete(statementName, id);
}
public int deleteByCriteria(T criteria)// 根据标准删除指定对象集合
{
String statementName = entitySimpleClassName + ".deleteByCriteria";
return getSqlMapClientTemplate().delete(statementName, criteria);
}
public List<T> queryByCriteria(T criteria)
{
String statementName = entitySimpleClassName + ".query";
List<T> entities = getSqlMapClientTemplate().queryForList(statementName, criteria);
return entities;
}
/**
* 根据标准查询分页查询对象列表
* <p>SQL语句id为query和queryCounts<p>
* @param criteria 查询标准
* @param pageNo 当前页号
* @param countPerPage 每页展示数量
* @return PaginationSupport 分页对象
*/
public PaginationSupport<T> queryPagingEntities(T criteria, int pageNo, int countPerPage)
{
String statementName = entitySimpleClassName + ".query";
return queryForPagination(criteria, pageNo, countPerPage, statementName);
}