@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2018 the original author or authors .
* Copyright 2002 - 2020 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -18,6 +18,7 @@ package org.springframework.jdbc.core.namedparam;
@@ -18,6 +18,7 @@ package org.springframework.jdbc.core.namedparam;
import java.util.List ;
import java.util.Map ;
import java.util.stream.Stream ;
import org.springframework.dao.DataAccessException ;
import org.springframework.jdbc.core.JdbcOperations ;
@ -130,7 +131,7 @@ public interface NamedParameterJdbcOperations {
@@ -130,7 +131,7 @@ public interface NamedParameterJdbcOperations {
* ( leaving it to the PreparedStatement to guess the corresponding SQL type )
* @param rse object that will extract results
* @return an arbitrary result object , as returned by the ResultSetExtractor
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* /
@Nullable
< T > T query ( String sql , Map < String , ? > paramMap , ResultSetExtractor < T > rse )
@ -145,7 +146,7 @@ public interface NamedParameterJdbcOperations {
@@ -145,7 +146,7 @@ public interface NamedParameterJdbcOperations {
* @param sql the SQL query to execute
* @param rse object that will extract results
* @return an arbitrary result object , as returned by the ResultSetExtractor
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* /
@Nullable
< T > T query ( String sql , ResultSetExtractor < T > rse ) throws DataAccessException ;
@ -170,7 +171,7 @@ public interface NamedParameterJdbcOperations {
@@ -170,7 +171,7 @@ public interface NamedParameterJdbcOperations {
* @param paramMap map of parameters to bind to the query
* ( leaving it to the PreparedStatement to guess the corresponding SQL type )
* @param rch object that will extract results , one row at a time
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* /
void query ( String sql , Map < String , ? > paramMap , RowCallbackHandler rch ) throws DataAccessException ;
@ -182,7 +183,7 @@ public interface NamedParameterJdbcOperations {
@@ -182,7 +183,7 @@ public interface NamedParameterJdbcOperations {
* equivalent to a query call with an empty parameter Map .
* @param sql the SQL query to execute
* @param rch object that will extract results , one row at a time
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* /
void query ( String sql , RowCallbackHandler rch ) throws DataAccessException ;
@ -194,7 +195,7 @@ public interface NamedParameterJdbcOperations {
@@ -194,7 +195,7 @@ public interface NamedParameterJdbcOperations {
* @param paramSource container of arguments to bind to the query
* @param rowMapper object that will map one object per row
* @return the result List , containing mapped objects
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* /
< T > List < T > query ( String sql , SqlParameterSource paramSource , RowMapper < T > rowMapper )
throws DataAccessException ;
@ -208,7 +209,7 @@ public interface NamedParameterJdbcOperations {
@@ -208,7 +209,7 @@ public interface NamedParameterJdbcOperations {
* ( leaving it to the PreparedStatement to guess the corresponding SQL type )
* @param rowMapper object that will map one object per row
* @return the result List , containing mapped objects
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* /
< T > List < T > query ( String sql , Map < String , ? > paramMap , RowMapper < T > rowMapper )
throws DataAccessException ;
@ -222,10 +223,41 @@ public interface NamedParameterJdbcOperations {
@@ -222,10 +223,41 @@ public interface NamedParameterJdbcOperations {
* @param sql the SQL query to execute
* @param rowMapper object that will map one object per row
* @return the result List , containing mapped objects
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* /
< T > List < T > query ( String sql , RowMapper < T > rowMapper ) throws DataAccessException ;
/ * *
* Query given SQL to create a prepared statement from SQL and a list
* of arguments to bind to the query , mapping each row to a Java object
* via a RowMapper , and turning it into an iterable and closeable Stream .
* @param sql the SQL query to execute
* @param paramSource container of arguments to bind to the query
* @param rowMapper object that will map one object per row
* @return the result Stream , containing mapped objects , needing to be
* closed once fully processed ( e . g . through a try - with - resources clause )
* @throws DataAccessException if the query fails
* @since 5 . 3
* /
< T > Stream < T > queryForStream ( String sql , SqlParameterSource paramSource , RowMapper < T > rowMapper )
throws DataAccessException ;
/ * *
* Query given SQL to create a prepared statement from SQL and a list
* of arguments to bind to the query , mapping each row to a Java object
* via a RowMapper , and turning it into an iterable and closeable Stream .
* @param sql the SQL query to execute
* @param paramMap map of parameters to bind to the query
* ( leaving it to the PreparedStatement to guess the corresponding SQL type )
* @param rowMapper object that will map one object per row
* @return the result Stream , containing mapped objects , needing to be
* closed once fully processed ( e . g . through a try - with - resources clause )
* @throws DataAccessException if the query fails
* @since 5 . 3
* /
< T > Stream < T > queryForStream ( String sql , Map < String , ? > paramMap , RowMapper < T > rowMapper )
throws DataAccessException ;
/ * *
* Query given SQL to create a prepared statement from SQL and a list
* of arguments to bind to the query , mapping a single result row to a
@ -238,7 +270,7 @@ public interface NamedParameterJdbcOperations {
@@ -238,7 +270,7 @@ public interface NamedParameterJdbcOperations {
* @throws org . springframework . dao . IncorrectResultSizeDataAccessException
* if the query does not return exactly one row , or does not return exactly
* one column in that row
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* /
@Nullable
< T > T queryForObject ( String sql , SqlParameterSource paramSource , RowMapper < T > rowMapper )
@ -257,7 +289,7 @@ public interface NamedParameterJdbcOperations {
@@ -257,7 +289,7 @@ public interface NamedParameterJdbcOperations {
* @throws org . springframework . dao . IncorrectResultSizeDataAccessException
* if the query does not return exactly one row , or does not return exactly
* one column in that row
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* /
@Nullable
< T > T queryForObject ( String sql , Map < String , ? > paramMap , RowMapper < T > rowMapper )
@ -275,7 +307,7 @@ public interface NamedParameterJdbcOperations {
@@ -275,7 +307,7 @@ public interface NamedParameterJdbcOperations {
* @throws org . springframework . dao . IncorrectResultSizeDataAccessException
* if the query does not return exactly one row , or does not return exactly
* one column in that row
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* @see org . springframework . jdbc . core . JdbcTemplate # queryForObject ( String , Class )
* /
@Nullable
@ -295,7 +327,7 @@ public interface NamedParameterJdbcOperations {
@@ -295,7 +327,7 @@ public interface NamedParameterJdbcOperations {
* @throws org . springframework . dao . IncorrectResultSizeDataAccessException
* if the query does not return exactly one row , or does not return exactly
* one column in that row
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* @see org . springframework . jdbc . core . JdbcTemplate # queryForObject ( String , Class )
* /
@Nullable
@ -312,7 +344,7 @@ public interface NamedParameterJdbcOperations {
@@ -312,7 +344,7 @@ public interface NamedParameterJdbcOperations {
* @return the result Map ( one entry for each column , using the column name as the key )
* @throws org . springframework . dao . IncorrectResultSizeDataAccessException
* if the query does not return exactly one row
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* @see org . springframework . jdbc . core . JdbcTemplate # queryForMap ( String )
* @see org . springframework . jdbc . core . ColumnMapRowMapper
* /
@ -332,7 +364,7 @@ public interface NamedParameterJdbcOperations {
@@ -332,7 +364,7 @@ public interface NamedParameterJdbcOperations {
* @return the result Map ( one entry for each column , using the column name as the key )
* @throws org . springframework . dao . IncorrectResultSizeDataAccessException
* if the query does not return exactly one row
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* @see org . springframework . jdbc . core . JdbcTemplate # queryForMap ( String )
* @see org . springframework . jdbc . core . ColumnMapRowMapper
* /
@ -348,7 +380,7 @@ public interface NamedParameterJdbcOperations {
@@ -348,7 +380,7 @@ public interface NamedParameterJdbcOperations {
* @param elementType the required type of element in the result list
* ( for example , { @code Integer . class } )
* @return a List of objects that match the specified element type
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* @see org . springframework . jdbc . core . JdbcTemplate # queryForList ( String , Class )
* @see org . springframework . jdbc . core . SingleColumnRowMapper
* /
@ -366,7 +398,7 @@ public interface NamedParameterJdbcOperations {
@@ -366,7 +398,7 @@ public interface NamedParameterJdbcOperations {
* @param elementType the required type of element in the result list
* ( for example , { @code Integer . class } )
* @return a List of objects that match the specified element type
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* @see org . springframework . jdbc . core . JdbcTemplate # queryForList ( String , Class )
* @see org . springframework . jdbc . core . SingleColumnRowMapper
* /
@ -383,7 +415,7 @@ public interface NamedParameterJdbcOperations {
@@ -383,7 +415,7 @@ public interface NamedParameterJdbcOperations {
* @param sql the SQL query to execute
* @param paramSource container of arguments to bind to the query
* @return a List that contains a Map per row
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* @see org . springframework . jdbc . core . JdbcTemplate # queryForList ( String )
* /
List < Map < String , Object > > queryForList ( String sql , SqlParameterSource paramSource ) throws DataAccessException ;
@ -399,7 +431,7 @@ public interface NamedParameterJdbcOperations {
@@ -399,7 +431,7 @@ public interface NamedParameterJdbcOperations {
* @param paramMap map of parameters to bind to the query
* ( leaving it to the PreparedStatement to guess the corresponding SQL type )
* @return a List that contains a Map per row
* @throws org . springframework . dao . DataAccessException if the query fails
* @throws DataAccessException if the query fails
* @see org . springframework . jdbc . core . JdbcTemplate # queryForList ( String )
* /
List < Map < String , Object > > queryForList ( String sql , Map < String , ? > paramMap ) throws DataAccessException ;
@ -417,7 +449,7 @@ public interface NamedParameterJdbcOperations {
@@ -417,7 +449,7 @@ public interface NamedParameterJdbcOperations {
* @param paramSource container of arguments to bind to the query
* @return an SqlRowSet representation ( possibly a wrapper around a
* { @code javax . sql . rowset . CachedRowSet } )
* @throws org . springframework . dao . DataAccessException if there is any problem executing the query
* @throws DataAccessException if there is any problem executing the query
* @see org . springframework . jdbc . core . JdbcTemplate # queryForRowSet ( String )
* @see org . springframework . jdbc . core . SqlRowSetResultSetExtractor
* @see javax . sql . rowset . CachedRowSet
@ -438,7 +470,7 @@ public interface NamedParameterJdbcOperations {
@@ -438,7 +470,7 @@ public interface NamedParameterJdbcOperations {
* ( leaving it to the PreparedStatement to guess the corresponding SQL type )
* @return an SqlRowSet representation ( possibly a wrapper around a
* { @code javax . sql . rowset . CachedRowSet } )
* @throws org . springframework . dao . DataAccessException if there is any problem executing the query
* @throws DataAccessException if there is any problem executing the query
* @see org . springframework . jdbc . core . JdbcTemplate # queryForRowSet ( String )
* @see org . springframework . jdbc . core . SqlRowSetResultSetExtractor
* @see javax . sql . rowset . CachedRowSet
@ -450,7 +482,7 @@ public interface NamedParameterJdbcOperations {
@@ -450,7 +482,7 @@ public interface NamedParameterJdbcOperations {
* @param sql the SQL containing named parameters
* @param paramSource container of arguments and SQL types to bind to the query
* @return the number of rows affected
* @throws org . springframework . dao . DataAccessException if there is any problem issuing the update
* @throws DataAccessException if there is any problem issuing the update
* /
int update ( String sql , SqlParameterSource paramSource ) throws DataAccessException ;
@ -460,7 +492,7 @@ public interface NamedParameterJdbcOperations {
@@ -460,7 +492,7 @@ public interface NamedParameterJdbcOperations {
* @param paramMap map of parameters to bind to the query
* ( leaving it to the PreparedStatement to guess the corresponding SQL type )
* @return the number of rows affected
* @throws org . springframework . dao . DataAccessException if there is any problem issuing the update
* @throws DataAccessException if there is any problem issuing the update
* /
int update ( String sql , Map < String , ? > paramMap ) throws DataAccessException ;
@ -471,7 +503,7 @@ public interface NamedParameterJdbcOperations {
@@ -471,7 +503,7 @@ public interface NamedParameterJdbcOperations {
* @param paramSource container of arguments and SQL types to bind to the query
* @param generatedKeyHolder a { @link KeyHolder } that will hold the generated keys
* @return the number of rows affected
* @throws org . springframework . dao . DataAccessException if there is any problem issuing the update
* @throws DataAccessException if there is any problem issuing the update
* @see MapSqlParameterSource
* @see org . springframework . jdbc . support . GeneratedKeyHolder
* /
@ -486,7 +518,7 @@ public interface NamedParameterJdbcOperations {
@@ -486,7 +518,7 @@ public interface NamedParameterJdbcOperations {
* @param generatedKeyHolder a { @link KeyHolder } that will hold the generated keys
* @param keyColumnNames names of the columns that will have keys generated for them
* @return the number of rows affected
* @throws org . springframework . dao . DataAccessException if there is any problem issuing the update
* @throws DataAccessException if there is any problem issuing the update
* @see MapSqlParameterSource
* @see org . springframework . jdbc . support . GeneratedKeyHolder
* /
@ -498,6 +530,7 @@ public interface NamedParameterJdbcOperations {
@@ -498,6 +530,7 @@ public interface NamedParameterJdbcOperations {
* @param sql the SQL statement to execute
* @param batchValues the array of Maps containing the batch of arguments for the query
* @return an array containing the numbers of rows affected by each update in the batch
* @throws DataAccessException if there is any problem issuing the update
* /
int [ ] batchUpdate ( String sql , Map < String , ? > [ ] batchValues ) ;
@ -506,6 +539,7 @@ public interface NamedParameterJdbcOperations {
@@ -506,6 +539,7 @@ public interface NamedParameterJdbcOperations {
* @param sql the SQL statement to execute
* @param batchArgs the array of { @link SqlParameterSource } containing the batch of arguments for the query
* @return an array containing the numbers of rows affected by each update in the batch
* @throws DataAccessException if there is any problem issuing the update
* /
int [ ] batchUpdate ( String sql , SqlParameterSource [ ] batchArgs ) ;