Java Code Examples for org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper

The following examples show how to use org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
 * 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=?",
	catch (EmptyResultDataAccessException ex) {
		throw new ObjectRetrievalFailureException(Owner.class, new Integer(id));
	return owner;
Example 2
 * Refresh the cache of Vets that the Clinic is holding.
 * @see org.springframework.samples.petclinic.Clinic#getVets()
@Transactional(readOnly = true)
public void refreshVetsCache() throws DataAccessException {
	synchronized (this.vets) {"Refreshing vets cache");

		// Retrieve the list of all vets.
				"SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",

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

		// 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));
			for (int specialtyId : vetSpecialtiesIds) {
				Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId);
Example 3
 * 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 ?",
			lastName + "%");
	return owners;
Example 4
Source Project: jeewx   Source File:    License: Apache License 2.0 5 votes vote down vote up
public static <T> DBTable<T> bulidDbTableFromSQL(String sql, Class<T> clazz, JdbcTemplate jdbcTemplate) throws InstantiationException, IllegalAccessException, Exception {
	DBTable<T> dbTable = new DBTable<T>();
	List<T> dataList = jdbcTemplate.query(sql, ParameterizedBeanPropertyRowMapper.newInstance(clazz));
	return dbTable;
Example 5
@Transactional(readOnly = true)
public Collection<PetType> getPetTypes() throws DataAccessException {
	return this.simpleJdbcTemplate.query(
			"SELECT id, name FROM types ORDER BY name",
Example 6
Source Project: jeewx   Source File:    License: Apache License 2.0 4 votes vote down vote up
protected ParameterizedBeanPropertyRowMapper resultBeanMapper(Class clazz) {
	return ParameterizedBeanPropertyRowMapper.newInstance(clazz);
Example 7
Source Project: maven-framework-project   Source File:    License: MIT License 3 votes vote down vote up
 * Returning ResultSet/REF Cursor from a SimpleJdbcCall
 * CREATE PROCEDURE read_all_customers()
 * SELECT a.CUST_ID, a.NAME, a.AGE FROM customer a;
 * END//
 * 使用simpleJdbcCall调用read_all_customers存储过程返回一个ResultSet Cursor
public List<Customer> getResultSetCursorUseSimpleJdbcCall(){
	Map<String, Object> map = simpleJdbcCall.withProcedureName("read_all_customers").
			returningResultSet("customers", ParameterizedBeanPropertyRowMapper.
			execute(new HashMap<String, Object>(0));
	return (List<Customer>) map.get("customers");