public abstract class AbstractJdbcCall
extends java.lang.Object
This class provides the base SPI for SimpleJdbcCall
.
Modifier and Type | Field and Description |
---|---|
protected Log |
logger
Logger available to subclasses
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractJdbcCall(javax.sql.DataSource dataSource)
Constructor to be used when initializing using a
DataSource . |
protected |
AbstractJdbcCall(JdbcTemplate jdbcTemplate)
Constructor to be used when initializing using a
JdbcTemplate . |
Modifier and Type | Method and Description |
---|---|
void |
addDeclaredParameter(SqlParameter parameter)
Add a declared parameter to the list of parameters for the call.
|
void |
addDeclaredRowMapper(java.lang.String parameterName,
RowMapper<?> rowMapper)
Add a
RowMapper for the specified parameter or column. |
protected void |
checkCompiled()
Check whether this operation has been compiled already;
lazily compile it if not already compiled.
|
void |
compile()
Compile this JdbcCall using provided parameters and meta-data plus other settings.
|
protected void |
compileInternal()
Delegate method to perform the actual compilation.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
doExecute(java.util.Map<java.lang.String,?> args)
Delegate method that executes the call using the passed-in Map of parameters.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
doExecute(java.lang.Object... args)
Delegate method that executes the call using the passed-in array of parameters.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
doExecute(SqlParameterSource parameterSource)
Delegate method that executes the call using the passed-in
SqlParameterSource . |
protected CallableStatementCreatorFactory |
getCallableStatementFactory()
Get the
CallableStatementCreatorFactory being used |
protected java.util.List<SqlParameter> |
getCallParameters()
Get a List of all the call parameters to be used for call.
|
java.lang.String |
getCallString()
Get the call string that should be used based on parameters and meta-data.
|
java.lang.String |
getCatalogName()
Get the catalog name used.
|
java.util.Set<java.lang.String> |
getInParameterNames()
Get the names of in parameters to be used.
|
JdbcTemplate |
getJdbcTemplate()
Get the configured
JdbcTemplate . |
java.lang.String |
getProcedureName()
Get the name of the stored procedure.
|
protected java.lang.String |
getScalarOutParameterName()
Get the name of a single out parameter or return value.
|
java.lang.String |
getSchemaName()
Get the schema name used.
|
boolean |
isCompiled()
Is this operation "compiled"?
|
boolean |
isFunction()
Is this call a function call?
|
boolean |
isNamedBinding()
Should parameters be bound by name?
|
boolean |
isReturnValueRequired()
Does the call require a return value?
|
protected java.util.Map<java.lang.String,?> |
matchInParameterValuesWithCallParameters(java.util.Map<java.lang.String,?> args)
Match the provided in parameter values with registered parameters and
parameters defined via meta-data processing.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource)
Match the provided in parameter values with registered parameters and
parameters defined via meta-data processing.
|
protected void |
onCompileInternal()
Hook method that subclasses may override to react to compilation.
|
void |
setAccessCallParameterMetaData(boolean accessCallParameterMetaData)
Specify whether the parameter meta-data for the call should be used.
|
void |
setCatalogName(java.lang.String catalogName)
Set the catalog name to use.
|
void |
setFunction(boolean function)
Specify whether this call is a function call.
|
void |
setInParameterNames(java.util.Set<java.lang.String> inParameterNames)
Set the names of in parameters to be used.
|
void |
setNamedBinding(boolean namedBinding)
Specify whether parameters should be bound by name.
|
void |
setProcedureName(java.lang.String procedureName)
Set the name of the stored procedure.
|
void |
setReturnValueRequired(boolean returnValueRequired)
Specify whether the call requires a return value.
|
void |
setSchemaName(java.lang.String schemaName)
Set the schema name to use.
|
protected final Log logger
protected AbstractJdbcCall(javax.sql.DataSource dataSource)
DataSource
.dataSource
- the DataSource to be usedprotected AbstractJdbcCall(JdbcTemplate jdbcTemplate)
JdbcTemplate
.jdbcTemplate
- the JdbcTemplate to usepublic JdbcTemplate getJdbcTemplate()
JdbcTemplate
.public void setProcedureName(@Nullable java.lang.String procedureName)
@Nullable public java.lang.String getProcedureName()
public void setInParameterNames(java.util.Set<java.lang.String> inParameterNames)
public java.util.Set<java.lang.String> getInParameterNames()
public void setCatalogName(@Nullable java.lang.String catalogName)
@Nullable public java.lang.String getCatalogName()
public void setSchemaName(@Nullable java.lang.String schemaName)
@Nullable public java.lang.String getSchemaName()
public void setFunction(boolean function)
false
.public boolean isFunction()
public void setReturnValueRequired(boolean returnValueRequired)
false
.public boolean isReturnValueRequired()
public void setNamedBinding(boolean namedBinding)
false
.public boolean isNamedBinding()
public void setAccessCallParameterMetaData(boolean accessCallParameterMetaData)
true
.@Nullable public java.lang.String getCallString()
protected CallableStatementCreatorFactory getCallableStatementFactory()
CallableStatementCreatorFactory
being usedpublic void addDeclaredParameter(SqlParameter parameter)
Only parameters declared as SqlParameter
and SqlInOutParameter
will
be used to provide input values. This is different from the StoredProcedure
class which - for backwards compatibility reasons - allows input values to be provided
for parameters declared as SqlOutParameter
.
parameter
- the SqlParameter
to addpublic void addDeclaredRowMapper(java.lang.String parameterName, RowMapper<?> rowMapper)
RowMapper
for the specified parameter or column.parameterName
- name of parameter or columnrowMapper
- the RowMapper implementation to usepublic final void compile() throws InvalidDataAccessApiUsageException
This finalizes the configuration for this object and subsequent attempts to compile are ignored. This will be implicitly called the first time an un-compiled call is executed.
InvalidDataAccessApiUsageException
- if the object hasn't
been correctly initialized, for example if no DataSource has been providedprotected void compileInternal()
Subclasses can override this template method to perform their own compilation. Invoked after this base class's compilation is complete.
protected void onCompileInternal()
public boolean isCompiled()
protected void checkCompiled()
Automatically called by doExecute
.
protected java.util.Map<java.lang.String,java.lang.Object> doExecute(SqlParameterSource parameterSource)
SqlParameterSource
.parameterSource
- parameter names and values to be used in callprotected java.util.Map<java.lang.String,java.lang.Object> doExecute(java.lang.Object... args)
args
- array of parameter values. The order of values must match the order
declared for the stored procedure.protected java.util.Map<java.lang.String,java.lang.Object> doExecute(java.util.Map<java.lang.String,?> args)
args
- Map of parameter name and values@Nullable protected java.lang.String getScalarOutParameterName()
protected java.util.List<SqlParameter> getCallParameters()
protected java.util.Map<java.lang.String,java.lang.Object> matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource)
parameterSource
- the parameter vakues provided as a SqlParameterSource
protected java.util.Map<java.lang.String,?> matchInParameterValuesWithCallParameters(java.util.Map<java.lang.String,?> args)
args
- the parameter values provided in a Map