package com.huimv.xt.dao; import java.sql.SQLException; import java.util.Date; import java.util.List; import java.util.Map; import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport; /** * BaseDAO基础接口实现 * @author hongjun.hu * @version 1.0 */ public class BaseDAOImpl extends SqlMapClientDaoSupport implements BaseDAO { /** * 单表操作:根据动态条件记数记录集 * @param nameSpace 命名空间串 * @param example example实例 * @return 数量 * @throws SQLException */ public int countByExample(String nameSpace, Object example) throws SQLException { Integer count = (Integer) getSqlMapClientTemplate().queryForObject( nameSpace + ".abatorgenerated_countByExample", example); return count; } /** * 数据删除 * @param sqlMapId sqlMap标识 * @param parameterObject 参数对象 * @return 插入对象 * @throws SQLException */ public int delete(String sqlMapId, Object parameterObject) throws SQLException { return getSqlMapClientTemplate().delete(sqlMapId, parameterObject); } /** * 单表操作:根据动态条件删除记录集 * @param nameSpace 命名空间串 * @param example example实例 * @return 删除返回 * @throws SQLException */ public int deleteByExample(String nameSpace, Object example) throws SQLException { int rows = getSqlMapClientTemplate().delete( nameSpace + ".abatorgenerated_deleteByExample", example); return rows; } /** * 单表操作:根据主键删除记录集 * @param nameSpace 命名空间串 * @param id 主键 * @return 删除返回 * @throws SQLException */ public int deleteByPrimaryKey(String nameSpace, Long id) throws SQLException { int rows = getSqlMapClientTemplate().delete( nameSpace + ".abatorgenerated_deleteByPrimaryKey", id); return rows; } /** * 得到当前数据时间 get.database.date位于XT_CZYH_SqlMap 中 * @return 日期 * @throws SQLException */ public Date getCurrentDate() throws SQLException { Date date = (Date) getSqlMapClientTemplate().queryForObject( "get.database.date", null); return date; } /** * 数据插入 * @param sqlMapId sqlMap标识 * @param parameterObject 参数对象 * @return Object 插入对象 * @throws SQLException */ public Object insert(String sqlMapId, Object parameterObject) throws SQLException { return getSqlMapClientTemplate().insert(sqlMapId, parameterObject); } /** * 单表操作:插入记录集 * @param nameSpace 命名空间串 * @param record 实体 * @throws SQLException */ public void insertRecord(String nameSpace, Object record) throws SQLException { getSqlMapClientTemplate().insert(nameSpace + ".abatorgenerated_insert", record); } /** * 数据查询并返回全部列表 * @param sqlMapId sqlMap标识 * @param parameterObject 参数对象 * @return 对象集合 * @throws SQLException */ @SuppressWarnings("rawtypes") public List queryForList(String sqlMapId, Object parameterObject) throws SQLException { return getSqlMapClientTemplate() .queryForList(sqlMapId, parameterObject); } /** * 数据查询并返回指定记录集大小的一个列表 * @param sqlMapId sqlMap标识 * @param parameterObject 参数对象 * @param skipResults - 记录位移量 * @param maxResults - 记录集大小 * @return List 对象List * @throws SQLException */ @SuppressWarnings("rawtypes") public List queryForList(String sqlMapId, Object parameterObject, int skipResults, int maxResults) throws SQLException { return getSqlMapClientTemplate().queryForList(sqlMapId, parameterObject, skipResults, maxResults); } /** * 数据查询并返回指定指keyProperty的一个Map对象 * @param sqlMapId sqlMap标识 * @param parameterObject 参数对象 * @param keyProperty Mapkey * @return Map map对象 * @throws SQLException */ @SuppressWarnings("rawtypes") public Map queryForMap(String sqlMapId, Object parameterObject, String keyProperty) throws SQLException { return getSqlMapClientTemplate().queryForMap(sqlMapId, parameterObject, keyProperty); } /** * 数据查询并返回指定keyProperty和valueProperty的一个Map对象 * @param sqlMapId sqlMap标识 * @param parameterObject 参数对象 * @param keyProperty keyProperty * @param valueProperty valueProperty * @return Map对象 * @throws SQLException */ @SuppressWarnings("rawtypes") public Map queryForMap(String sqlMapId, Object parameterObject, String keyProperty, String valueProperty) throws SQLException { return getSqlMapClientTemplate().queryForMap(sqlMapId + ".updateUser", parameterObject, keyProperty, valueProperty); } /** * 数据查询并返回一个对象 * @param sqlMapId sqlMap标识 * @param parameterObject 参数对象 * @return 插入对象 * @throws SQLException */ public Object queryForObject(String sqlMapId, Object parameterObject) throws SQLException { return getSqlMapClientTemplate().queryForObject(sqlMapId, parameterObject); } /** * 数据查询并返回指定的对象 * @param sqlMapId sqlMap标识 * @param parameterObject 参数对象 * @param resultObject 指定的对象 * @return 插入对象 * @throws SQLException */ public Object queryForObject(String sqlMapId, Object parameterObject, Object resultObject) throws SQLException { return getSqlMapClientTemplate().queryForObject(sqlMapId, parameterObject, resultObject); } /** * 单表操作:根据条件动态查询记录集 * @param nameSpace sql命名空间 * @param example example * @return List * @throws SQLException */ @SuppressWarnings("rawtypes") public List selectByExample(String nameSpace, Object example) throws SQLException { List list = getSqlMapClientTemplate().queryForList( nameSpace + ".abatorgenerated_selectByExample", example); return list; } /** * 单表操作:根据主键查询记录集 * @param nameSpace sql命名空间 * @param id PrimaryKey * @return Object * @throws SQLException */ public Object selectByPrimaryKey(String nameSpace, Long id) throws SQLException { Object record = getSqlMapClientTemplate().queryForObject( nameSpace + ".abatorgenerated_selectByPrimaryKey", id); return record; } /** * 数据更新 * @param sqlMapId sqlMap标识 * @param parameterObject 参数对象 * @return 插入对象 * @throws SQLException */ public int update(String sqlMapId, Object parameterObject) throws SQLException { return getSqlMapClientTemplate().update(sqlMapId, parameterObject); } /** * 单表操作:根据主键更新记录集 * @param nameSpace sql命名空间 * @param record 对象实体 * @return 更新返回代码值 * @throws SQLException */ public int updateByPrimaryKey(String nameSpace, Object record) throws SQLException { int rows = getSqlMapClientTemplate().update( nameSpace + ".abatorgenerated_updateByPrimaryKey", record); return rows; } /** * 单表操作:根据主键更新记录集 * @param nameSpace sql命名空间 * @param record 对象实体 * @return 更新返回代码值 * @throws SQLException */ public int updateByPrimaryKeySelective(String nameSpace, Object record) throws SQLException { int rows = getSqlMapClientTemplate().update( nameSpace + ".abatorgenerated_updateByPrimaryKeySelective", record); return rows; } }