Browse Source

Add note on SQL types with SqlBinaryValue/SqlCharacterValue

Closes gh-34786
pull/35405/head
Juergen Hoeller 5 months ago
parent
commit
f3832c7262
  1. 12
      spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlBinaryValue.java
  2. 11
      spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlCharacterValue.java

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

@ -34,12 +34,18 @@ import org.springframework.lang.Nullable; @@ -34,12 +34,18 @@ import org.springframework.lang.Nullable;
*
* <p>Designed for use with {@link org.springframework.jdbc.core.JdbcTemplate}
* as well as {@link org.springframework.jdbc.core.simple.JdbcClient}, to be
* passed in as a parameter value wrapping the target content value. Can be
* combined with {@link org.springframework.jdbc.core.SqlParameterValue} for
* specifying a SQL type, for example,
* passed in as a parameter value wrapping the target content value.
*
* <p>Can be combined with {@link org.springframework.jdbc.core.SqlParameterValue}
* for specifying a SQL type, for example,
* {@code new SqlParameterValue(Types.BLOB, new SqlBinaryValue(myContent))}.
* With most database drivers, the type hint is not actually necessary.
*
* <p>Note: Only specify {@code Types.BLOB} in case of an actual BLOB, preferring
* {@code Types.LONGVARBINARY} otherwise. With PostgreSQL, {@code Types.ARRAY}
* has to be specified for BYTEA columns, rather than {@code Types.BLOB}. This
* is in contrast to {@link SqlLobValue} where byte array handling was lenient.
*
* @author Juergen Hoeller
* @since 6.1.4
* @see SqlCharacterValue

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

@ -33,12 +33,17 @@ import org.springframework.lang.Nullable; @@ -33,12 +33,17 @@ import org.springframework.lang.Nullable;
*
* <p>Designed for use with {@link org.springframework.jdbc.core.JdbcTemplate}
* as well as {@link org.springframework.jdbc.core.simple.JdbcClient}, to be
* passed in as a parameter value wrapping the target content value. Can be
* combined with {@link org.springframework.jdbc.core.SqlParameterValue} for
* specifying a SQL type, for example,
* passed in as a parameter value wrapping the target content value.
*
* <p>Can be combined with {@link org.springframework.jdbc.core.SqlParameterValue}
* for specifying a SQL type, for example,
* {@code new SqlParameterValue(Types.CLOB, new SqlCharacterValue(myContent))}.
* With most database drivers, the type hint is not actually necessary.
*
* <p>Note: Only specify {@code Types.CLOB} in case of an actual CLOB, preferring
* {@code Types.LONGVARCHAR} otherwise. This is in contrast to {@link SqlLobValue}
* where char sequence handling was lenient.
*
* @author Juergen Hoeller
* @since 6.1.4
* @see SqlBinaryValue

Loading…
Cancel
Save