Check for procedure vs function constants in CallMetaDataContext
Closes gh-31550
This commit is contained in:
parent
6a7a0bddb7
commit
9957bb6918
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.jdbc.core.metadata;
|
||||
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
|
|
@ -115,28 +114,28 @@ public class CallMetaDataContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* Specify a limited set of in parameters to be used.
|
||||
* Specify a limited set of the {@code in} parameters to be used.
|
||||
*/
|
||||
public void setLimitedInParameterNames(Set<String> limitedInParameterNames) {
|
||||
this.limitedInParameterNames = limitedInParameterNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a limited set of in parameters to be used.
|
||||
* Get the limited set of the {@code in} parameters to be used.
|
||||
*/
|
||||
public Set<String> getLimitedInParameterNames() {
|
||||
return this.limitedInParameterNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the names of the out parameters.
|
||||
* Specify the names of the {@code out} parameters.
|
||||
*/
|
||||
public void setOutParameterNames(List<String> outParameterNames) {
|
||||
this.outParameterNames = outParameterNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of the out parameter names.
|
||||
* Get the list of the {@code out} parameter names.
|
||||
*/
|
||||
public List<String> getOutParameterNames() {
|
||||
return this.outParameterNames;
|
||||
|
|
@ -434,14 +433,14 @@ public class CallMetaDataContext {
|
|||
if (paramNameToUse == null) {
|
||||
paramNameToUse = "";
|
||||
}
|
||||
if (meta.getParameterType() == DatabaseMetaData.procedureColumnOut) {
|
||||
if (meta.isOutParameter()) {
|
||||
workParams.add(provider.createDefaultOutParameter(paramNameToUse, meta));
|
||||
outParamNames.add(paramNameToUse);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Added meta-data out parameter for '" + paramNameToUse + "'");
|
||||
}
|
||||
}
|
||||
else if (meta.getParameterType() == DatabaseMetaData.procedureColumnInOut) {
|
||||
else if (meta.isInOutParameter()) {
|
||||
workParams.add(provider.createDefaultInOutParameter(paramNameToUse, meta));
|
||||
outParamNames.add(paramNameToUse);
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
|
@ -554,7 +553,7 @@ public class CallMetaDataContext {
|
|||
Map<String, String> callParameterNames = CollectionUtils.newHashMap(this.callParameters.size());
|
||||
for (SqlParameter parameter : this.callParameters) {
|
||||
if (parameter.isInputValueProvided()) {
|
||||
String parameterName = parameter.getName();
|
||||
String parameterName = parameter.getName();
|
||||
String parameterNameToMatch = provider.parameterNameToUse(parameterName);
|
||||
if (parameterNameToMatch != null) {
|
||||
callParameterNames.put(parameterNameToMatch.toLowerCase(), parameterName);
|
||||
|
|
@ -606,7 +605,7 @@ public class CallMetaDataContext {
|
|||
int i = 0;
|
||||
for (SqlParameter parameter : this.callParameters) {
|
||||
if (parameter.isInputValueProvided()) {
|
||||
String parameterName = parameter.getName();
|
||||
String parameterName = parameter.getName();
|
||||
matchedParameters.put(parameterName, parameterValues[i++]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -97,6 +97,28 @@ public class CallParameterMetaData {
|
|||
this.parameterType == DatabaseMetaData.procedureColumnResult));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the declared parameter qualifies as an 'out' parameter
|
||||
* for our purposes: type {@link DatabaseMetaData#procedureColumnOut},
|
||||
* or in case of a function, {@link DatabaseMetaData#functionColumnOut}.
|
||||
* @since 5.3.31
|
||||
*/
|
||||
public boolean isOutParameter() {
|
||||
return (this.function ? this.parameterType == DatabaseMetaData.functionColumnOut :
|
||||
this.parameterType == DatabaseMetaData.procedureColumnOut);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the declared parameter qualifies as an 'in-out' parameter
|
||||
* for our purposes: type {@link DatabaseMetaData#procedureColumnInOut},
|
||||
* or in case of a function, {@link DatabaseMetaData#functionColumnInOut}.
|
||||
* @since 5.3.31
|
||||
*/
|
||||
public boolean isInOutParameter() {
|
||||
return (this.function ? this.parameterType == DatabaseMetaData.functionColumnInOut :
|
||||
this.parameterType == DatabaseMetaData.procedureColumnInOut);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the parameter SQL type.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -35,7 +35,8 @@ import org.springframework.util.StringUtils;
|
|||
|
||||
/**
|
||||
* A generic implementation of the {@link CallMetaDataProvider} interface.
|
||||
* This class can be extended to provide database specific behavior.
|
||||
*
|
||||
* <p>This class can be extended to provide database specific behavior.
|
||||
*
|
||||
* @author Thomas Risberg
|
||||
* @author Juergen Hoeller
|
||||
|
|
@ -113,7 +114,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
|||
@Nullable String schemaName, @Nullable String procedureName) throws SQLException {
|
||||
|
||||
this.procedureColumnMetaDataUsed = true;
|
||||
processProcedureColumns(databaseMetaData, catalogName, schemaName, procedureName);
|
||||
processProcedureColumns(databaseMetaData, catalogName, schemaName, procedureName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -124,52 +125,19 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
|||
@Override
|
||||
@Nullable
|
||||
public String procedureNameToUse(@Nullable String procedureName) {
|
||||
if (procedureName == null) {
|
||||
return null;
|
||||
}
|
||||
else if (isStoresUpperCaseIdentifiers()) {
|
||||
return procedureName.toUpperCase();
|
||||
}
|
||||
else if (isStoresLowerCaseIdentifiers()) {
|
||||
return procedureName.toLowerCase();
|
||||
}
|
||||
else {
|
||||
return procedureName;
|
||||
}
|
||||
return identifierNameToUse(procedureName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String catalogNameToUse(@Nullable String catalogName) {
|
||||
if (catalogName == null) {
|
||||
return null;
|
||||
}
|
||||
else if (isStoresUpperCaseIdentifiers()) {
|
||||
return catalogName.toUpperCase();
|
||||
}
|
||||
else if (isStoresLowerCaseIdentifiers()) {
|
||||
return catalogName.toLowerCase();
|
||||
}
|
||||
else {
|
||||
return catalogName;
|
||||
}
|
||||
return identifierNameToUse(catalogName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String schemaNameToUse(@Nullable String schemaName) {
|
||||
if (schemaName == null) {
|
||||
return null;
|
||||
}
|
||||
else if (isStoresUpperCaseIdentifiers()) {
|
||||
return schemaName.toUpperCase();
|
||||
}
|
||||
else if (isStoresLowerCaseIdentifiers()) {
|
||||
return schemaName.toLowerCase();
|
||||
}
|
||||
else {
|
||||
return schemaName;
|
||||
}
|
||||
return identifierNameToUse(schemaName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -197,18 +165,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
|||
@Override
|
||||
@Nullable
|
||||
public String parameterNameToUse(@Nullable String parameterName) {
|
||||
if (parameterName == null) {
|
||||
return null;
|
||||
}
|
||||
else if (isStoresUpperCaseIdentifiers()) {
|
||||
return parameterName.toUpperCase();
|
||||
}
|
||||
else if (isStoresLowerCaseIdentifiers()) {
|
||||
return parameterName.toLowerCase();
|
||||
}
|
||||
else {
|
||||
return parameterName;
|
||||
}
|
||||
return identifierNameToUse(parameterName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -316,6 +273,22 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
|||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private String identifierNameToUse(@Nullable String identifierName) {
|
||||
if (identifierName == null) {
|
||||
return null;
|
||||
}
|
||||
else if (isStoresUpperCaseIdentifiers()) {
|
||||
return identifierName.toUpperCase();
|
||||
}
|
||||
else if (isStoresLowerCaseIdentifiers()) {
|
||||
return identifierName.toLowerCase();
|
||||
}
|
||||
else {
|
||||
return identifierName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the procedure column meta-data.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue