Skip to content

Commit 7d5b389

Browse files
committed
Add since 7.0 tags for stream methods
See gh-34623
1 parent 8819c74 commit 7d5b389

File tree

1 file changed

+17
-10
lines changed
  • spring-jdbc/src/main/java/org/springframework/jdbc/object

1 file changed

+17
-10
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlQuery.java

+17-10
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public List<T> execute(Object @Nullable [] params, @Nullable Map<?, ?> context)
108108
* but it can be useful for creating the objects of the result list.
109109
* @return a result Stream of objects, one per row of the ResultSet. Normally all these
110110
* will be of the same class, although it is possible to use different types.
111+
* @since 7.0
111112
*/
112113
public Stream<T> stream(Object @Nullable [] params, @Nullable Map<?, ?> context) throws DataAccessException {
113114
validateParameters(params);
@@ -130,6 +131,7 @@ public List<T> execute(Object... params) throws DataAccessException {
130131
* @param params parameters for the query. Primitive parameters must
131132
* be represented by their Object wrapper type. The ordering of parameters is
132133
* significant.
134+
* @since 7.0
133135
*/
134136
public Stream<T> stream(Object... params) throws DataAccessException {
135137
return stream(params, null);
@@ -146,6 +148,7 @@ public List<T> execute(Map<?, ?> context) throws DataAccessException {
146148
/**
147149
* Convenient method to stream without parameters.
148150
* @param context the contextual information for object creation
151+
* @since 7.0
149152
*/
150153
public Stream<T> stream(Map<?, ?> context) throws DataAccessException {
151154
return stream(null, context);
@@ -160,6 +163,7 @@ public List<T> execute() throws DataAccessException {
160163

161164
/**
162165
* Convenient method to stream without parameters nor context.
166+
* @since 7.0
163167
*/
164168
public Stream<T> stream() throws DataAccessException {
165169
return stream(null, null);
@@ -262,6 +266,7 @@ public List<T> executeByNamedParam(Map<String, ?> paramMap, @Nullable Map<?, ?>
262266
* but it can be useful for creating the objects of the result list.
263267
* @return a Stream of objects, one per row of the ResultSet. Normally all these
264268
* will be of the same class, although it is possible to use different types.
269+
* @since 7.0
265270
*/
266271
public Stream<T> streamByNamedParam(Map<String, ?> paramMap, @Nullable Map<?, ?> context) throws DataAccessException {
267272
return queryByNamedParam(paramMap, context, getJdbcTemplate()::queryForStream);
@@ -282,11 +287,23 @@ public List<T> executeByNamedParam(Map<String, ? extends @Nullable Object> param
282287
* @param paramMap parameters associated with the name specified while declaring
283288
* the SqlParameters. Primitive parameters must be represented by their Object wrapper
284289
* type. The ordering of parameters is not significant.
290+
* @since 7.0
285291
*/
286292
public Stream<T> streamByNamedParam(Map<String, ? extends @Nullable Object> paramMap) throws DataAccessException {
287293
return streamByNamedParam(paramMap, null);
288294
}
289295

296+
private <R> R queryByNamedParam(Map<String, ?> paramMap, @Nullable Map<?, ?> context, BiFunction<PreparedStatementCreator, RowMapper<T>, R> queryFunction) {
297+
validateNamedParameters(paramMap);
298+
ParsedSql parsedSql = getParsedSql();
299+
MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
300+
String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
301+
@Nullable Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
302+
RowMapper<T> rowMapper = newRowMapper(params, context);
303+
return queryFunction.apply(newPreparedStatementCreator(sqlToUse, params), rowMapper);
304+
}
305+
306+
290307
/**
291308
* Generic object finder method, used by all other {@code findObject} methods.
292309
* Object finder methods are like EJB entity bean finders, in that it is
@@ -407,14 +424,4 @@ public Stream<T> streamByNamedParam(Map<String, ? extends @Nullable Object> para
407424
*/
408425
protected abstract RowMapper<T> newRowMapper(@Nullable Object @Nullable [] parameters, @Nullable Map<?, ?> context);
409426

410-
private <R> R queryByNamedParam(Map<String, ?> paramMap, @Nullable Map<?, ?> context, BiFunction<PreparedStatementCreator, RowMapper<T>, R> queryFunction) {
411-
validateNamedParameters(paramMap);
412-
ParsedSql parsedSql = getParsedSql();
413-
MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
414-
String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
415-
@Nullable Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
416-
RowMapper<T> rowMapper = newRowMapper(params, context);
417-
return queryFunction.apply(newPreparedStatementCreator(sqlToUse, params), rowMapper);
418-
}
419-
420427
}

0 commit comments

Comments
 (0)