Skip to content

Commit 08474aa

Browse files
committed
Clarify JDBC-defined negative values returned from batchUpdate
Closes gh-25138
1 parent 2ff2251 commit 08474aa

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,8 @@ <T> List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> ele
896896
* @param pss object to set parameters on the PreparedStatement
897897
* created by this method
898898
* @return an array of the number of rows affected by each statement
899+
* (may also contain special JDBC-defined negative values for affected rows such as
900+
* {@link java.sql.Statement#SUCCESS_NO_INFO}/{@link java.sql.Statement#EXECUTE_FAILED})
899901
* @throws DataAccessException if there is any problem issuing the update
900902
*/
901903
int[] batchUpdate(String sql, BatchPreparedStatementSetter pss) throws DataAccessException;
@@ -905,6 +907,8 @@ <T> List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> ele
905907
* @param sql the SQL statement to execute
906908
* @param batchArgs the List of Object arrays containing the batch of arguments for the query
907909
* @return an array containing the numbers of rows affected by each update in the batch
910+
* (may also contain special JDBC-defined negative values for affected rows such as
911+
* {@link java.sql.Statement#SUCCESS_NO_INFO}/{@link java.sql.Statement#EXECUTE_FAILED})
908912
* @throws DataAccessException if there is any problem issuing the update
909913
*/
910914
int[] batchUpdate(String sql, List<Object[]> batchArgs) throws DataAccessException;
@@ -916,20 +920,24 @@ <T> List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> ele
916920
* @param argTypes the SQL types of the arguments
917921
* (constants from {@code java.sql.Types})
918922
* @return an array containing the numbers of rows affected by each update in the batch
923+
* (may also contain special JDBC-defined negative values for affected rows such as
924+
* {@link java.sql.Statement#SUCCESS_NO_INFO}/{@link java.sql.Statement#EXECUTE_FAILED})
919925
* @throws DataAccessException if there is any problem issuing the update
920926
*/
921927
int[] batchUpdate(String sql, List<Object[]> batchArgs, int[] argTypes) throws DataAccessException;
922928

923929
/**
924-
* Execute multiple batches using the supplied SQL statement with the collect of supplied arguments.
925-
* The arguments' values will be set using the ParameterizedPreparedStatementSetter.
930+
* Execute multiple batches using the supplied SQL statement with the collect of supplied
931+
* arguments. The arguments' values will be set using the ParameterizedPreparedStatementSetter.
926932
* Each batch should be of size indicated in 'batchSize'.
927933
* @param sql the SQL statement to execute.
928934
* @param batchArgs the List of Object arrays containing the batch of arguments for the query
929935
* @param batchSize batch size
930936
* @param pss the ParameterizedPreparedStatementSetter to use
931-
* @return an array containing for each batch another array containing the numbers of rows affected
932-
* by each update in the batch
937+
* @return an array containing for each batch another array containing the numbers of
938+
* rows affected by each update in the batch
939+
* (may also contain special JDBC-defined negative values for affected rows such as
940+
* {@link java.sql.Statement#SUCCESS_NO_INFO}/{@link java.sql.Statement#EXECUTE_FAILED})
933941
* @throws DataAccessException if there is any problem issuing the update
934942
* @since 3.1
935943
*/

spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,15 +498,20 @@ int update(String sql, SqlParameterSource paramSource, KeyHolder generatedKeyHol
498498
* @param sql the SQL statement to execute
499499
* @param batchValues the array of Maps containing the batch of arguments for the query
500500
* @return an array containing the numbers of rows affected by each update in the batch
501+
* (may also contain special JDBC-defined negative values for affected rows such as
502+
* {@link java.sql.Statement#SUCCESS_NO_INFO}/{@link java.sql.Statement#EXECUTE_FAILED})
501503
* @throws DataAccessException if there is any problem issuing the update
502504
*/
503505
int[] batchUpdate(String sql, Map<String, ?>[] batchValues);
504506

505507
/**
506508
* Execute a batch using the supplied SQL statement with the batch of supplied arguments.
507509
* @param sql the SQL statement to execute
508-
* @param batchArgs the array of {@link SqlParameterSource} containing the batch of arguments for the query
510+
* @param batchArgs the array of {@link SqlParameterSource} containing the batch of
511+
* arguments for the query
509512
* @return an array containing the numbers of rows affected by each update in the batch
513+
* (may also contain special JDBC-defined negative values for affected rows such as
514+
* {@link java.sql.Statement#SUCCESS_NO_INFO}/{@link java.sql.Statement#EXECUTE_FAILED})
510515
* @throws DataAccessException if there is any problem issuing the update
511516
*/
512517
int[] batchUpdate(String sql, SqlParameterSource[] batchArgs);

0 commit comments

Comments
 (0)