|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2013 the original author or authors. |
|
|
|
|
* Copyright 2002-2014 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. |
|
|
|
|
@ -53,6 +53,9 @@ public abstract class AbstractJdbcCall {
@@ -53,6 +53,9 @@ public abstract class AbstractJdbcCall {
|
|
|
|
|
/** Lower-level class used to execute SQL */ |
|
|
|
|
private final JdbcTemplate jdbcTemplate; |
|
|
|
|
|
|
|
|
|
/** Context used to retrieve and manage database metadata */ |
|
|
|
|
private final CallMetaDataContext callMetaDataContext = new CallMetaDataContext(); |
|
|
|
|
|
|
|
|
|
/** List of SqlParameter objects */ |
|
|
|
|
private final List<SqlParameter> declaredParameters = new ArrayList<SqlParameter>(); |
|
|
|
|
|
|
|
|
|
@ -66,12 +69,9 @@ public abstract class AbstractJdbcCall {
@@ -66,12 +69,9 @@ public abstract class AbstractJdbcCall {
|
|
|
|
|
*/ |
|
|
|
|
private boolean compiled = false; |
|
|
|
|
|
|
|
|
|
/** the generated string used for call statement */ |
|
|
|
|
/** The generated string used for call statement */ |
|
|
|
|
private String callString; |
|
|
|
|
|
|
|
|
|
/** context used to retrieve and manage database metadata */ |
|
|
|
|
private CallMetaDataContext callMetaDataContext = new CallMetaDataContext(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Object enabling us to create CallableStatementCreators |
|
|
|
|
* efficiently, based on this class's declared parameters. |
|
|
|
|
@ -103,13 +103,6 @@ public abstract class AbstractJdbcCall {
@@ -103,13 +103,6 @@ public abstract class AbstractJdbcCall {
|
|
|
|
|
return this.jdbcTemplate; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the {@link CallableStatementCreatorFactory} being used |
|
|
|
|
*/ |
|
|
|
|
protected CallableStatementCreatorFactory getCallableStatementFactory() { |
|
|
|
|
return this.callableStatementFactory; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Set the name of the stored procedure. |
|
|
|
|
*/ |
|
|
|
|
@ -153,7 +146,7 @@ public abstract class AbstractJdbcCall {
@@ -153,7 +146,7 @@ public abstract class AbstractJdbcCall {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Set the schema name to use, |
|
|
|
|
* Set the schema name to use. |
|
|
|
|
*/ |
|
|
|
|
public void setSchemaName(String schemaName) { |
|
|
|
|
this.callMetaDataContext.setSchemaName(schemaName); |
|
|
|
|
@ -183,8 +176,8 @@ public abstract class AbstractJdbcCall {
@@ -183,8 +176,8 @@ public abstract class AbstractJdbcCall {
|
|
|
|
|
/** |
|
|
|
|
* Specify whether the call requires a rerurn value. |
|
|
|
|
*/ |
|
|
|
|
public void setReturnValueRequired(boolean b) { |
|
|
|
|
this.callMetaDataContext.setReturnValueRequired(b); |
|
|
|
|
public void setReturnValueRequired(boolean returnValueRequired) { |
|
|
|
|
this.callMetaDataContext.setReturnValueRequired(returnValueRequired); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -194,6 +187,28 @@ public abstract class AbstractJdbcCall {
@@ -194,6 +187,28 @@ public abstract class AbstractJdbcCall {
|
|
|
|
|
return this.callMetaDataContext.isReturnValueRequired(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Specify whether the parameter metadata for the call should be used. The default is true. |
|
|
|
|
*/ |
|
|
|
|
public void setAccessCallParameterMetaData(boolean accessCallParameterMetaData) { |
|
|
|
|
this.callMetaDataContext.setAccessCallParameterMetaData(accessCallParameterMetaData); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the call string that should be used based on parameters and meta data. |
|
|
|
|
*/ |
|
|
|
|
public String getCallString() { |
|
|
|
|
return this.callString; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the {@link CallableStatementCreatorFactory} being used |
|
|
|
|
*/ |
|
|
|
|
protected CallableStatementCreatorFactory getCallableStatementFactory() { |
|
|
|
|
return this.callableStatementFactory; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Add a declared parameter to the list of parameters for the call. |
|
|
|
|
* Only parameters declared as {@code SqlParameter} and {@code SqlInOutParameter} |
|
|
|
|
@ -235,20 +250,6 @@ public abstract class AbstractJdbcCall {
@@ -235,20 +250,6 @@ public abstract class AbstractJdbcCall {
|
|
|
|
|
addDeclaredRowMapper(parameterName, (RowMapper) rowMapper); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the call string that should be used based on parameters and meta data. |
|
|
|
|
*/ |
|
|
|
|
public String getCallString() { |
|
|
|
|
return this.callString; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Specify whether the parameter metadata for the call should be used. The default is true. |
|
|
|
|
*/ |
|
|
|
|
public void setAccessCallParameterMetaData(boolean accessCallParameterMetaData) { |
|
|
|
|
this.callMetaDataContext.setAccessCallParameterMetaData(accessCallParameterMetaData); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
// Methods handling compilation issues
|
|
|
|
|
@ -375,18 +376,21 @@ public abstract class AbstractJdbcCall {
@@ -375,18 +376,21 @@ public abstract class AbstractJdbcCall {
|
|
|
|
|
/** |
|
|
|
|
* Method to perform the actual call processing |
|
|
|
|
*/ |
|
|
|
|
private Map<String, Object> executeCallInternal(Map<String, ?> params) { |
|
|
|
|
CallableStatementCreator csc = getCallableStatementFactory().newCallableStatementCreator(params); |
|
|
|
|
private Map<String, Object> executeCallInternal(Map<String, ?> args) { |
|
|
|
|
CallableStatementCreator csc = getCallableStatementFactory().newCallableStatementCreator(args); |
|
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
|
logger.debug("The following parameters are used for call " + getCallString() + " with: " + params); |
|
|
|
|
logger.debug("The following parameters are used for call " + getCallString() + " with " + args); |
|
|
|
|
int i = 1; |
|
|
|
|
for (SqlParameter p : getCallParameters()) { |
|
|
|
|
logger.debug(i++ + ": " + p.getName() + " SQL Type "+ p.getSqlType() + " Type Name " + p.getTypeName() + " " + p.getClass().getName()); |
|
|
|
|
for (SqlParameter param : getCallParameters()) { |
|
|
|
|
logger.debug(i + ": " + param.getName() + ", SQL type "+ param.getSqlType() + ", type name " + |
|
|
|
|
param.getTypeName() + ", parameter class [" + param.getClass().getName() + "]"); |
|
|
|
|
i++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return getJdbcTemplate().call(csc, getCallParameters()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the name of a single out parameter or return value. |
|
|
|
|
* Used for functions or procedures with one out parameter. |
|
|
|
|
@ -395,6 +399,14 @@ public abstract class AbstractJdbcCall {
@@ -395,6 +399,14 @@ public abstract class AbstractJdbcCall {
|
|
|
|
|
return this.callMetaDataContext.getScalarOutParameterName(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get a List of all the call parameters to be used for call. This includes any parameters added |
|
|
|
|
* based on meta data processing. |
|
|
|
|
*/ |
|
|
|
|
protected List<SqlParameter> getCallParameters() { |
|
|
|
|
return this.callMetaDataContext.getCallParameters(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Match the provided in parameter values with registered parameters and |
|
|
|
|
* parameters defined via metadata processing. |
|
|
|
|
@ -425,12 +437,4 @@ public abstract class AbstractJdbcCall {
@@ -425,12 +437,4 @@ public abstract class AbstractJdbcCall {
|
|
|
|
|
return this.callMetaDataContext.matchInParameterValuesWithCallParameters(args); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get a List of all the call parameters to be used for call. This includes any parameters added |
|
|
|
|
* based on meta data processing. |
|
|
|
|
*/ |
|
|
|
|
protected List<SqlParameter> getCallParameters() { |
|
|
|
|
return this.callMetaDataContext.getCallParameters(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|