@@ -108,6 +108,7 @@ public List<T> execute(Object @Nullable [] params, @Nullable Map<?, ?> context)
108
108
* but it can be useful for creating the objects of the result list.
109
109
* @return a result Stream of objects, one per row of the ResultSet. Normally all these
110
110
* will be of the same class, although it is possible to use different types.
111
+ * @since 7.0
111
112
*/
112
113
public Stream <T > stream (Object @ Nullable [] params , @ Nullable Map <?, ?> context ) throws DataAccessException {
113
114
validateParameters (params );
@@ -130,6 +131,7 @@ public List<T> execute(Object... params) throws DataAccessException {
130
131
* @param params parameters for the query. Primitive parameters must
131
132
* be represented by their Object wrapper type. The ordering of parameters is
132
133
* significant.
134
+ * @since 7.0
133
135
*/
134
136
public Stream <T > stream (Object ... params ) throws DataAccessException {
135
137
return stream (params , null );
@@ -146,6 +148,7 @@ public List<T> execute(Map<?, ?> context) throws DataAccessException {
146
148
/**
147
149
* Convenient method to stream without parameters.
148
150
* @param context the contextual information for object creation
151
+ * @since 7.0
149
152
*/
150
153
public Stream <T > stream (Map <?, ?> context ) throws DataAccessException {
151
154
return stream (null , context );
@@ -160,6 +163,7 @@ public List<T> execute() throws DataAccessException {
160
163
161
164
/**
162
165
* Convenient method to stream without parameters nor context.
166
+ * @since 7.0
163
167
*/
164
168
public Stream <T > stream () throws DataAccessException {
165
169
return stream (null , null );
@@ -262,6 +266,7 @@ public List<T> executeByNamedParam(Map<String, ?> paramMap, @Nullable Map<?, ?>
262
266
* but it can be useful for creating the objects of the result list.
263
267
* @return a Stream of objects, one per row of the ResultSet. Normally all these
264
268
* will be of the same class, although it is possible to use different types.
269
+ * @since 7.0
265
270
*/
266
271
public Stream <T > streamByNamedParam (Map <String , ?> paramMap , @ Nullable Map <?, ?> context ) throws DataAccessException {
267
272
return queryByNamedParam (paramMap , context , getJdbcTemplate ()::queryForStream );
@@ -282,11 +287,23 @@ public List<T> executeByNamedParam(Map<String, ? extends @Nullable Object> param
282
287
* @param paramMap parameters associated with the name specified while declaring
283
288
* the SqlParameters. Primitive parameters must be represented by their Object wrapper
284
289
* type. The ordering of parameters is not significant.
290
+ * @since 7.0
285
291
*/
286
292
public Stream <T > streamByNamedParam (Map <String , ? extends @ Nullable Object > paramMap ) throws DataAccessException {
287
293
return streamByNamedParam (paramMap , null );
288
294
}
289
295
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
+
290
307
/**
291
308
* Generic object finder method, used by all other {@code findObject} methods.
292
309
* 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
407
424
*/
408
425
protected abstract RowMapper <T > newRowMapper (@ Nullable Object @ Nullable [] parameters , @ Nullable Map <?, ?> context );
409
426
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
-
420
427
}
0 commit comments