• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ParameterizedBeanPropertyRowMapper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper的典型用法代码示例。如果您正苦于以下问题:Java ParameterizedBeanPropertyRowMapper类的具体用法?Java ParameterizedBeanPropertyRowMapper怎么用?Java ParameterizedBeanPropertyRowMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ParameterizedBeanPropertyRowMapper类属于org.springframework.jdbc.core.simple包,在下文中一共展示了ParameterizedBeanPropertyRowMapper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getListRealType

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
private RowMapper<?> getListRealType(Method method) {
    ResultType resultType = method.getAnnotation(ResultType.class);
    if (resultType != null) {
        if (resultType.value().equals(Map.class)) {
            return getColumnMapRowMapper();
        }
        return ParameterizedBeanPropertyRowMapper.newInstance(resultType.value());
    }
    String genericReturnType = method.getGenericReturnType().toString();
    String realType = genericReturnType.replace("java.util.List", "").replace("<", "").replace(">", "");
    if (realType.contains("java.util.Map")) {
        return getColumnMapRowMapper();
    } else if (realType.length() > 0) {
        try {
            return ParameterizedBeanPropertyRowMapper.newInstance(Class.forName(realType));
        } catch (ClassNotFoundException e) {
            LOGGER.error(e.getMessage(), e.fillInStackTrace());
            throw new RuntimeException("dao get class error ,class name is:" + realType);
        }
    }
    return getColumnMapRowMapper();
}
 
开发者ID:edagarli,项目名称:Nicole,代码行数:23,代码来源:DaoHandler.java


示例2: loadOwner

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
/**
 * Loads the {@link Owner} with the supplied <code>id</code>; also loads
 * the {@link Pet Pets} and {@link Visit Visits} for the corresponding
 * owner, if not already loaded.
 */
@Transactional(readOnly = true)
public Owner loadOwner(int id) throws DataAccessException {
	Owner owner;
	try {
		owner = this.simpleJdbcTemplate.queryForObject(
				"SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id=?",
				ParameterizedBeanPropertyRowMapper.newInstance(Owner.class),
				id);
	}
	catch (EmptyResultDataAccessException ex) {
		throw new ObjectRetrievalFailureException(Owner.class, new Integer(id));
	}
	loadPetsAndVisits(owner);
	return owner;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:21,代码来源:SimpleJdbcClinic.java


示例3: findById

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
/**
 * Loads the {@link Owner} with the supplied <code>id</code>; also loads the {@link Pet Pets} and {@link Visit Visits}
 * for the corresponding owner, if not already loaded.
 */
@Override
public Owner findById(int id) throws DataAccessException {
    Owner owner;
    try {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", id);
        owner = this.namedParameterJdbcTemplate.queryForObject(
                "SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id",
                params,
                ParameterizedBeanPropertyRowMapper.newInstance(Owner.class)
        );
    } catch (EmptyResultDataAccessException ex) {
        throw new ObjectRetrievalFailureException(Owner.class, id);
    }
    loadPetsAndVisits(owner);
    return owner;
}
 
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:22,代码来源:JdbcOwnerRepositoryImpl.java


示例4: queryForObject

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
public T queryForObject(String sql, Class clazz, Object... args) {
	try {
		return (T) simpleJdbcTemplate
				.queryForObject(sql, ParameterizedBeanPropertyRowMapper
						.newInstance(clazz), args);
		// return (T) this.jdbcTemplate.queryForObject(sql, args, clazz);
	} catch (Exception ex) {
		// ex.printStackTrace();
		// throw new ObjectNotFoundException(ex, sql);
		this.logger.error("查询出错", ex);
		return null;
	}
}
 
开发者ID:yulele166,项目名称:pub-service,代码行数:14,代码来源:JdbcDaoSupport.java


示例5: refreshVetsCache

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
/**
 * Refresh the cache of Vets that the Clinic is holding.
 * @see org.springframework.samples.petclinic.Clinic#getVets()
 */
@ManagedOperation
@Transactional(readOnly = true)
public void refreshVetsCache() throws DataAccessException {
	synchronized (this.vets) {
		this.logger.info("Refreshing vets cache");

		// Retrieve the list of all vets.
		this.vets.clear();
		this.vets.addAll(this.simpleJdbcTemplate.query(
				"SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
				ParameterizedBeanPropertyRowMapper.newInstance(Vet.class)));

		// Retrieve the list of all possible specialties.
		final List<Specialty> specialties = this.simpleJdbcTemplate.query(
				"SELECT id, name FROM specialties",
				ParameterizedBeanPropertyRowMapper.newInstance(Specialty.class));

		// Build each vet's list of specialties.
		for (Vet vet : this.vets) {
			final List<Integer> vetSpecialtiesIds = this.simpleJdbcTemplate.query(
					"SELECT specialty_id FROM vet_specialties WHERE vet_id=?",
					new ParameterizedRowMapper<Integer>() {
						public Integer mapRow(ResultSet rs, int row) throws SQLException {
							return Integer.valueOf(rs.getInt(1));
						}},
					vet.getId().intValue());
			for (int specialtyId : vetSpecialtiesIds) {
				Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId);
				vet.addSpecialty(specialty);
			}
		}
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:38,代码来源:SimpleJdbcClinic.java


示例6: findOwners

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
/**
 * Loads {@link Owner Owners} from the data store by last name, returning
 * all owners whose last name <i>starts</i> with the given name; also loads
 * the {@link Pet Pets} and {@link Visit Visits} for the corresponding
 * owners, if not already loaded.
 */
@Transactional(readOnly = true)
public Collection<Owner> findOwners(String lastName) throws DataAccessException {
	List<Owner> owners = this.simpleJdbcTemplate.query(
			"SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE last_name like ?",
			ParameterizedBeanPropertyRowMapper.newInstance(Owner.class),
			lastName + "%");
	loadOwnersPetsAndVisits(owners);
	return owners;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:16,代码来源:SimpleJdbcClinic.java


示例7: getProjectDescDetailList

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
@Override
public List<ProjDescDetail> getProjectDescDetailList(Set<Integer> descItemIds, String descType) {
	String sqlQuery = "select * from " + DescriptionType.getDescriptionTableName(descType) + " where ProjDescId in (:ids)";
	MapSqlParameterSource parameters = new MapSqlParameterSource();
	parameters.addValue("ids", descItemIds);
	List<ProjDescDetail> projDescDetails = namedParameterJdbcTemplate.query(sqlQuery, parameters, ParameterizedBeanPropertyRowMapper.newInstance(ProjDescDetail.class));
	return projDescDetails;
}
 
开发者ID:devintqa,项目名称:pms,代码行数:9,代码来源:ProjectDescriptionDAOImpl.java


示例8: QueryImpl

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
/**
 * <p> 构造函数初始化SQL,及相关参数 </p>
 * @param sql
 * @param params
 */
public QueryImpl(
			Class<T> entity ,
			JdbcTemplate jdbcTemplate,
			SQLGenerator sqlGenerator,
			String sql,
			Object...params){
	super(jdbcTemplate,sqlGenerator,sql,params);
	this.mapper = ParameterizedBeanPropertyRowMapper.newInstance( entity );
}
 
开发者ID:leopardoooo,项目名称:cambodia,代码行数:15,代码来源:QueryImpl.java


示例9: findAll

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
/**
 * Refresh the cache of Vets that the ClinicService is holding.
 *
 * @see org.springframework.samples.petclinic.model.service.ClinicService#findVets()
 */
@Override
public Collection<Vet> findAll() throws DataAccessException {
    List<Vet> vets = new ArrayList<Vet>();
    // Retrieve the list of all vets.
    vets.addAll(this.jdbcTemplate.query(
            "SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
            ParameterizedBeanPropertyRowMapper.newInstance(Vet.class)));

    // Retrieve the list of all possible specialties.
    final List<Specialty> specialties = this.jdbcTemplate.query(
            "SELECT id, name FROM specialties",
            ParameterizedBeanPropertyRowMapper.newInstance(Specialty.class));

    // Build each vet's list of specialties.
    for (Vet vet : vets) {
        final List<Integer> vetSpecialtiesIds = this.jdbcTemplate.query(
                "SELECT specialty_id FROM vet_specialties WHERE vet_id=?",
                new ParameterizedRowMapper<Integer>() {
                    @Override
                    public Integer mapRow(ResultSet rs, int row) throws SQLException {
                        return Integer.valueOf(rs.getInt(1));
                    }
                },
                vet.getId().intValue());
        for (int specialtyId : vetSpecialtiesIds) {
            Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId);
            vet.addSpecialty(specialty);
        }
    }
    return vets;
}
 
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:37,代码来源:JdbcVetRepositoryImpl.java


示例10: findByLastName

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
/**
 * Loads {@link Owner Owners} from the data store by last name, returning all owners whose last name <i>starts</i> with
 * the given name; also loads the {@link Pet Pets} and {@link Visit Visits} for the corresponding owners, if not
 * already loaded.
 */
@Override
public Collection<Owner> findByLastName(String lastName) throws DataAccessException {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("lastName", lastName + "%");
    List<Owner> owners = this.namedParameterJdbcTemplate.query(
            "SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE last_name like :lastName",
            params,
            ParameterizedBeanPropertyRowMapper.newInstance(Owner.class)
    );
    loadOwnersPetsAndVisits(owners);
    return owners;
}
 
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:18,代码来源:JdbcOwnerRepositoryImpl.java


示例11: findPetTypes

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
@Override
public List<PetType> findPetTypes() throws DataAccessException {
    Map<String, Object> params = new HashMap<String, Object>();
    return this.namedParameterJdbcTemplate.query(
            "SELECT id, name FROM types ORDER BY name",
            params,
            ParameterizedBeanPropertyRowMapper.newInstance(PetType.class));
}
 
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:9,代码来源:JdbcPetRepositoryImpl.java


示例12: findById

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
@Override
public SysUser findById(Integer id) {
	try{
		String sql = "SELECT * FROM sys_user WHERE id=?";
		return this.jdbcTemplate.queryForObject(sql, 
				ParameterizedBeanPropertyRowMapper.newInstance(SysUser.class),id);
	}catch(EmptyResultDataAccessException e){
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:huligong1234,项目名称:springbyexample,代码行数:12,代码来源:SysUserDaoImpl.java


示例13: findList

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
@Override
public List<SysUser> findList(SysUser sysUser) {
	logger.info("######info.....");
	logger.debug("######debug.....");
	logger.error("######error.....");
	String sql = "SELECT * FROM sys_user";
	return this.jdbcTemplate.query(sql, ParameterizedBeanPropertyRowMapper.newInstance(SysUser.class));
}
 
开发者ID:huligong1234,项目名称:springbyexample,代码行数:9,代码来源:SysUserDaoImpl.java


示例14: queryForList

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
public List<T> queryForList(String sql, Class clazz, Object... args) {
	return this.simpleJdbcTemplate.query(sql,
			ParameterizedBeanPropertyRowMapper.newInstance(clazz), args);

}
 
开发者ID:yulele166,项目名称:pub-service,代码行数:6,代码来源:JdbcDaoSupport.java


示例15: getReturnDaoResult

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
private Object getReturnDaoResult(String dbType, DaoPage pageSetting, Method method, String executeSql, Map<String, Object> paramMap) {
    String methodName = method.getName();
    if (checkActiveKey(methodName)) {
        if (paramMap != null) {
            return namedParameterJdbcTemplate.update(executeSql, paramMap);
        } else {
            return jdbcTemplate.update(executeSql);
        }
    } else if (checkBatchKey(methodName)) {
        return batchUpdate(executeSql);
    } else {
        Class<?> returnType = method.getReturnType();
        if(returnType.isPrimitive()){
            Number number = jdbcTemplate.queryForObject(executeSql, BigDecimal.class);
            if ("int".equals(returnType.getCanonicalName())) {
                return number.intValue();
            } else if ("long".equals(returnType.getCanonicalName())) {
                return number.longValue();
            } else if ("double".equals(returnType.getCanonicalName())) {
                return number.doubleValue();
            }
        } else if(returnType.isAssignableFrom(List.class) || returnType.isAssignableFrom(DaoPage.class)){
            int page = pageSetting.getPage();
            int rows = pageSetting.getRows();
            if (page != 0 && rows != 0) {
                if(returnType.isAssignableFrom(DaoPage.class)){
                    if(paramMap != null){
                        pageSetting.setTotal(namedParameterJdbcTemplate.queryForObject(getCountSql(executeSql), paramMap, Integer.class));
                    } else{
                        pageSetting.setTotal(jdbcTemplate.queryForObject(getCountSql(executeSql), Integer.class));
                    }
                }
                executeSql = DaoUtil.createPageSql(dbType, executeSql, page, rows);
            }
            RowMapper resultType = getListRealType(method);
            List list;
            if (paramMap != null) {
                list = namedParameterJdbcTemplate.query(executeSql, paramMap, resultType);
            } else {
                list = jdbcTemplate.query(executeSql, resultType);
            }

            if (returnType.isAssignableFrom(DaoPage.class)) {
                pageSetting.setResults(list);
                return pageSetting;
            } else {
                return list;
            }
        } else if (returnType.isAssignableFrom(Map.class)) {
            // Map类型
            if (paramMap != null) {
                return namedParameterJdbcTemplate.queryForObject(executeSql, paramMap, getColumnMapRowMapper());
            } else {
                return jdbcTemplate.queryForObject(executeSql, getColumnMapRowMapper());
            }
        } else if (returnType.isAssignableFrom(String.class)) {
            if (paramMap != null) {
                return namedParameterJdbcTemplate.queryForObject(executeSql, paramMap, String.class);
            } else {
                return jdbcTemplate.queryForObject(executeSql, String.class);
            }
        } else if (DaoUtil.isWrapClass(returnType)) {
            if (paramMap != null) {
                return namedParameterJdbcTemplate.queryForObject(executeSql, paramMap, returnType);
            } else {
                return jdbcTemplate.queryForObject(executeSql, returnType);
            }
        } else {
            // 对象类型
            RowMapper<?> rm = ParameterizedBeanPropertyRowMapper.newInstance(returnType);
            if (paramMap != null) {
                return namedParameterJdbcTemplate.queryForObject(executeSql, paramMap, rm);
            } else {
                return jdbcTemplate.queryForObject(executeSql, rm);
            }
        }
    }

    return null;
}
 
开发者ID:edagarli,项目名称:Nicole,代码行数:81,代码来源:DaoHandler.java


示例16: getPetTypes

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
@Transactional(readOnly = true)
public Collection<PetType> getPetTypes() throws DataAccessException {
	return this.simpleJdbcTemplate.query(
			"SELECT id, name FROM types ORDER BY name",
			ParameterizedBeanPropertyRowMapper.newInstance(PetType.class));
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:7,代码来源:SimpleJdbcClinic.java


示例17: PartResultSetExtractor

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
public PartResultSetExtractor(Class<T> cls, DataHandler<T> dataHandler) {
	rowMapper = ParameterizedBeanPropertyRowMapper.newInstance(cls);
	this.dataHandler = dataHandler;
}
 
开发者ID:leopardoooo,项目名称:cambodia,代码行数:5,代码来源:PartResultSetExtractor.java


示例18: getPetTypes

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
public Collection<PetType> getPetTypes() throws DataAccessException {
    return this.namedParameterJdbcTemplate.query(
            "SELECT id, name FROM types ORDER BY name", new HashMap<String, Object>(),
            ParameterizedBeanPropertyRowMapper.newInstance(PetType.class));
}
 
开发者ID:jptiancai,项目名称:spring-petclinic-study,代码行数:6,代码来源:JdbcOwnerRepositoryImpl.java


示例19: findList

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
@Override
public List<SysUser> findList(SysUser sysUser) {
	String sql = "SELECT * FROM sys_user";
	return this.jdbcTemplate.query(sql, ParameterizedBeanPropertyRowMapper.newInstance(SysUser.class));
}
 
开发者ID:huligong1234,项目名称:springbyexample,代码行数:6,代码来源:SysUserDaoImpl.java


示例20: getResultSetCursorUseSimpleJdbcCall

import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper; //导入依赖的package包/类
/**
 * Returning ResultSet/REF Cursor from a SimpleJdbcCall
 * 
 * DELIMITER //
 * CREATE PROCEDURE read_all_customers()
 * BEGIN
 * SELECT a.CUST_ID, a.NAME, a.AGE FROM customer a;
 * END//
 * 
 * 使用simpleJdbcCall调用read_all_customers存储过程返回一个ResultSet Cursor
 * 
 */
@SuppressWarnings("unchecked")
public List<Customer> getResultSetCursorUseSimpleJdbcCall(){
	Map<String, Object> map = simpleJdbcCall.withProcedureName("read_all_customers").
			returningResultSet("customers", ParameterizedBeanPropertyRowMapper.
					newInstance(Customer.class)).
			execute(new HashMap<String, Object>(0));
	return (List<Customer>) map.get("customers");
}
 
开发者ID:v5developer,项目名称:maven-framework-project,代码行数:21,代码来源:JdbcCustomerDAO.java



注:本文中的org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JtsSpatialContext类代码示例发布时间:2022-05-22
下一篇:
Java ServerCommandEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap