org.springframework.jdbc.core.SingleColumnRowMapper Java Examples

The following examples show how to use org.springframework.jdbc.core.SingleColumnRowMapper. 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
Source File: ReportDao.java    From maestro-java with Apache License 2.0 6 votes vote down vote up
public int getLastTestId() {
    try {
        Integer ret = runQuery("select MAX(test_id) from report",
                new SingleColumnRowMapper<>(Integer.class));

        if (ret == null) {
            return -1;
        }

        return ret.intValue();
    }
    catch (DataNotFoundException e) {
        logger.warn("The query runner returned data not found. Returning -1 as the next test ID");

        return -1;
    }
}
 
Example #2
Source File: ReportDao.java    From maestro-java with Apache License 2.0 6 votes vote down vote up
public int getLastTestNumber(int testId) {
    try {
        Integer ret = runQuery("select MAX(test_number) from report where test_id = ?",
                new SingleColumnRowMapper<>(Integer.class),
                testId);

        if (ret == null) {
            return -1;
        }

        return ret.intValue();
    }
    catch (DataNotFoundException e) {
        logger.warn("The query runner returned data not found. Returning -1 as the next test number");

        return -1;
    }
}
 
Example #3
Source File: NamedParameterJdbcTemplate.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
@Nullable
public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramMap, new SingleColumnRowMapper<>(requiredType));
}
 
Example #4
Source File: NamedParameterJdbcTemplate.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
@Nullable
public <T> T queryForObject(String sql, SqlParameterSource paramSource, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramSource, new SingleColumnRowMapper<>(requiredType));
}
 
Example #5
Source File: NamedParameterJdbcTemplate.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
@Nullable
public <T> T queryForObject(String sql, SqlParameterSource paramSource, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramSource, new SingleColumnRowMapper<>(requiredType));
}
 
Example #6
Source File: NamedParameterJdbcTemplate.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
@Nullable
public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramMap, new SingleColumnRowMapper<>(requiredType));
}
 
Example #7
Source File: DdlUtils.java    From DataLink with Apache License 2.0 5 votes vote down vote up
/**
 * !!! Only supports MySQL
 */
@SuppressWarnings("unchecked")
public static List<String> findSchemas(JdbcTemplate jdbcTemplate, final String schemaPattern) {
    try {
        if (StringUtils.isEmpty(schemaPattern)) {
            return jdbcTemplate.query("show databases", new SingleColumnRowMapper(String.class));
        }
        return jdbcTemplate.query("show databases like ?",
                new Object[]{schemaPattern},
                new SingleColumnRowMapper(String.class));
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return new ArrayList<String>();
    }
}
 
Example #8
Source File: DaoImpl.java    From x7 with Apache License 2.0 5 votes vote down vote up
private <K> List<K> queryForPlainValueList(Class<K> clzz, String sql, Criteria.ResultMappedCriteria resultMappedCriteria, Dialect dialect, JdbcTemplate jdbcTemplate) {

        List<Object> valueList = resultMappedCriteria.getValueList();

        if (valueList == null || valueList.isEmpty()) {
            return this.jdbcTemplate.query(sql, new SingleColumnRowMapper<>(clzz));
        }else {
            Object[] arr = dialect.toArr(valueList);
            return this.jdbcTemplate.query(sql, arr,
                    new SingleColumnRowMapper<>(clzz));
        }
    }
 
Example #9
Source File: NamedParameterJdbcTemplate.java    From effectivejava with Apache License 2.0 4 votes vote down vote up
@Override
public <T> List<T> queryForList(String sql, SqlParameterSource paramSource, Class<T> elementType)
		throws DataAccessException {

	return query(sql, paramSource, new SingleColumnRowMapper<T>(elementType));
}
 
Example #10
Source File: NamedParameterJdbcTemplate.java    From effectivejava with Apache License 2.0 4 votes vote down vote up
@Override
public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramMap, new SingleColumnRowMapper<T>(requiredType));
}
 
Example #11
Source File: NamedParameterJdbcTemplate.java    From effectivejava with Apache License 2.0 4 votes vote down vote up
@Override
public <T> T queryForObject(String sql, SqlParameterSource paramSource, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramSource, new SingleColumnRowMapper<T>(requiredType));
}
 
Example #12
Source File: AddressPrinterJobConfiguration.java    From spring-batch-lightmin with Apache License 2.0 4 votes vote down vote up
@Bean
public JdbcCursorItemReader<Long> addressBatchTaskDeletionReader(final DataSource dataSource) throws Exception {
    final JdbcCursorItemReader<Long> reader = new JdbcCursorItemReader<>();
    reader.setSql(SELECT_BATCH_TASK_ADDRESS_TO_DELETE_QUERY);
    reader.setRowMapper(new SingleColumnRowMapper<>());
    reader.setDataSource(dataSource);
    reader.setMaxRows(50);
    reader.afterPropertiesSet();
    return reader;
}
 
Example #13
Source File: AddressPrinterJobConfiguration.java    From spring-batch-lightmin with Apache License 2.0 4 votes vote down vote up
@Bean
public JdbcCursorItemReader<Long> addressPrinterReader(final DataSource dataSource) throws Exception {
    final JdbcCursorItemReader<Long> reader = new JdbcCursorItemReader<>();
    reader.setSql(SELECT_ADDRESS_QUERY);
    reader.setRowMapper(new SingleColumnRowMapper<>());
    reader.setDataSource(dataSource);
    reader.setMaxRows(100);
    reader.afterPropertiesSet();
    return reader;
}
 
Example #14
Source File: NamedParameterJdbcTemplate.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public <T> List<T> queryForList(String sql, SqlParameterSource paramSource, Class<T> elementType)
		throws DataAccessException {

	return query(sql, paramSource, new SingleColumnRowMapper<T>(elementType));
}
 
Example #15
Source File: NamedParameterJdbcTemplate.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramMap, new SingleColumnRowMapper<T>(requiredType));
}
 
Example #16
Source File: NamedParameterJdbcTemplate.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public <T> T queryForObject(String sql, SqlParameterSource paramSource, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramSource, new SingleColumnRowMapper<T>(requiredType));
}
 
Example #17
Source File: NamedParameterJdbcTemplate.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> List<T> queryForList(String sql, SqlParameterSource paramSource, Class<T> elementType)
		throws DataAccessException {

	return query(sql, paramSource, new SingleColumnRowMapper<T>(elementType));
}
 
Example #18
Source File: NamedParameterJdbcTemplate.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramMap, new SingleColumnRowMapper<T>(requiredType));
}
 
Example #19
Source File: NamedParameterJdbcTemplate.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public <T> T queryForObject(String sql, SqlParameterSource paramSource, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramSource, new SingleColumnRowMapper<T>(requiredType));
}
 
Example #20
Source File: NamedParameterJdbcTemplate.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public <T> List<T> queryForList(String sql, SqlParameterSource paramSource, Class<T> elementType)
		throws DataAccessException {

	return query(sql, paramSource, new SingleColumnRowMapper<>(elementType));
}
 
Example #21
Source File: ComRecipientDaoImpl.java    From openemm with GNU Affero General Public License v3.0 4 votes vote down vote up
private <T> T selectRecipients(@VelocityCheck int companyID, Class<T> type, String sqlStatement, Object... sqlParameters) throws SQLException {
	return selectRecipients(companyID, new SingleColumnRowMapper<>(type), sqlStatement, sqlParameters);
}
 
Example #22
Source File: NamedParameterJdbcTemplate.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public <T> List<T> queryForList(String sql, SqlParameterSource paramSource, Class<T> elementType)
		throws DataAccessException {

	return query(sql, paramSource, new SingleColumnRowMapper<>(elementType));
}