Class AbstractJdbcCall
java.lang.Object
org.springframework.jdbc.core.simple.AbstractJdbcCall
- Direct Known Subclasses:
SimpleJdbcCall
Abstract class to provide base functionality for easy stored procedure calls
based on configuration options and database meta-data.
This class provides the base SPI for SimpleJdbcCall.
- Since:
- 2.5
- Author:
- Thomas Risberg, Juergen Hoeller
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractJdbcCall(DataSource dataSource) Constructor to be used when initializing using aDataSource.protectedAbstractJdbcCall(JdbcTemplate jdbcTemplate) Constructor to be used when initializing using aJdbcTemplate. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDeclaredParameter(SqlParameter parameter) Add a declared parameter to the list of parameters for the call.voidaddDeclaredRowMapper(String parameterName, RowMapper<?> rowMapper) Add aRowMapperfor the specified parameter or column.protected voidCheck whether this operation has been compiled already; lazily compile it if not already compiled.final voidcompile()Compile this JdbcCall using provided parameters and meta-data plus other settings.protected voidDelegate method to perform the actual compilation.Delegate method that executes the call using the passed-in array of parameters.Delegate method that executes the call using the passed-in Map of parameters.doExecute(SqlParameterSource parameterSource) Delegate method that executes the call using the passed-inSqlParameterSource.protected CallableStatementCreatorFactoryGet theCallableStatementCreatorFactorybeing used.protected List<SqlParameter>Get a List of all the call parameters to be used for call.Get the call string that should be used based on parameters and meta-data.Get the catalog name used.Get the names of in parameters to be used.Get the configuredJdbcTemplate.Get the name of the stored procedure.protected StringGet the name of a single out parameter or return value.Get the schema name used.booleanIs this operation "compiled"?booleanIs this call a function call?booleanShould parameters be bound by name?booleanDoes the call require a return value?Match the provided in parameter values with registered parameters and parameters defined via meta-data processing.matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource) Match the provided in parameter values with registered parameters and parameters defined via meta-data processing.protected voidHook method that subclasses may override to react to compilation.voidsetAccessCallParameterMetaData(boolean accessCallParameterMetaData) Specify whether the parameter meta-data for the call should be used.voidsetCatalogName(String catalogName) Set the catalog name to use.voidsetFunction(boolean function) Specify whether this call is a function call.voidsetInParameterNames(Set<String> inParameterNames) Set the names of in parameters to be used.voidsetNamedBinding(boolean namedBinding) Specify whether parameters should be bound by name.voidsetProcedureName(String procedureName) Set the name of the stored procedure.voidsetReturnValueRequired(boolean returnValueRequired) Specify whether the call requires a return value.voidsetSchemaName(String schemaName) Set the schema name to use.
-
Field Details
-
logger
Logger available to subclasses.
-
-
Constructor Details
-
AbstractJdbcCall
Constructor to be used when initializing using aDataSource.- Parameters:
dataSource- the DataSource to be used
-
AbstractJdbcCall
Constructor to be used when initializing using aJdbcTemplate.- Parameters:
jdbcTemplate- the JdbcTemplate to use
-
-
Method Details
-
getJdbcTemplate
Get the configuredJdbcTemplate. -
setProcedureName
Set the name of the stored procedure. -
getProcedureName
Get the name of the stored procedure. -
setInParameterNames
Set the names of in parameters to be used. -
getInParameterNames
Get the names of in parameters to be used. -
setCatalogName
Set the catalog name to use. -
getCatalogName
Get the catalog name used. -
setSchemaName
Set the schema name to use. -
getSchemaName
Get the schema name used. -
setFunction
public void setFunction(boolean function) Specify whether this call is a function call. The default isfalse. -
isFunction
public boolean isFunction()Is this call a function call? -
setReturnValueRequired
public void setReturnValueRequired(boolean returnValueRequired) Specify whether the call requires a return value. The default isfalse. -
isReturnValueRequired
public boolean isReturnValueRequired()Does the call require a return value? -
setNamedBinding
public void setNamedBinding(boolean namedBinding) Specify whether parameters should be bound by name. The default isfalse.- Since:
- 4.2
-
isNamedBinding
public boolean isNamedBinding()Should parameters be bound by name?- Since:
- 4.2
-
setAccessCallParameterMetaData
public void setAccessCallParameterMetaData(boolean accessCallParameterMetaData) Specify whether the parameter meta-data for the call should be used. The default istrue. -
getCallString
Get the call string that should be used based on parameters and meta-data. -
getCallableStatementFactory
Get theCallableStatementCreatorFactorybeing used. -
addDeclaredParameter
Add a declared parameter to the list of parameters for the call.Only parameters declared as
SqlParameterandSqlInOutParameterwill be used to provide input values. This is different from theStoredProcedureclass which - for backwards compatibility reasons - allows input values to be provided for parameters declared asSqlOutParameter.- Parameters:
parameter- theSqlParameterto add
-
addDeclaredRowMapper
Add aRowMapperfor the specified parameter or column.- Parameters:
parameterName- name of parameter or columnrowMapper- the RowMapper implementation to use
-
compile
Compile this JdbcCall using provided parameters and meta-data plus other settings.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.
- Throws:
InvalidDataAccessApiUsageException- if the object hasn't been correctly initialized, for example if no DataSource has been provided
-
compileInternal
protected void compileInternal()Delegate method to perform the actual compilation.Subclasses can override this template method to perform their own compilation. Invoked after this base class's compilation is complete.
-
onCompileInternal
protected void onCompileInternal()Hook method that subclasses may override to react to compilation. This implementation does nothing. -
isCompiled
public boolean isCompiled()Is this operation "compiled"?- Returns:
- whether this operation is compiled and ready to use
-
checkCompiled
protected void checkCompiled()Check whether this operation has been compiled already; lazily compile it if not already compiled.Automatically called by all
doExecute(...)methods. -
doExecute
Delegate method that executes the call using the passed-inSqlParameterSource.- Parameters:
parameterSource- parameter names and values to be used in call- Returns:
- a Map of out parameters
-
doExecute
Delegate method that executes the call using the passed-in array of parameters.- Parameters:
args- array of parameter values. The order of values must match the order declared for the stored procedure.- Returns:
- a Map of out parameters
-
doExecute
Delegate method that executes the call using the passed-in Map of parameters.- Parameters:
args- a Map of parameter name and values- Returns:
- a Map of out parameters
-
getScalarOutParameterName
Get the name of a single out parameter or return value. Used for functions or procedures with one out parameter. -
getCallParameters
Get a List of all the call parameters to be used for call. This includes any parameters added based on meta-data processing. -
matchInParameterValuesWithCallParameters
protected Map<String,Object> matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource) Match the provided in parameter values with registered parameters and parameters defined via meta-data processing.- Parameters:
parameterSource- the parameter values provided as aSqlParameterSource- Returns:
- a Map with parameter names and values
-
matchInParameterValuesWithCallParameters
Match the provided in parameter values with registered parameters and parameters defined via meta-data processing.- Parameters:
args- the parameter values provided in a Map- Returns:
- a Map with parameter names and values
-