Browse Source

Refined TemporaryLobCreator null handling (from 4.3.x)

Issue: SPR-15656
pull/1595/head
Juergen Hoeller 7 years ago
parent
commit
75bd516251
  1. 3
      spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/PostgresCallMetaDataProvider.java
  2. 14
      spring-jdbc/src/main/java/org/springframework/jdbc/object/RdbmsOperation.java
  3. 29
      spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/TemporaryLobCreator.java
  4. 1
      spring-jms/src/main/java/org/springframework/jms/listener/adapter/AbstractAdaptableMessageListener.java

3
spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/PostgresCallMetaDataProvider.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -78,4 +78,5 @@ public class PostgresCallMetaDataProvider extends GenericCallMetaDataProvider { @@ -78,4 +78,5 @@ public class PostgresCallMetaDataProvider extends GenericCallMetaDataProvider {
public boolean byPassReturnParameter(String parameterName) {
return RETURN_VALUE_NAME.equals(parameterName);
}
}

14
spring-jdbc/src/main/java/org/springframework/jdbc/object/RdbmsOperation.java

@ -89,24 +89,24 @@ public abstract class RdbmsOperation implements InitializingBean { @@ -89,24 +89,24 @@ public abstract class RdbmsOperation implements InitializingBean {
/**
* An alternative to the more commonly used setDataSource() when you want to
* use the same JdbcTemplate in multiple RdbmsOperations. This is appropriate if the
* JdbcTemplate has special configuration such as a SQLExceptionTranslator that should
* apply to multiple RdbmsOperation objects.
* An alternative to the more commonly used {@link #setDataSource} when you want to
* use the same {@link JdbcTemplate} in multiple {@code RdbmsOperations}. This is
* appropriate if the {@code JdbcTemplate} has special configuration such as a
* {@link org.springframework.jdbc.support.SQLExceptionTranslator} to be reused.
*/
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
/**
* Return the JdbcTemplate object used by this object.
* Return the {@link JdbcTemplate} used by this operation object.
*/
public JdbcTemplate getJdbcTemplate() {
return this.jdbcTemplate;
}
/**
* Set the JDBC DataSource to obtain connections from.
* Set the JDBC {@link DataSource} to obtain connections from.
* @see org.springframework.jdbc.core.JdbcTemplate#setDataSource
*/
public void setDataSource(DataSource dataSource) {
@ -409,7 +409,7 @@ public abstract class RdbmsOperation implements InitializingBean { @@ -409,7 +409,7 @@ public abstract class RdbmsOperation implements InitializingBean {
* Validate the named parameters passed to an execute method based on declared parameters.
* Subclasses should invoke this method before every {@code executeQuery()} or
* {@code update()} method.
* @param parameters parameter Map supplied. May be {@code null}.
* @param parameters parameter Map supplied (may be {@code null})
* @throws InvalidDataAccessApiUsageException if the parameters are invalid
*/
protected void validateNamedParameters(@Nullable Map<String, ?> parameters) throws InvalidDataAccessApiUsageException {

29
spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/TemporaryLobCreator.java

@ -60,11 +60,15 @@ public class TemporaryLobCreator implements LobCreator { @@ -60,11 +60,15 @@ public class TemporaryLobCreator implements LobCreator {
public void setBlobAsBytes(PreparedStatement ps, int paramIndex, @Nullable byte[] content)
throws SQLException {
Blob blob = ps.getConnection().createBlob();
blob.setBytes(1, content);
this.temporaryBlobs.add(blob);
ps.setBlob(paramIndex, blob);
if (content != null) {
Blob blob = ps.getConnection().createBlob();
blob.setBytes(1, content);
this.temporaryBlobs.add(blob);
ps.setBlob(paramIndex, blob);
}
else {
ps.setBlob(paramIndex, (Blob) null);
}
if (logger.isDebugEnabled()) {
logger.debug(content != null ? "Copied bytes into temporary BLOB with length " + content.length :
@ -103,11 +107,15 @@ public class TemporaryLobCreator implements LobCreator { @@ -103,11 +107,15 @@ public class TemporaryLobCreator implements LobCreator {
public void setClobAsString(PreparedStatement ps, int paramIndex, @Nullable String content)
throws SQLException {
Clob clob = ps.getConnection().createClob();
clob.setString(1, content);
this.temporaryClobs.add(clob);
ps.setClob(paramIndex, clob);
if (content != null) {
Clob clob = ps.getConnection().createClob();
clob.setString(1, content);
this.temporaryClobs.add(clob);
ps.setClob(paramIndex, clob);
}
else {
ps.setClob(paramIndex, (Clob) null);
}
if (logger.isDebugEnabled()) {
logger.debug(content != null ? "Copied string into temporary CLOB with length " + content.length() :
@ -183,4 +191,5 @@ public class TemporaryLobCreator implements LobCreator { @@ -183,4 +191,5 @@ public class TemporaryLobCreator implements LobCreator {
logger.error("Could not free LOB", ex);
}
}
}

1
spring-jms/src/main/java/org/springframework/jms/listener/adapter/AbstractAdaptableMessageListener.java

@ -189,6 +189,7 @@ public abstract class AbstractAdaptableMessageListener @@ -189,6 +189,7 @@ public abstract class AbstractAdaptableMessageListener
/**
* Return the {@link QosSettings} to use when sending a response,
* or {@code null} if the defaults should be used.
* @since 5.0
*/
@Nullable
protected QosSettings getResponseQosSettings() {

Loading…
Cancel
Save