diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java index d043c1f146d..5de404f14bc 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java @@ -21,7 +21,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -48,11 +47,6 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { /** Logger available to subclasses. */ protected static final Log logger = LogFactory.getLog(TableMetaDataProvider.class); - /** Database products we know not supporting the use of a String[] for generated keys. */ - private static final List productsNotSupportingGeneratedKeysColumnNameArray = - Arrays.asList("Apache Derby", "HSQL Database Engine"); - - /** The name of the user currently connected. */ private final @Nullable String userName; @@ -93,45 +87,14 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { @Override public void initializeWithMetaData(DatabaseMetaData databaseMetaData) throws SQLException { try { - if (databaseMetaData.supportsGetGeneratedKeys()) { - logger.debug("GetGeneratedKeys is supported"); - setGetGeneratedKeysSupported(true); - } - else { - logger.debug("GetGeneratedKeys is not supported"); - setGetGeneratedKeysSupported(false); - } + setGetGeneratedKeysSupported(databaseMetaData.supportsGetGeneratedKeys()); + setGeneratedKeysColumnNameArraySupported(isGetGeneratedKeysSupported()); } catch (SQLException ex) { if (logger.isWarnEnabled()) { logger.warn("Error retrieving 'DatabaseMetaData.supportsGetGeneratedKeys': " + ex.getMessage()); } } - try { - String databaseProductName = databaseMetaData.getDatabaseProductName(); - if (productsNotSupportingGeneratedKeysColumnNameArray.contains(databaseProductName)) { - if (logger.isDebugEnabled()) { - logger.debug("GeneratedKeysColumnNameArray is not supported for " + databaseProductName); - } - setGeneratedKeysColumnNameArraySupported(false); - } - else { - if (isGetGeneratedKeysSupported()) { - if (logger.isDebugEnabled()) { - logger.debug("GeneratedKeysColumnNameArray is supported for " + databaseProductName); - } - setGeneratedKeysColumnNameArraySupported(true); - } - else { - setGeneratedKeysColumnNameArraySupported(false); - } - } - } - catch (SQLException ex) { - if (logger.isWarnEnabled()) { - logger.warn("Error retrieving 'DatabaseMetaData.getDatabaseProductName': " + ex.getMessage()); - } - } try { this.databaseVersion = databaseMetaData.getDatabaseProductVersion(); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlBinaryValue.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlBinaryValue.java index 982adb7545c..884a55214d0 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlBinaryValue.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlBinaryValue.java @@ -35,12 +35,18 @@ import org.springframework.jdbc.core.SqlTypeValue; * *

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. + * + *

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. * + *

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 diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlCharacterValue.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlCharacterValue.java index 6bbcdba79db..bae27406d27 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlCharacterValue.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlCharacterValue.java @@ -34,12 +34,17 @@ import org.springframework.jdbc.core.SqlTypeValue; * *

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. + * + *

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. * + *

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