Browse Source

Unwrap SqlParameterValue for disposable value detection in cleanupParameters

Closes gh-22972
pull/25592/head
Juergen Hoeller 6 years ago
parent
commit
6d524e1da5
  1. 13
      spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java

13
spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -513,12 +513,17 @@ public abstract class StatementCreatorUtils { @@ -513,12 +513,17 @@ public abstract class StatementCreatorUtils {
public static void cleanupParameters(Collection<?> paramValues) {
if (paramValues != null) {
for (Object inValue : paramValues) {
if (inValue instanceof DisposableSqlTypeValue) {
((DisposableSqlTypeValue) inValue).cleanup();
// Unwrap SqlParameterValue first...
if (inValue instanceof SqlParameterValue) {
inValue = ((SqlParameterValue) inValue).getValue();
}
else if (inValue instanceof SqlValue) {
// Check for disposable value types
if (inValue instanceof SqlValue) {
((SqlValue) inValue).cleanup();
}
else if (inValue instanceof DisposableSqlTypeValue) {
((DisposableSqlTypeValue) inValue).cleanup();
}
}
}
}

Loading…
Cancel
Save