CallParameterMetaData detects function return parameter specifically
Closes gh-25588
This commit is contained in:
parent
613b05d814
commit
e797398b10
|
|
@ -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.
|
||||
|
|
@ -30,25 +30,39 @@ import org.springframework.lang.Nullable;
|
|||
*/
|
||||
public class CallParameterMetaData {
|
||||
|
||||
@Nullable
|
||||
private String parameterName;
|
||||
|
||||
private int parameterType;
|
||||
|
||||
private int sqlType;
|
||||
private final boolean function;
|
||||
|
||||
@Nullable
|
||||
private String typeName;
|
||||
private final String parameterName;
|
||||
|
||||
private boolean nullable;
|
||||
private final int parameterType;
|
||||
|
||||
private final int sqlType;
|
||||
|
||||
@Nullable
|
||||
private final String typeName;
|
||||
|
||||
private final boolean nullable;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor taking all the properties.
|
||||
* Constructor taking all the properties except the function marker.
|
||||
*/
|
||||
@Deprecated
|
||||
public CallParameterMetaData(
|
||||
@Nullable String columnName, int columnType, int sqlType, @Nullable String typeName, boolean nullable) {
|
||||
|
||||
this(false, columnName, columnType, sqlType, typeName, nullable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor taking all the properties including the function marker.
|
||||
* @since 5.2.9
|
||||
*/
|
||||
public CallParameterMetaData(boolean function, @Nullable String columnName, int columnType,
|
||||
int sqlType, @Nullable String typeName, boolean nullable) {
|
||||
|
||||
this.function = function;
|
||||
this.parameterName = columnName;
|
||||
this.parameterType = columnType;
|
||||
this.sqlType = sqlType;
|
||||
|
|
@ -58,7 +72,15 @@ public class CallParameterMetaData {
|
|||
|
||||
|
||||
/**
|
||||
* Get the parameter name.
|
||||
* Return whether this parameter is declared in a function.
|
||||
* @since 5.2.9
|
||||
*/
|
||||
public boolean isFunction() {
|
||||
return this.function;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the parameter name.
|
||||
*/
|
||||
@Nullable
|
||||
public String getParameterName() {
|
||||
|
|
@ -66,7 +88,7 @@ public class CallParameterMetaData {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the parameter type.
|
||||
* Return the parameter type.
|
||||
*/
|
||||
public int getParameterType() {
|
||||
return this.parameterType;
|
||||
|
|
@ -75,23 +97,25 @@ public class CallParameterMetaData {
|
|||
/**
|
||||
* Determine whether the declared parameter qualifies as a 'return' parameter
|
||||
* for our purposes: type {@link DatabaseMetaData#procedureColumnReturn} or
|
||||
* {@link DatabaseMetaData#procedureColumnResult}.
|
||||
* {@link DatabaseMetaData#procedureColumnResult}, or in case of a function,
|
||||
* {@link DatabaseMetaData#functionReturn}.
|
||||
* @since 4.3.15
|
||||
*/
|
||||
public boolean isReturnParameter() {
|
||||
return (this.parameterType == DatabaseMetaData.procedureColumnReturn ||
|
||||
this.parameterType == DatabaseMetaData.procedureColumnResult);
|
||||
return (this.function ? this.parameterType == DatabaseMetaData.functionReturn :
|
||||
(this.parameterType == DatabaseMetaData.procedureColumnReturn ||
|
||||
this.parameterType == DatabaseMetaData.procedureColumnResult));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parameter SQL type.
|
||||
* Return the parameter SQL type.
|
||||
*/
|
||||
public int getSqlType() {
|
||||
return this.sqlType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parameter type name.
|
||||
* Return the parameter type name.
|
||||
*/
|
||||
@Nullable
|
||||
public String getTypeName() {
|
||||
|
|
@ -99,7 +123,7 @@ public class CallParameterMetaData {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get whether the parameter is nullable.
|
||||
* Return whether the parameter is nullable.
|
||||
*/
|
||||
public boolean isNullable() {
|
||||
return this.nullable;
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
|||
}
|
||||
else {
|
||||
int nullable = (function ? DatabaseMetaData.functionNullable : DatabaseMetaData.procedureNullable);
|
||||
CallParameterMetaData meta = new CallParameterMetaData(columnName, columnType,
|
||||
CallParameterMetaData meta = new CallParameterMetaData(function, columnName, columnType,
|
||||
columns.getInt("DATA_TYPE"), columns.getString("TYPE_NAME"),
|
||||
columns.getInt("NULLABLE") == nullable);
|
||||
this.callParameterMetaData.add(meta);
|
||||
|
|
|
|||
Loading…
Reference in New Issue