Skip to content

Commit f3832c7

Browse files
committed
Add note on SQL types with SqlBinaryValue/SqlCharacterValue
Closes gh-34786
1 parent 16e99f2 commit f3832c7

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@
3434
*
3535
* <p>Designed for use with {@link org.springframework.jdbc.core.JdbcTemplate}
3636
* as well as {@link org.springframework.jdbc.core.simple.JdbcClient}, to be
37-
* passed in as a parameter value wrapping the target content value. Can be
38-
* combined with {@link org.springframework.jdbc.core.SqlParameterValue} for
39-
* specifying a SQL type, for example,
37+
* passed in as a parameter value wrapping the target content value.
38+
*
39+
* <p>Can be combined with {@link org.springframework.jdbc.core.SqlParameterValue}
40+
* for specifying a SQL type, for example,
4041
* {@code new SqlParameterValue(Types.BLOB, new SqlBinaryValue(myContent))}.
4142
* With most database drivers, the type hint is not actually necessary.
4243
*
44+
* <p>Note: Only specify {@code Types.BLOB} in case of an actual BLOB, preferring
45+
* {@code Types.LONGVARBINARY} otherwise. With PostgreSQL, {@code Types.ARRAY}
46+
* has to be specified for BYTEA columns, rather than {@code Types.BLOB}. This
47+
* is in contrast to {@link SqlLobValue} where byte array handling was lenient.
48+
*
4349
* @author Juergen Hoeller
4450
* @since 6.1.4
4551
* @see SqlCharacterValue

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@
3333
*
3434
* <p>Designed for use with {@link org.springframework.jdbc.core.JdbcTemplate}
3535
* as well as {@link org.springframework.jdbc.core.simple.JdbcClient}, to be
36-
* passed in as a parameter value wrapping the target content value. Can be
37-
* combined with {@link org.springframework.jdbc.core.SqlParameterValue} for
38-
* specifying a SQL type, for example,
36+
* passed in as a parameter value wrapping the target content value.
37+
*
38+
* <p>Can be combined with {@link org.springframework.jdbc.core.SqlParameterValue}
39+
* for specifying a SQL type, for example,
3940
* {@code new SqlParameterValue(Types.CLOB, new SqlCharacterValue(myContent))}.
4041
* With most database drivers, the type hint is not actually necessary.
4142
*
43+
* <p>Note: Only specify {@code Types.CLOB} in case of an actual CLOB, preferring
44+
* {@code Types.LONGVARCHAR} otherwise. This is in contrast to {@link SqlLobValue}
45+
* where char sequence handling was lenient.
46+
*
4247
* @author Juergen Hoeller
4348
* @since 6.1.4
4449
* @see SqlBinaryValue

0 commit comments

Comments
 (0)