Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
import org.springframework.dao.DataAccessException;
import org.springframework.dao.support.DataAccessUtils;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.RowMapperResultSetExtractor;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterUtils;
import org.springframework.jdbc.core.namedparam.ParsedSql;
import org.springframework.util.Assert;

/**
* Reusable operation object representing an SQL query.
Expand Down Expand Up @@ -112,7 +114,10 @@ public int getRowsExpected() {
public List<T> execute(Object @Nullable [] params, @Nullable Map<?, ?> context) throws DataAccessException {
validateParameters(params);
RowMapper<T> rowMapper = newRowMapper(params, context);
return getJdbcTemplate().query(newPreparedStatementCreator(params), rowMapper);
List<T> result = getJdbcTemplate().query(newPreparedStatementCreator(params),
new RowMapperResultSetExtractor<>(rowMapper, getRowsExpected()));
Assert.state(result != null, "No result");
return result;
}

/**
Expand Down Expand Up @@ -229,7 +234,10 @@ public List<T> executeByNamedParam(Map<String, ?> paramMap, @Nullable Map<?, ?>
String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
@Nullable Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
RowMapper<T> rowMapper = newRowMapper(params, context);
return getJdbcTemplate().query(newPreparedStatementCreator(sqlToUse, params), rowMapper);
List<T> result = getJdbcTemplate().query(newPreparedStatementCreator(sqlToUse, params),
new RowMapperResultSetExtractor<>(rowMapper, getRowsExpected()));
Assert.state(result != null, "No result");
return result;
}

/**
Expand Down