Browse Source

Consistent ordering of overloaded operations

6.0.x
Juergen Hoeller 1 year ago
parent
commit
c373f496f3
  1. 16
      spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java
  2. 10
      spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -527,26 +527,26 @@ public interface NamedParameterJdbcOperations {
throws DataAccessException; throws DataAccessException;
/** /**
* Executes a batch using the supplied SQL statement with the batch of supplied arguments. * Execute a batch using the supplied SQL statement with the batch of supplied arguments.
* @param sql the SQL statement to execute * @param sql the SQL statement to execute
* @param batchValues the array of Maps containing the batch of arguments for the query * @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 * @return an array containing the numbers of rows affected by each update in the batch
* (may also contain special JDBC-defined negative values for affected rows such as * (may also contain special JDBC-defined negative values for affected rows such as
* {@link java.sql.Statement#SUCCESS_NO_INFO}/{@link java.sql.Statement#EXECUTE_FAILED}) * {@link java.sql.Statement#SUCCESS_NO_INFO}/{@link java.sql.Statement#EXECUTE_FAILED})
* @throws DataAccessException if there is any problem issuing the update * @throws DataAccessException if there is any problem issuing the update
*/ */
int[] batchUpdate(String sql, Map<String, ?>[] batchValues); int[] batchUpdate(String sql, SqlParameterSource[] batchArgs);
/** /**
* Execute a batch using the supplied SQL statement with the batch of supplied arguments. * Executes a batch using the supplied SQL statement with the batch of supplied arguments.
* @param sql the SQL statement to execute * @param sql the SQL statement to execute
* @param batchArgs the array of {@link SqlParameterSource} containing the batch of * @param batchValues the array of Maps containing the batch of arguments for the query
* arguments for the query
* @return an array containing the numbers of rows affected by each update in the batch * @return an array containing the numbers of rows affected by each update in the batch
* (may also contain special JDBC-defined negative values for affected rows such as * (may also contain special JDBC-defined negative values for affected rows such as
* {@link java.sql.Statement#SUCCESS_NO_INFO}/{@link java.sql.Statement#EXECUTE_FAILED}) * {@link java.sql.Statement#SUCCESS_NO_INFO}/{@link java.sql.Statement#EXECUTE_FAILED})
* @throws DataAccessException if there is any problem issuing the update * @throws DataAccessException if there is any problem issuing the update
*/ */
int[] batchUpdate(String sql, SqlParameterSource[] batchArgs); int[] batchUpdate(String sql, Map<String, ?>[] batchValues);
} }

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

@ -359,11 +359,6 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return getJdbcOperations().update(psc, generatedKeyHolder); return getJdbcOperations().update(psc, generatedKeyHolder);
} }
@Override
public int[] batchUpdate(String sql, Map<String, ?>[] batchValues) {
return batchUpdate(sql, SqlParameterSourceUtils.createBatch(batchValues));
}
@Override @Override
public int[] batchUpdate(String sql, SqlParameterSource[] batchArgs) { public int[] batchUpdate(String sql, SqlParameterSource[] batchArgs) {
if (batchArgs.length == 0) { if (batchArgs.length == 0) {
@ -388,6 +383,11 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
}); });
} }
@Override
public int[] batchUpdate(String sql, Map<String, ?>[] batchValues) {
return batchUpdate(sql, SqlParameterSourceUtils.createBatch(batchValues));
}
/** /**
* Build a {@link PreparedStatementCreator} based on the given SQL and named parameters. * Build a {@link PreparedStatementCreator} based on the given SQL and named parameters.

Loading…
Cancel
Save