Example usage for org.springframework.jdbc.core BeanPropertyRowMapper BeanPropertyRowMapper

List of usage examples for org.springframework.jdbc.core BeanPropertyRowMapper BeanPropertyRowMapper

Introduction

In this page you can find the example usage for org.springframework.jdbc.core BeanPropertyRowMapper BeanPropertyRowMapper.

Prototype

public BeanPropertyRowMapper() 

Source Link

Document

Create a new BeanPropertyRowMapper for bean-style configuration.

Usage

From source file:com.codekul.simpleboot.repository.RepoImplJdbcUser.java

@Override
public Boolean login(User user) throws Exception {

    BeanPropertyRowMapper<User> rowMapper = new BeanPropertyRowMapper<User>();

    User userFromDb = jdbcTemplate.queryForObject(
            "select * from codekul_user where username = ? and password = ?",
            new Object[] { user.getUserName(), user.getPassword() }, rowMapper);

    return userFromDb != null;
}

From source file:com.branded.holdings.qpc.repository.jdbc.JdbcVetRepositoryImpl.java

/**
 * Refresh the cache of Vets that the ClinicService is holding.
 *
 * @see com.branded.holdings.qpc.model.service.ClinicService#shouldFindVets()
 *///from w ww .jav a 2s.com
@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",
                    BeanPropertyRowMapper.newInstance(Vet.class)));

    // Retrieve the list of all possible specialties.
    final List<Specialty> specialties = this.jdbcTemplate.query("SELECT id, name FROM specialties",
            BeanPropertyRowMapper.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 BeanPropertyRowMapper<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;
}

From source file:com.branded.holdings.qpc.repository.jdbc.JdbcVisitRepositoryImpl.java

@Override
public List<Visit> findByPetId(Integer petId) {
    final List<Visit> visits = this.jdbcTemplate.query(
            "SELECT id, visit_date, description FROM visits WHERE pet_id=?",
            new BeanPropertyRowMapper<Visit>() {
                @Override//from   www .j a  v  a  2 s  .  c om
                public Visit mapRow(ResultSet rs, int row) throws SQLException {
                    Visit visit = new Visit();
                    visit.setId(rs.getInt("id"));
                    Date visitDate = rs.getDate("visit_date");
                    visit.setDate(new DateTime(visitDate));
                    visit.setDescription(rs.getString("description"));
                    return visit;
                }
            }, petId);
    return visits;
}

From source file:com.mx.core.dao.BeanPropRowMap.java

/**
 * Static factory method to create a new BeanPropertyRowMapper
 * (with the mapped class specified only once).
 * @param mappedClass the class that each row should be mapped to
 *///from www. j a  v a 2s .  co  m
public static <T> BeanPropertyRowMapper<T> newInstance(Class<T> mappedClass) {
    BeanPropertyRowMapper<T> newInstance = new BeanPropertyRowMapper<T>();
    newInstance.setMappedClass(mappedClass);
    return newInstance;
}