use of org.springframework.jdbc.core.BeanPropertyRowMapper in project camel by apache.
the class DefaultSqlEndpoint method queryForStreamList.
@SuppressWarnings("unchecked")
public ResultSetIterator queryForStreamList(Connection connection, Statement statement, ResultSet rs) throws SQLException {
if (outputClass == null) {
RowMapper rowMapper = new ColumnMapRowMapper();
return new ResultSetIterator(connection, statement, rs, rowMapper);
} else {
Class<?> outputClzz = getCamelContext().getClassResolver().resolveClass(outputClass);
RowMapper rowMapper = new BeanPropertyRowMapper(outputClzz);
return new ResultSetIterator(connection, statement, rs, rowMapper);
}
}
use of org.springframework.jdbc.core.BeanPropertyRowMapper in project camel by apache.
the class DefaultSqlEndpoint method queryForObject.
@SuppressWarnings("unchecked")
public Object queryForObject(ResultSet rs) throws SQLException {
Object result = null;
if (outputClass == null) {
RowMapper rowMapper = new ColumnMapRowMapper();
RowMapperResultSetExtractor<Map<String, Object>> mapper = new RowMapperResultSetExtractor<Map<String, Object>>(rowMapper);
List<Map<String, Object>> data = mapper.extractData(rs);
if (data.size() > 1) {
throw new SQLDataException("Query result not unique for outputType=SelectOne. Got " + data.size() + " count instead.");
} else if (data.size() == 1) {
// Set content depend on number of column from query result
Map<String, Object> row = data.get(0);
if (row.size() == 1) {
result = row.values().iterator().next();
} else {
result = row;
}
}
} else {
Class<?> outputClzz = getCamelContext().getClassResolver().resolveClass(outputClass);
RowMapper rowMapper = new BeanPropertyRowMapper(outputClzz);
RowMapperResultSetExtractor<?> mapper = new RowMapperResultSetExtractor(rowMapper);
List<?> data = mapper.extractData(rs);
if (data.size() > 1) {
throw new SQLDataException("Query result not unique for outputType=SelectOne. Got " + data.size() + " count instead.");
} else if (data.size() == 1) {
result = data.get(0);
}
}
// If data.size is zero, let result be null.
return result;
}
use of org.springframework.jdbc.core.BeanPropertyRowMapper in project camel by apache.
the class DefaultSqlEndpoint method queryForList.
@SuppressWarnings("unchecked")
public List<?> queryForList(ResultSet rs, boolean allowMapToClass) throws SQLException {
if (allowMapToClass && outputClass != null) {
Class<?> outputClazz = getCamelContext().getClassResolver().resolveClass(outputClass);
RowMapper rowMapper = new BeanPropertyRowMapper(outputClazz);
RowMapperResultSetExtractor<?> mapper = new RowMapperResultSetExtractor(rowMapper);
List<?> data = mapper.extractData(rs);
return data;
} else {
ColumnMapRowMapper rowMapper = new ColumnMapRowMapper();
RowMapperResultSetExtractor<Map<String, Object>> mapper = new RowMapperResultSetExtractor<Map<String, Object>>(rowMapper);
List<Map<String, Object>> data = mapper.extractData(rs);
return data;
}
}
use of org.springframework.jdbc.core.BeanPropertyRowMapper in project Gargoyle by callakrsos.
the class MacroFavorDAO method getRoots.
/**
* 루트 데이터 리턴
*
* @inheritDoc
*/
public List<MacroItemVO> getRoots() throws Exception {
List<MacroItemVO> select = Collections.emptyList();
try (Connection connection = getConnection()) {
String sql = "select * from meerkat.tbm_sys_fav_macro_sql where parent_macro_id is null";
select = DbUtil.select(connection, sql, 10, new BeanPropertyRowMapper<>(MacroItemVO.class));
}
System.out.println(select);
return select;
}
Aggregations