List of usage examples for org.springframework.jdbc.core BeanPropertyRowMapper newInstance
public static <T> BeanPropertyRowMapper<T> newInstance(Class<T> mappedClass)
From source file:com.branded.holdings.qpc.repository.jdbc.JdbcOwnerRepositoryImpl.java
public Collection<PetType> getPetTypes() throws DataAccessException { return this.namedParameterJdbcTemplate.query("SELECT id, name FROM types ORDER BY name", new HashMap<String, Object>(), BeanPropertyRowMapper.newInstance(PetType.class)); }
From source file:com.wandrell.pattern.repository.spring.SpringJdbcRepository.java
/** * Returns all the entities contained in the repository. * <p>//w w w .j a v a2 s . co m * The query used for this operation just queries the table received by the * constructor. * * @return all the entities contained in the repository */ @Override public final Collection<V> getAll() { return getTemplate().query(getSelectAllValuesQuery(), BeanPropertyRowMapper.newInstance(getType())); }
From source file:com.wandrell.pattern.repository.spring.SpringJdbcRepository.java
/** * Queries the entities in the repository and returns a subset of them. * <p>/*from ww w . jav a 2 s .com*/ * The collection is created by building a query from the received * {@code QueryData} and executing it. * * @param query * the query user to acquire the entities * @return the queried subset of entities */ @Override public final Collection<V> getCollection(final NamedParameterQueryData query) { checkNotNull(query, "Received a null pointer as the query"); return getTemplate().query(query.getQuery(), query.getParameters(), BeanPropertyRowMapper.newInstance(getType())); }
From source file:com.wandrell.pattern.repository.spring.SpringJdbcRepository.java
/** * Queries the entities in the repository and returns a single one. * <p>/* w ww . ja va 2s .c om*/ * The entity is acquired by building a query from the received * {@code QueryData} and executing it. * * @param query * the query user to acquire the entities * @return the queried entity */ @Override public final V getEntity(final NamedParameterQueryData query) { V entity; // Entity acquired from the query checkNotNull(query, "Received a null pointer as the query"); // Tries to acquire the entity try { entity = getTemplate().queryForObject(query.getQuery(), query.getParameters(), BeanPropertyRowMapper.newInstance(getType())); } catch (final EmptyResultDataAccessException exception) { entity = null; } return entity; }
From source file:org.mi.core.common.jdbc.QueryPageExt.java
private <T> List<T> query(String corentsql, Object[] params, Class<T> dtoEntity, PagedJdbcTemplate pagedJdbcTemplate) { return pagedJdbcTemplate.query(corentsql, params, BeanPropertyRowMapper.newInstance(dtoEntity)); }
From source file:ru.org.linux.site.Message.java
public List<EditInfoDTO> loadEditInfo(Connection db) { SingleConnectionDataSource scds = new SingleConnectionDataSource(db, true); SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(scds); List<EditInfoDTO> list = jdbcTemplate.query("SELECT * FROM edit_info WHERE msgid=? ORDER BY id DESC", BeanPropertyRowMapper.newInstance(EditInfoDTO.class), msgid); return ImmutableList.copyOf(list); }
From source file:ru.org.linux.topic.TopicDao.java
public List<EditInfoDto> loadEditInfo(int msgid) { List<EditInfoDto> list = jdbcTemplate.query("SELECT * FROM edit_info WHERE msgid=? ORDER BY id DESC", BeanPropertyRowMapper.newInstance(EditInfoDto.class), msgid); return ImmutableList.copyOf(list); }