Browse Source

Specify generic type nullness in spring-jdbc

See gh-34140
pull/34266/head
Sébastien Deleuze 12 months ago
parent
commit
8299a617b9
  1. 11
      spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java
  2. 6
      spring-jdbc/src/main/java/org/springframework/jdbc/core/DataClassRowMapper.java
  3. 12
      spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java
  4. 8
      spring-jdbc/src/main/java/org/springframework/jdbc/core/SimplePropertyRowMapper.java
  5. 10
      spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java
  6. 8
      spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterUtils.java
  7. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/object/GenericSqlQuery.java
  8. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/object/MappingSqlQuery.java
  9. 10
      spring-jdbc/src/main/java/org/springframework/jdbc/object/MappingSqlQueryWithParameters.java
  10. 8
      spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlOperation.java
  11. 8
      spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlQuery.java
  12. 8
      spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlUpdate.java
  13. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/object/UpdatableSqlQuery.java

11
spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@ -261,7 +261,7 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> { @@ -261,7 +261,7 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
* @param propertyName the property name (as used by property descriptors)
* @since 5.3.9
*/
protected void suppressProperty(String propertyName) {
protected void suppressProperty(@Nullable String propertyName) {
if (this.mappedProperties != null) {
this.mappedProperties.remove(lowerCaseName(propertyName));
this.mappedProperties.remove(underscoreName(propertyName));
@ -296,7 +296,10 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> { @@ -296,7 +296,10 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
* @since 4.2
* @see #underscoreName
*/
protected String lowerCaseName(String name) {
protected String lowerCaseName(@Nullable String name) {
if (!StringUtils.hasLength(name)) {
return "";
}
return name.toLowerCase(Locale.US);
}
@ -308,7 +311,7 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> { @@ -308,7 +311,7 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
* @since 4.2
* @see JdbcUtils#convertPropertyNameToUnderscoreName
*/
protected String underscoreName(String name) {
protected String underscoreName(@Nullable String name) {
return JdbcUtils.convertPropertyNameToUnderscoreName(name);
}

6
spring-jdbc/src/main/java/org/springframework/jdbc/core/DataClassRowMapper.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 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.
@ -64,7 +64,7 @@ public class DataClassRowMapper<T> extends BeanPropertyRowMapper<T> { @@ -64,7 +64,7 @@ public class DataClassRowMapper<T> extends BeanPropertyRowMapper<T> {
private @Nullable Constructor<T> mappedConstructor;
private String @Nullable [] constructorParameterNames;
private @Nullable String @Nullable [] constructorParameterNames;
private TypeDescriptor @Nullable [] constructorParameterTypes;
@ -108,7 +108,7 @@ public class DataClassRowMapper<T> extends BeanPropertyRowMapper<T> { @@ -108,7 +108,7 @@ public class DataClassRowMapper<T> extends BeanPropertyRowMapper<T> {
protected T constructMappedInstance(ResultSet rs, TypeConverter tc) throws SQLException {
Assert.state(this.mappedConstructor != null, "Mapped constructor was not initialized");
Object[] args;
@Nullable Object[] args;
if (this.constructorParameterNames != null && this.constructorParameterTypes != null) {
args = new Object[this.constructorParameterNames.length];
for (int i = 0; i < args.length; i++) {

12
spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 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.
@ -154,7 +154,7 @@ public class PreparedStatementCreatorFactory { @@ -154,7 +154,7 @@ public class PreparedStatementCreatorFactory {
* Return a new PreparedStatementSetter for the given parameters.
* @param params the parameter array (may be {@code null})
*/
public PreparedStatementSetter newPreparedStatementSetter(Object @Nullable [] params) {
public PreparedStatementSetter newPreparedStatementSetter(@Nullable Object @Nullable [] params) {
return new PreparedStatementCreatorImpl(params != null ? Arrays.asList(params) : Collections.emptyList());
}
@ -162,7 +162,7 @@ public class PreparedStatementCreatorFactory { @@ -162,7 +162,7 @@ public class PreparedStatementCreatorFactory {
* Return a new PreparedStatementCreator for the given parameters.
* @param params list of parameters (may be {@code null})
*/
public PreparedStatementCreator newPreparedStatementCreator(@Nullable List<?> params) {
public PreparedStatementCreator newPreparedStatementCreator(@Nullable List<? extends @Nullable Object> params) {
return new PreparedStatementCreatorImpl(params != null ? params : Collections.emptyList());
}
@ -170,7 +170,7 @@ public class PreparedStatementCreatorFactory { @@ -170,7 +170,7 @@ public class PreparedStatementCreatorFactory {
* Return a new PreparedStatementCreator for the given parameters.
* @param params the parameter array (may be {@code null})
*/
public PreparedStatementCreator newPreparedStatementCreator(Object @Nullable [] params) {
public PreparedStatementCreator newPreparedStatementCreator(@Nullable Object @Nullable [] params) {
return new PreparedStatementCreatorImpl(params != null ? Arrays.asList(params) : Collections.emptyList());
}
@ -180,7 +180,7 @@ public class PreparedStatementCreatorFactory { @@ -180,7 +180,7 @@ public class PreparedStatementCreatorFactory {
* the factory's, for example because of named parameter expanding)
* @param params the parameter array (may be {@code null})
*/
public PreparedStatementCreator newPreparedStatementCreator(String sqlToUse, Object @Nullable [] params) {
public PreparedStatementCreator newPreparedStatementCreator(String sqlToUse, @Nullable Object @Nullable [] params) {
return new PreparedStatementCreatorImpl(
sqlToUse, (params != null ? Arrays.asList(params) : Collections.emptyList()));
}
@ -208,7 +208,7 @@ public class PreparedStatementCreatorFactory { @@ -208,7 +208,7 @@ public class PreparedStatementCreatorFactory {
Set<String> names = new HashSet<>();
for (int i = 0; i < parameters.size(); i++) {
Object param = parameters.get(i);
if (param instanceof SqlParameterValue sqlParameterValue) {
if (param instanceof SqlParameterValue sqlParameterValue && sqlParameterValue.getName() != null) {
names.add(sqlParameterValue.getName());
}
else {

8
spring-jdbc/src/main/java/org/springframework/jdbc/core/SimplePropertyRowMapper.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 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.
@ -28,6 +28,8 @@ import java.util.Map; @@ -28,6 +28,8 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.BeanUtils;
import org.springframework.core.MethodParameter;
import org.springframework.core.convert.ConversionService;
@ -82,7 +84,7 @@ public class SimplePropertyRowMapper<T> implements RowMapper<T> { @@ -82,7 +84,7 @@ public class SimplePropertyRowMapper<T> implements RowMapper<T> {
private final Constructor<T> mappedConstructor;
private final String[] constructorParameterNames;
private final @Nullable String[] constructorParameterNames;
private final TypeDescriptor[] constructorParameterTypes;
@ -122,7 +124,7 @@ public class SimplePropertyRowMapper<T> implements RowMapper<T> { @@ -122,7 +124,7 @@ public class SimplePropertyRowMapper<T> implements RowMapper<T> {
@Override
public T mapRow(ResultSet rs, int rowNumber) throws SQLException {
Object[] args = new Object[this.constructorParameterNames.length];
@Nullable Object[] args = new Object[this.constructorParameterNames.length];
Set<Integer> usedIndex = new HashSet<>();
for (int i = 0; i < args.length; i++) {
String name = this.constructorParameterNames[i];

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 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.
@ -370,7 +370,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -370,7 +370,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
Object[] values = NamedParameterUtils.buildValueArray(parsedSql, batchArgs[i], null);
@Nullable Object[] values = NamedParameterUtils.buildValueArray(parsedSql, batchArgs[i], null);
pscf.newPreparedStatementSetter(values).setValues(ps);
}
@Override
@ -407,12 +407,12 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -407,12 +407,12 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
else {
pscf.setReturnGeneratedKeys(true);
}
Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, null);
@Nullable Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, null);
PreparedStatementCreator psc = pscf.newPreparedStatementCreator(params);
return getJdbcOperations().batchUpdate(psc, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
Object[] values = NamedParameterUtils.buildValueArray(parsedSql, batchArgs[i], null);
@Nullable Object[] values = NamedParameterUtils.buildValueArray(parsedSql, batchArgs[i], null);
pscf.newPreparedStatementSetter(values).setValues(ps);
}
@ -460,7 +460,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -460,7 +460,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
if (customizer != null) {
customizer.accept(pscf);
}
Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, null);
@Nullable Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, null);
return pscf.newPreparedStatementCreator(params);
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@ -348,10 +348,10 @@ public abstract class NamedParameterUtils { @@ -348,10 +348,10 @@ public abstract class NamedParameterUtils {
* be built into the value array in the form of SqlParameterValue objects.
* @return the array of values
*/
public static Object[] buildValueArray(
public static @Nullable Object[] buildValueArray(
ParsedSql parsedSql, SqlParameterSource paramSource, @Nullable List<SqlParameter> declaredParams) {
Object[] paramArray = new Object[parsedSql.getTotalParameterCount()];
@Nullable Object[] paramArray = new Object[parsedSql.getTotalParameterCount()];
if (parsedSql.getNamedParameterCount() > 0 && parsedSql.getUnnamedParameterCount() > 0) {
throw new InvalidDataAccessApiUsageException(
"Not allowed to mix named and traditional ? placeholders. You have " +
@ -497,7 +497,7 @@ public abstract class NamedParameterUtils { @@ -497,7 +497,7 @@ public abstract class NamedParameterUtils {
* @param paramMap the Map of parameters
* @return the array of values
*/
public static Object[] buildValueArray(String sql, Map<String, ?> paramMap) {
public static @Nullable Object[] buildValueArray(String sql, Map<String, ?> paramMap) {
ParsedSql parsedSql = parseSqlStatement(sql);
return buildValueArray(parsedSql, new MapSqlParameterSource(paramMap), null);
}

4
spring-jdbc/src/main/java/org/springframework/jdbc/object/GenericSqlQuery.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2025 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.
@ -70,7 +70,7 @@ public class GenericSqlQuery<T> extends SqlQuery<T> { @@ -70,7 +70,7 @@ public class GenericSqlQuery<T> extends SqlQuery<T> {
@Override
@SuppressWarnings("unchecked")
protected RowMapper<T> newRowMapper(Object @Nullable [] parameters, @Nullable Map<?, ?> context) {
protected RowMapper<T> newRowMapper(@Nullable Object @Nullable [] parameters, @Nullable Map<?, ?> context) {
if (this.rowMapper != null) {
return this.rowMapper;
}

4
spring-jdbc/src/main/java/org/springframework/jdbc/object/MappingSqlQuery.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2025 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.
@ -63,7 +63,7 @@ public abstract class MappingSqlQuery<T> extends MappingSqlQueryWithParameters<T @@ -63,7 +63,7 @@ public abstract class MappingSqlQuery<T> extends MappingSqlQueryWithParameters<T
* @see #mapRow(ResultSet, int)
*/
@Override
protected final @Nullable T mapRow(ResultSet rs, int rowNum, Object @Nullable [] parameters, @Nullable Map<?, ?> context)
protected final @Nullable T mapRow(ResultSet rs, int rowNum, @Nullable Object @Nullable [] parameters, @Nullable Map<?, ?> context)
throws SQLException {
return mapRow(rs, rowNum);

10
spring-jdbc/src/main/java/org/springframework/jdbc/object/MappingSqlQueryWithParameters.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2025 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.
@ -74,7 +74,7 @@ public abstract class MappingSqlQueryWithParameters<T> extends SqlQuery<T> { @@ -74,7 +74,7 @@ public abstract class MappingSqlQueryWithParameters<T> extends SqlQuery<T> {
* implementation of the mapRow() method.
*/
@Override
protected RowMapper<T> newRowMapper(Object @Nullable [] parameters, @Nullable Map<?, ?> context) {
protected RowMapper<T> newRowMapper(@Nullable Object @Nullable [] parameters, @Nullable Map<?, ?> context) {
return new RowMapperImpl(parameters, context);
}
@ -93,7 +93,7 @@ public abstract class MappingSqlQueryWithParameters<T> extends SqlQuery<T> { @@ -93,7 +93,7 @@ public abstract class MappingSqlQueryWithParameters<T> extends SqlQuery<T> {
* Subclasses can simply not catch SQLExceptions, relying on the
* framework to clean up.
*/
protected abstract @Nullable T mapRow(ResultSet rs, int rowNum, Object @Nullable [] parameters, @Nullable Map<?, ?> context)
protected abstract @Nullable T mapRow(ResultSet rs, int rowNum, @Nullable Object @Nullable [] parameters, @Nullable Map<?, ?> context)
throws SQLException;
@ -103,14 +103,14 @@ public abstract class MappingSqlQueryWithParameters<T> extends SqlQuery<T> { @@ -103,14 +103,14 @@ public abstract class MappingSqlQueryWithParameters<T> extends SqlQuery<T> {
*/
protected class RowMapperImpl implements RowMapper<T> {
private final Object @Nullable [] params;
private final @Nullable Object @Nullable [] params;
private final @Nullable Map<?, ?> context;
/**
* Use an array results. More efficient if we know how many results to expect.
*/
public RowMapperImpl(Object @Nullable [] parameters, @Nullable Map<?, ?> context) {
public RowMapperImpl(@Nullable Object @Nullable [] parameters, @Nullable Map<?, ?> context) {
this.params = parameters;
this.context = context;
}

8
spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlOperation.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2025 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.
@ -94,7 +94,7 @@ public abstract class SqlOperation extends RdbmsOperation { @@ -94,7 +94,7 @@ public abstract class SqlOperation extends RdbmsOperation {
* with the given parameters.
* @param params the parameter array (may be {@code null})
*/
protected final PreparedStatementSetter newPreparedStatementSetter(Object @Nullable [] params) {
protected final PreparedStatementSetter newPreparedStatementSetter(@Nullable Object @Nullable [] params) {
Assert.state(this.preparedStatementFactory != null, "No PreparedStatementFactory available");
return this.preparedStatementFactory.newPreparedStatementSetter(params);
}
@ -104,7 +104,7 @@ public abstract class SqlOperation extends RdbmsOperation { @@ -104,7 +104,7 @@ public abstract class SqlOperation extends RdbmsOperation {
* with the given parameters.
* @param params the parameter array (may be {@code null})
*/
protected final PreparedStatementCreator newPreparedStatementCreator(Object @Nullable [] params) {
protected final PreparedStatementCreator newPreparedStatementCreator(@Nullable Object @Nullable [] params) {
Assert.state(this.preparedStatementFactory != null, "No PreparedStatementFactory available");
return this.preparedStatementFactory.newPreparedStatementCreator(params);
}
@ -116,7 +116,7 @@ public abstract class SqlOperation extends RdbmsOperation { @@ -116,7 +116,7 @@ public abstract class SqlOperation extends RdbmsOperation {
* the factory's, for example because of named parameter expanding)
* @param params the parameter array (may be {@code null})
*/
protected final PreparedStatementCreator newPreparedStatementCreator(String sqlToUse, Object @Nullable [] params) {
protected final PreparedStatementCreator newPreparedStatementCreator(String sqlToUse, @Nullable Object @Nullable [] params) {
Assert.state(this.preparedStatementFactory != null, "No PreparedStatementFactory available");
return this.preparedStatementFactory.newPreparedStatementCreator(sqlToUse, params);
}

8
spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlQuery.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2025 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.
@ -227,7 +227,7 @@ public abstract class SqlQuery<T> extends SqlOperation { @@ -227,7 +227,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
ParsedSql parsedSql = getParsedSql();
MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
@Nullable Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
RowMapper<T> rowMapper = newRowMapper(params, context);
return getJdbcTemplate().query(newPreparedStatementCreator(sqlToUse, params), rowMapper);
}
@ -238,7 +238,7 @@ public abstract class SqlQuery<T> extends SqlOperation { @@ -238,7 +238,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* the SqlParameters. Primitive parameters must be represented by their Object wrapper
* type. The ordering of parameters is not significant.
*/
public List<T> executeByNamedParam(Map<String, ?> paramMap) throws DataAccessException {
public List<T> executeByNamedParam(Map<String, ? extends @Nullable Object> paramMap) throws DataAccessException {
return executeByNamedParam(paramMap, null);
}
@ -361,6 +361,6 @@ public abstract class SqlQuery<T> extends SqlOperation { @@ -361,6 +361,6 @@ public abstract class SqlQuery<T> extends SqlOperation {
* but it can be useful for creating the objects of the result list.
* @see #execute
*/
protected abstract RowMapper<T> newRowMapper(Object @Nullable [] parameters, @Nullable Map<?, ?> context);
protected abstract RowMapper<T> newRowMapper(@Nullable Object @Nullable [] parameters, @Nullable Map<?, ?> context);
}

8
spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlUpdate.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2025 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,6 +20,8 @@ import java.util.Map; @@ -20,6 +20,8 @@ import java.util.Map;
import javax.sql.DataSource;
import org.jspecify.annotations.Nullable;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.jdbc.JdbcUpdateAffectedIncorrectNumberOfRowsException;
@ -252,7 +254,7 @@ public class SqlUpdate extends SqlOperation { @@ -252,7 +254,7 @@ public class SqlUpdate extends SqlOperation {
ParsedSql parsedSql = getParsedSql();
MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
@Nullable Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
int rowsAffected = getJdbcTemplate().update(newPreparedStatementCreator(sqlToUse, params));
checkRowsAffected(rowsAffected);
return rowsAffected;
@ -271,7 +273,7 @@ public class SqlUpdate extends SqlOperation { @@ -271,7 +273,7 @@ public class SqlUpdate extends SqlOperation {
ParsedSql parsedSql = getParsedSql();
MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
@Nullable Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
int rowsAffected = getJdbcTemplate().update(newPreparedStatementCreator(sqlToUse, params), generatedKeyHolder);
checkRowsAffected(rowsAffected);
return rowsAffected;

4
spring-jdbc/src/main/java/org/springframework/jdbc/object/UpdatableSqlQuery.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2025 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.
@ -63,7 +63,7 @@ public abstract class UpdatableSqlQuery<T> extends SqlQuery<T> { @@ -63,7 +63,7 @@ public abstract class UpdatableSqlQuery<T> extends SqlQuery<T> {
* implementation of the {@code updateRow()} method.
*/
@Override
protected RowMapper<T> newRowMapper(Object @Nullable [] parameters, @Nullable Map<?, ?> context) {
protected RowMapper<T> newRowMapper(@Nullable Object @Nullable [] parameters, @Nullable Map<?, ?> context) {
return new RowMapperImpl(context);
}

Loading…
Cancel
Save