- 
                Notifications
    
You must be signed in to change notification settings  - Fork 38.8k
 
Description
Commit a61b297#diff-d1e8483d1c981021eda9e2ef12138d8732b1711cc16c1438f041398f5d90be8f declared ParameterizedPreparedStatementSetter argument as @Nullable, which causes nullability warnings in user code.
This is the only usage of ParameterizedPreparedStatementSetter in Framework's codebase:
spring-framework/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java
Lines 1089 to 1103 in ad22a99
| @Override | |
| public <T> int[][] batchUpdate(String sql, Collection<T> batchArgs, int batchSize, | |
| ParameterizedPreparedStatementSetter<T> pss) throws DataAccessException { | |
| if (logger.isDebugEnabled()) { | |
| logger.debug("Executing SQL batch update [" + sql + "] with a batch size of " + batchSize); | |
| } | |
| int[][] result = execute(sql, (PreparedStatementCallback<int[][]>) ps -> { | |
| List<int[]> rowsAffected = new ArrayList<>(); | |
| try { | |
| boolean batchSupported = JdbcUtils.supportsBatchUpdates(ps.getConnection()); | |
| int n = 0; | |
| for (T obj : batchArgs) { | |
| pss.setValues(ps, obj); | |
| n++; | 
Looking at JdbcTemplate#batchUpdate argument batchArgs, it doesn't declare collection elements as nullable, so perhaps that should translate to ParameterizedPreparedStatementSetter argument as well? In any case, I believe Framework should provide some guarantees here so that it doesn't burden user code with null-checks.