Browse Source

Merge branch '6.0.x'

pull/31091/head
Sam Brannen 1 year ago
parent
commit
5f893cadc5
  1. 16
      spring-jdbc/src/main/java/org/springframework/jdbc/core/ArgumentPreparedStatementSetter.java
  2. 16
      spring-jdbc/src/main/java/org/springframework/jdbc/core/ArgumentTypePreparedStatementSetter.java

16
spring-jdbc/src/main/java/org/springframework/jdbc/core/ArgumentPreparedStatementSetter.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.
@ -22,7 +22,8 @@ import java.sql.SQLException;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
* Simple adapter for {@link PreparedStatementSetter} that applies a given array of arguments. * Simple adapter for {@link PreparedStatementSetter} that applies a given array
* of arguments.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.2.3 * @since 3.2.3
@ -34,7 +35,7 @@ public class ArgumentPreparedStatementSetter implements PreparedStatementSetter,
/** /**
* Create a new ArgPreparedStatementSetter for the given arguments. * Create a new {@code ArgumentPreparedStatementSetter} for the given arguments.
* @param args the arguments to set * @param args the arguments to set
*/ */
public ArgumentPreparedStatementSetter(@Nullable Object[] args) { public ArgumentPreparedStatementSetter(@Nullable Object[] args) {
@ -53,14 +54,17 @@ public class ArgumentPreparedStatementSetter implements PreparedStatementSetter,
} }
/** /**
* Set the value for prepared statements specified parameter index using the passed in value. * Set the value for the prepared statement's specified parameter position
* This method can be overridden by subclasses if needed. * using the supplied value.
* <p>This method can be overridden by subclasses if needed.
* @param ps the PreparedStatement * @param ps the PreparedStatement
* @param parameterPosition index of the parameter position * @param parameterPosition index of the parameter position
* @param argValue the value to set * @param argValue the value to set
* @throws SQLException if thrown by PreparedStatement methods * @throws SQLException if thrown by PreparedStatement methods
*/ */
protected void doSetValue(PreparedStatement ps, int parameterPosition, Object argValue) throws SQLException { protected void doSetValue(PreparedStatement ps, int parameterPosition, @Nullable Object argValue)
throws SQLException {
if (argValue instanceof SqlParameterValue paramValue) { if (argValue instanceof SqlParameterValue paramValue) {
StatementCreatorUtils.setParameterValue(ps, parameterPosition, paramValue, paramValue.getValue()); StatementCreatorUtils.setParameterValue(ps, parameterPosition, paramValue, paramValue.getValue());
} }

16
spring-jdbc/src/main/java/org/springframework/jdbc/core/ArgumentTypePreparedStatementSetter.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.
@ -25,8 +25,8 @@ import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
* Simple adapter for {@link PreparedStatementSetter} that applies * Simple adapter for {@link PreparedStatementSetter} that applies the given
* given arrays of arguments and JDBC argument types. * arrays of arguments and JDBC argument types.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.2.3 * @since 3.2.3
@ -41,7 +41,8 @@ public class ArgumentTypePreparedStatementSetter implements PreparedStatementSet
/** /**
* Create a new ArgTypePreparedStatementSetter for the given arguments. * Create a new {@code ArgumentTypePreparedStatementSetter} for the given
* arguments and types.
* @param args the arguments to set * @param args the arguments to set
* @param argTypes the corresponding SQL types of the arguments * @param argTypes the corresponding SQL types of the arguments
*/ */
@ -84,15 +85,16 @@ public class ArgumentTypePreparedStatementSetter implements PreparedStatementSet
} }
/** /**
* Set the value for the prepared statement's specified parameter position using the passed in * Set the value for the prepared statement's specified parameter position
* value and type. This method can be overridden by subclasses if needed. * using the supplied value and type.
* <p>This method can be overridden by subclasses if needed.
* @param ps the PreparedStatement * @param ps the PreparedStatement
* @param parameterPosition index of the parameter position * @param parameterPosition index of the parameter position
* @param argType the argument type * @param argType the argument type
* @param argValue the argument value * @param argValue the argument value
* @throws SQLException if thrown by PreparedStatement methods * @throws SQLException if thrown by PreparedStatement methods
*/ */
protected void doSetValue(PreparedStatement ps, int parameterPosition, int argType, Object argValue) protected void doSetValue(PreparedStatement ps, int parameterPosition, int argType, @Nullable Object argValue)
throws SQLException { throws SQLException {
StatementCreatorUtils.setParameterValue(ps, parameterPosition, argType, argValue); StatementCreatorUtils.setParameterValue(ps, parameterPosition, argType, argValue);

Loading…
Cancel
Save