Polishing

This commit is contained in:
Juergen Hoeller
2014-02-07 17:42:37 +01:00
parent 99f9dce14a
commit 749b65b0b2
5 changed files with 28 additions and 40 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -1009,7 +1009,7 @@ public interface JdbcOperations {
* @param batchArgs the List of Object arrays containing the batch of arguments for the query
* @return an array containing the numbers of rows affected by each update in the batch
*/
public int[] batchUpdate(String sql, List<Object[]> batchArgs);
public int[] batchUpdate(String sql, List<Object[]> batchArgs) throws DataAccessException;
/**
* Execute a batch using the supplied SQL statement with the batch of supplied arguments.
@@ -1019,7 +1019,8 @@ public interface JdbcOperations {
* (constants from {@code java.sql.Types})
* @return an array containing the numbers of rows affected by each update in the batch
*/
public int[] batchUpdate(String sql, List<Object[]> batchArgs, int[] argTypes);
public int[] batchUpdate(String sql, List<Object[]> batchArgs, int[] argTypes)
throws DataAccessException;
/**
* Execute multiple batches using the supplied SQL statement with the collect of supplied arguments.
@@ -1032,7 +1033,9 @@ public interface JdbcOperations {
* @return an array containing for each batch another array containing the numbers of rows affected
* by each update in the batch
*/
public <T> int[][] batchUpdate(String sql, Collection<T> batchArgs, int batchSize, ParameterizedPreparedStatementSetter<T> pss);
public <T> int[][] batchUpdate(String sql, Collection<T> batchArgs, int batchSize,
ParameterizedPreparedStatementSetter<T> pss) throws DataAccessException;
//-------------------------------------------------------------------------
// Methods dealing with callable statements

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -1028,23 +1028,19 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
}
@Override
public int[] batchUpdate(String sql, List<Object[]> batchArgs) {
public int[] batchUpdate(String sql, List<Object[]> batchArgs) throws DataAccessException {
return batchUpdate(sql, batchArgs, new int[0]);
}
@Override
public int[] batchUpdate(String sql, List<Object[]> batchArgs, int[] argTypes) {
public int[] batchUpdate(String sql, List<Object[]> batchArgs, int[] argTypes) throws DataAccessException {
return BatchUpdateUtils.executeBatchUpdate(sql, batchArgs, argTypes, this);
}
/*
* (non-Javadoc)
* @see org.springframework.jdbc.core.JdbcOperations#batchUpdate(java.lang.String, java.util.Collection, int, org.springframework.jdbc.core.ParameterizedPreparedStatementSetter)
*
* Contribution by Nicolas Fabre
*/
@Override
public <T> int[][] batchUpdate(String sql, final Collection<T> batchArgs, final int batchSize, final ParameterizedPreparedStatementSetter<T> pss) {
public <T> int[][] batchUpdate(String sql, final Collection<T> batchArgs, final int batchSize,
final ParameterizedPreparedStatementSetter<T> pss) throws DataAccessException {
if (logger.isDebugEnabled()) {
logger.debug("Executing SQL batch update [" + sql + "] with a batch size of " + batchSize);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@@ -20,7 +20,8 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
/**
* Parameterized callback interface used by the {@link JdbcTemplate} class for batch updates.
* Parameterized callback interface used by the {@link JdbcTemplate} class for
* batch updates.
*
* <p>This interface sets values on a {@link java.sql.PreparedStatement} provided
* by the JdbcTemplate class, for each of a number of updates in a batch using the
@@ -40,7 +41,6 @@ public interface ParameterizedPreparedStatementSetter<T> {
/**
* Set parameter values on the given PreparedStatement.
*
* @param ps the PreparedStatement to invoke setter methods on
* @param argument the object containing the values to be set
* @throws SQLException if a SQLException is encountered (i.e. there is no need to catch SQLException)