【文件属性】:
文件名称:springmvc-jdbcTemplate
文件大小:15.84MB
文件格式:ZIP
更新时间:2018-12-23 03:38:34
jdbcTemplate
package com.flong.commons.persistence.dao.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import com.flong.commons.lang.exception.DaoAccessException;
import com.flong.commons.persistence.Entity;
import com.flong.commons.persistence.bean.DataStore;
import com.flong.commons.persistence.bean.PagingParameter;
import com.flong.commons.persistence.builder.PagingSqlBuilder;
import com.flong.commons.persistence.builder.SimpleSqlBuilder;
import com.flong.commons.persistence.condition.Condition;
import com.flong.commons.persistence.dao.BaseDao;
import com.flong.commons.persistence.interfaces.ISQLQuery;
import com.flong.commons.persistence.interfaces.MapRowMapper;
import com.mchange.v2.c3p0.ComboPooledDataSource;
/**
* 数据查询DAO支持类
*
* 创建日期:2012-9-26
* @author wangk
*/
public abstract class BaseDaoSupport implements BaseDao, InitializingBean {
/** 日志对象 */
private static final Logger logger = Logger.getLogger(BaseDaoSupport.class);
/** 实现类日志对象 */
protected final Logger log = Logger.getLogger(getClass());
@Autowired protected ISQLQuery iSQLQuery;
/** JDBC模版对象 */
@Autowired protected JdbcTemplate jdbcTemplate;
/** SQL语句参数带名称的JDBC模版对象 */
protected NamedParameterJdbcTemplate namedParameterJdbcTemplate;
/** 分页SQL语句创建对象 */
protected PagingSqlBuilder pagingSqlBuilder;
/**
* 获得JDBC模版对象
*
* @return
* 创建日期:2012-9-25
* 修改说明:
* @author wangk
*/
public JdbcTemplate getJdbcTemplate() {
return jdbcTemplate;
}
/**
* 获得SQL语句参数带名称的JDBC模版对象
*
* @return
* 创建日期:2012-12-19
* 修改说明:
* @author wangk
*/
public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() {
return namedParameterJdbcTemplate;
}
/**
* 获得分页SQL语句创建对象
*
* @return
* 创建日期:2012-10-8
* 修改说明:
* @author wangk
*/
public PagingSqlBuilder getPagingSqlBuilder() {
return pagingSqlBuilder;
}
/**
* 初始化非注入的属性
*
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
* 创建日期:2012-12-19
* 修改说明:
* @author wangk
*/
@Override
public void afterPropertiesSet() throws Exception {
//初始化namedParameterJdbcTemplate
namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate.getDataSource());
//初始化pagingSqlBuilder
pagingSqlBuilder = new PagingSqlBuilder(((ComboPooledDataSource)
jdbcTemplate.getDataSource()).getJdbcUrl().replaceAll("://.*$", ""));
}
@Override
public List