Browse Source

Merge branch '6.2.x'

pull/35250/head
Juergen Hoeller 5 months ago
parent
commit
321a804449
  1. 41
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java
  2. 12
      spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlBinaryValue.java
  3. 11
      spring-jdbc/src/main/java/org/springframework/jdbc/core/support/SqlCharacterValue.java

41
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java

@ -21,7 +21,6 @@ import java.sql.ResultSet; @@ -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 { @@ -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<String> 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 { @@ -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();

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

@ -35,12 +35,18 @@ import org.springframework.jdbc.core.SqlTypeValue; @@ -35,12 +35,18 @@ import org.springframework.jdbc.core.SqlTypeValue;
*
* <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

@ -34,12 +34,17 @@ import org.springframework.jdbc.core.SqlTypeValue; @@ -34,12 +34,17 @@ import org.springframework.jdbc.core.SqlTypeValue;
*
* <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