Java Code Examples for org.springframework.jdbc.core.RowMapperResultSetExtractor

The following examples show how to use org.springframework.jdbc.core.RowMapperResultSetExtractor. These examples are extracted from open source projects. 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 Project: compass   Source File: ShardJdbcTemplate.java    License: Apache License 2.0 7 votes vote down vote up
@SuppressWarnings("rawtypes")
private ShardOperationProcessor<List> getNonAggregationProcessor(final RowMapper rowMapper) {
       final List<QueryCallable<List>> callableList = new ArrayList<ShardJdbcTemplate.QueryCallable<List>>();

       ShardOperationProcessor<List> processor = new ShardOperationProcessor<List>() {
           @SuppressWarnings("unchecked")
		@Override
           public void addOperation(Shard shard, String sql, Object[] args) {
               ResultSetExtractor extractor = new RowMapperResultSetExtractor(rowMapper);
               QueryCallable<List> callable = new QueryCallable<List>(shard, sql, args, extractor);

               callableList.add(callable);
           }

		@Override
           public List processOperations() {
               List<List> rawResultList = ShardJdbcTemplate.this.executeQuery(callableList);
               return AggregationUtil.aggregateObjectList(rawResultList);
           }
       };

       return processor;
   }
 
Example 2
Source Project: opscenter   Source File: ProcedureJdbcTemplate.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 创建结果集列表
 * @param cstmt
 * @param rs
 * @return List<List<Map<String, Object>>>
 * @throws IOException
 */
public List<List<Map<String, Object>>> createRows(PreparedStatement ps, ResultSet rs) throws IOException{
	List<List<Map<String, Object>>> list = new ArrayList<>();
	RowMapperResultSetExtractor<Map<String, Object>> rse = new RowMapperResultSetExtractor<>(new ColumnMapRowMapper());
	boolean label = true;
	int health = 0;
	while(label){
		try {
			rs=ps.getResultSet();
			if(rs !=null){
				list.add(rse.extractData(rs));
		    	label = ps.getMoreResults();
		    	health++;
		    	if(health > MAX_LOOP) break;
				continue;
		    }
		    label = false;
		} catch (SQLException e) {
			label = false;
		}
	}
	return list;
}
 
Example 3
private <T> T selectRecipients(@VelocityCheck int companyID, RowMapper<T> mapper, String sqlStatement, Object... sqlParameters) throws SQLException {
	List<T> results = selectRecipients(companyID, new RowMapperResultSetExtractor<>(mapper, 1), sqlStatement, sqlParameters);
	return DataAccessUtils.singleResult(results);
}