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");
|
* 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.
|
||||||
|
|
@ -30,25 +30,39 @@ import org.springframework.lang.Nullable;
|
||||||
*/
|
*/
|
||||||
public class CallParameterMetaData {
|
public class CallParameterMetaData {
|
||||||
|
|
||||||
@Nullable
|
private final boolean function;
|
||||||
private String parameterName;
|
|
||||||
|
|
||||||
private int parameterType;
|
|
||||||
|
|
||||||
private int sqlType;
|
|
||||||
|
|
||||||
@Nullable
|
@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(
|
public CallParameterMetaData(
|
||||||
@Nullable String columnName, int columnType, int sqlType, @Nullable String typeName, boolean nullable) {
|
@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.parameterName = columnName;
|
||||||
this.parameterType = columnType;
|
this.parameterType = columnType;
|
||||||
this.sqlType = sqlType;
|
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
|
@Nullable
|
||||||
public String getParameterName() {
|
public String getParameterName() {
|
||||||
|
|
@ -66,7 +88,7 @@ public class CallParameterMetaData {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the parameter type.
|
* Return the parameter type.
|
||||||
*/
|
*/
|
||||||
public int getParameterType() {
|
public int getParameterType() {
|
||||||
return this.parameterType;
|
return this.parameterType;
|
||||||
|
|
@ -75,23 +97,25 @@ public class CallParameterMetaData {
|
||||||
/**
|
/**
|
||||||
* Determine whether the declared parameter qualifies as a 'return' parameter
|
* Determine whether the declared parameter qualifies as a 'return' parameter
|
||||||
* for our purposes: type {@link DatabaseMetaData#procedureColumnReturn} or
|
* 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
|
* @since 4.3.15
|
||||||
*/
|
*/
|
||||||
public boolean isReturnParameter() {
|
public boolean isReturnParameter() {
|
||||||
return (this.parameterType == DatabaseMetaData.procedureColumnReturn ||
|
return (this.function ? this.parameterType == DatabaseMetaData.functionReturn :
|
||||||
this.parameterType == DatabaseMetaData.procedureColumnResult);
|
(this.parameterType == DatabaseMetaData.procedureColumnReturn ||
|
||||||
|
this.parameterType == DatabaseMetaData.procedureColumnResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the parameter SQL type.
|
* Return the parameter SQL type.
|
||||||
*/
|
*/
|
||||||
public int getSqlType() {
|
public int getSqlType() {
|
||||||
return this.sqlType;
|
return this.sqlType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the parameter type name.
|
* Return the parameter type name.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getTypeName() {
|
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() {
|
public boolean isNullable() {
|
||||||
return this.nullable;
|
return this.nullable;
|
||||||
|
|
|
||||||
|
|
@ -399,7 +399,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int nullable = (function ? DatabaseMetaData.functionNullable : DatabaseMetaData.procedureNullable);
|
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("DATA_TYPE"), columns.getString("TYPE_NAME"),
|
||||||
columns.getInt("NULLABLE") == nullable);
|
columns.getInt("NULLABLE") == nullable);
|
||||||
this.callParameterMetaData.add(meta);
|
this.callParameterMetaData.add(meta);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue