Refined TemporaryLobCreator null handling (from 4.3.x)
Issue: SPR-15656
This commit is contained in:
parent
10139d42fc
commit
75bd516251
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -78,4 +78,5 @@ public class PostgresCallMetaDataProvider extends GenericCallMetaDataProvider {
|
||||||
public boolean byPassReturnParameter(String parameterName) {
|
public boolean byPassReturnParameter(String parameterName) {
|
||||||
return RETURN_VALUE_NAME.equals(parameterName);
|
return RETURN_VALUE_NAME.equals(parameterName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,24 +89,24 @@ public abstract class RdbmsOperation implements InitializingBean {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An alternative to the more commonly used setDataSource() when you want to
|
* An alternative to the more commonly used {@link #setDataSource} when you want to
|
||||||
* use the same JdbcTemplate in multiple RdbmsOperations. This is appropriate if the
|
* use the same {@link JdbcTemplate} in multiple {@code RdbmsOperations}. This is
|
||||||
* JdbcTemplate has special configuration such as a SQLExceptionTranslator that should
|
* appropriate if the {@code JdbcTemplate} has special configuration such as a
|
||||||
* apply to multiple RdbmsOperation objects.
|
* {@link org.springframework.jdbc.support.SQLExceptionTranslator} to be reused.
|
||||||
*/
|
*/
|
||||||
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
||||||
this.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() {
|
public JdbcTemplate getJdbcTemplate() {
|
||||||
return this.jdbcTemplate;
|
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
|
* @see org.springframework.jdbc.core.JdbcTemplate#setDataSource
|
||||||
*/
|
*/
|
||||||
public void setDataSource(DataSource dataSource) {
|
public void setDataSource(DataSource dataSource) {
|
||||||
|
@ -409,7 +409,7 @@ public abstract class RdbmsOperation implements InitializingBean {
|
||||||
* Validate the named parameters passed to an execute method based on declared parameters.
|
* Validate the named parameters passed to an execute method based on declared parameters.
|
||||||
* Subclasses should invoke this method before every {@code executeQuery()} or
|
* Subclasses should invoke this method before every {@code executeQuery()} or
|
||||||
* {@code update()} method.
|
* {@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
|
* @throws InvalidDataAccessApiUsageException if the parameters are invalid
|
||||||
*/
|
*/
|
||||||
protected void validateNamedParameters(@Nullable Map<String, ?> parameters) throws InvalidDataAccessApiUsageException {
|
protected void validateNamedParameters(@Nullable Map<String, ?> parameters) throws InvalidDataAccessApiUsageException {
|
||||||
|
|
|
@ -60,11 +60,15 @@ public class TemporaryLobCreator implements LobCreator {
|
||||||
public void setBlobAsBytes(PreparedStatement ps, int paramIndex, @Nullable byte[] content)
|
public void setBlobAsBytes(PreparedStatement ps, int paramIndex, @Nullable byte[] content)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
|
|
||||||
|
if (content != null) {
|
||||||
Blob blob = ps.getConnection().createBlob();
|
Blob blob = ps.getConnection().createBlob();
|
||||||
blob.setBytes(1, content);
|
blob.setBytes(1, content);
|
||||||
|
|
||||||
this.temporaryBlobs.add(blob);
|
this.temporaryBlobs.add(blob);
|
||||||
ps.setBlob(paramIndex, blob);
|
ps.setBlob(paramIndex, blob);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ps.setBlob(paramIndex, (Blob) null);
|
||||||
|
}
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug(content != null ? "Copied bytes into temporary BLOB with length " + content.length :
|
logger.debug(content != null ? "Copied bytes into temporary BLOB with length " + content.length :
|
||||||
|
@ -103,11 +107,15 @@ public class TemporaryLobCreator implements LobCreator {
|
||||||
public void setClobAsString(PreparedStatement ps, int paramIndex, @Nullable String content)
|
public void setClobAsString(PreparedStatement ps, int paramIndex, @Nullable String content)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
|
|
||||||
|
if (content != null) {
|
||||||
Clob clob = ps.getConnection().createClob();
|
Clob clob = ps.getConnection().createClob();
|
||||||
clob.setString(1, content);
|
clob.setString(1, content);
|
||||||
|
|
||||||
this.temporaryClobs.add(clob);
|
this.temporaryClobs.add(clob);
|
||||||
ps.setClob(paramIndex, clob);
|
ps.setClob(paramIndex, clob);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ps.setClob(paramIndex, (Clob) null);
|
||||||
|
}
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug(content != null ? "Copied string into temporary CLOB with length " + content.length() :
|
logger.debug(content != null ? "Copied string into temporary CLOB with length " + content.length() :
|
||||||
|
@ -183,4 +191,5 @@ public class TemporaryLobCreator implements LobCreator {
|
||||||
logger.error("Could not free LOB", ex);
|
logger.error("Could not free LOB", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,6 +189,7 @@ public abstract class AbstractAdaptableMessageListener
|
||||||
/**
|
/**
|
||||||
* Return the {@link QosSettings} to use when sending a response,
|
* Return the {@link QosSettings} to use when sending a response,
|
||||||
* or {@code null} if the defaults should be used.
|
* or {@code null} if the defaults should be used.
|
||||||
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
protected QosSettings getResponseQosSettings() {
|
protected QosSettings getResponseQosSettings() {
|
||||||
|
|
Loading…
Reference in New Issue