Skip to content

Review ParameterizedPreparedStatementSetter argument nullability #35749

@vpavic

Description

@vpavic

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:

@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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions