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(Class<T> mappedClass) 

Source Link

Document

Create a new BeanPropertyRowMapper , accepting unpopulated properties in the target bean.

Usage

From source file:com.anthony.forumspring.dao.TopicsDao.java

@Override
public List<Topics> findByTopicId(int topic_id) {
    String sql = "SELECT * FROM TOPICS where topic_id = " + topic_id;
    return jdbcTemplate.query(sql, new BeanPropertyRowMapper(Topics.class));
}

From source file:org.smigo.species.varieties.JdbcVarietyDao.java

@Override
public Collection<Variety> getVarieties() {
    return jdbcTemplate.query(SELECT, new BeanPropertyRowMapper<>(Variety.class));
}

From source file:com.anthony.forumspring.dao.CommentaireDao.java

@Override
public List<Commentaire> findAllByIdValidation() {
    String sql = "Select * from commentaires where validation = 0";
    return this.jdbcTemplate.query(sql, new BeanPropertyRowMapper(Commentaire.class));
}

From source file:net.noday.d4c.dao.DomainDao.java

public Domain get(Long id) {
    String sql = "select * from domain where id=?";
    return jdbc.queryForObject(sql, new BeanPropertyRowMapper<Domain>(Domain.class), id);
}

From source file:lydichris.smashbracket.persistence.EntrantPersistence.java

public List<Entrant> getEntrantsInTournament(String uuid) {
    String SQL = "select * from entrants where tournament_uuid = ?";
    return jdbcTemplateObject.query(SQL, new BeanPropertyRowMapper(Entrant.class), uuid);
}

From source file:nbadb.DAO.PlayerJDBCTemplate.java

public List<PlayerDAO> findAllPlayerCareerStats(int playerid) {
    String SQL = "SELECT * FROM careervy WHERE playerID=" + playerid + "";

    List<PlayerDAO> players = template.query(SQL, new BeanPropertyRowMapper(PlayerCareerStats.class));

    return players;
}

From source file:org.awesomeagile.dao.DatabaseIntegrationTest.java

@Test
public void testUsers() throws Exception {
    JdbcTemplate jdbcTemplate = testDatabase.jdbcTemplate(DATABASE_NAME);
    List<User> users = jdbcTemplate.query("select * from teams.user", new BeanPropertyRowMapper<>(User.class));
    assertEquals(2, users.size());/*from  w w  w  .  j a v a 2  s  .  c om*/
    assertThat(users, hasItem(new UserWithName("stan")));
}

From source file:org.easybatch.extensions.spring.SpringJdbcRecordMapper.java

@Override
public GenericRecord<P> processRecord(JdbcRecord record) throws RecordMappingException {
    ResultSet resultSet = record.getPayload();
    BeanPropertyRowMapper<P> beanPropertyRowMapper = new BeanPropertyRowMapper<>(type);
    try {//from  w  w w.j  av a2  s .c  om
        return new GenericRecord<>(record.getHeader(),
                beanPropertyRowMapper.mapRow(resultSet, record.getHeader().getNumber().intValue()));
    } catch (SQLException e) {
        throw new RecordMappingException("Unable to map record " + record + " to target type", e);
    }
}

From source file:com.stehno.sjdbcx.reflection.extractor.RowMapperExtractor.java

public RowMapper extract(final Method method) {
    final com.stehno.sjdbcx.annotation.RowMapper mapper = AnnotationUtils.getAnnotation(method,
            com.stehno.sjdbcx.annotation.RowMapper.class);
    if (mapper == null) {
        Class mappedType = method.getReturnType();

        if (Collection.class.isAssignableFrom(mappedType)) {
            mappedType = (Class) ((ParameterizedType) method.getGenericReturnType())
                    .getActualTypeArguments()[0];

        } else if (mappedType.isArray()) {
            throw new UnsupportedOperationException("Auto-mapping for array return types is not yet supported");

        } else if (mappedType.isPrimitive()) {
            if (mappedType == int.class || mappedType == long.class) {
                return new SingleColumnRowMapper();

            } else if (mappedType == boolean.class) {
                return new RowMapper<Boolean>() {
                    @Override//w w  w  .  ja  va  2 s  . c  om
                    public Boolean mapRow(final ResultSet resultSet, final int i) throws SQLException {
                        return resultSet.getBoolean(1);
                    }
                };
            }
        }

        return new BeanPropertyRowMapper(mappedType);

    } else {
        final String extractKey = mapper.value();
        if (StringUtils.isEmpty(extractKey)) {
            return resolve((Class<RowMapper>) mapper.type());
        } else {
            return resolve(extractKey);
        }
    }
}

From source file:org.smigo.species.varieties.JdbcVarietyDao.java

@Override
public Variety getVarietiesById(int id) {
    final String select = SELECT + " WHERE ID = ?";
    return jdbcTemplate.queryForObject(select, new Object[] { id }, new BeanPropertyRowMapper<>(Variety.class));
}