Class SimpleJdbcCall
- All Implemented Interfaces:
SimpleJdbcCallOperations
The meta-data processing is based on the DatabaseMetaData provided by the JDBC driver. Since we rely on the JDBC driver, this "auto-detection" can only be used for databases that are known to provide accurate meta-data. These currently include Derby, MySQL, Microsoft SQL Server, Oracle, DB2, Sybase and PostgreSQL. For any other databases you are required to declare all parameters explicitly. You can of course declare all parameters explicitly even if the database provides the necessary meta-data. In that case your declared parameters will take precedence. You can also turn off any meta-data processing if you want to use parameter names that do not match what is declared during the stored procedure compilation.
The actual call is being handled using Spring's JdbcTemplate
.
Many of the configuration methods return the current instance of the SimpleJdbcCall in order to provide the ability to chain multiple ones together in a "fluent" interface style.
- Since:
- 2.5
- Author:
- Thomas Risberg, Stephane Nicoll
- See Also:
-
Field Summary
Fields inherited from class org.springframework.jdbc.core.simple.AbstractJdbcCall
logger
-
Constructor Summary
ConstructorDescriptionSimpleJdbcCall
(DataSource dataSource) Constructor that takes one parameter with the JDBC DataSource to use when creating the underlying JdbcTemplate.SimpleJdbcCall
(JdbcTemplate jdbcTemplate) Alternative Constructor that takes one parameter with the JdbcTemplate to be used. -
Method Summary
Modifier and TypeMethodDescriptiondeclareParameters
(SqlParameter... sqlParameters) Specify one or more parameters if desired.Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.execute
(SqlParameterSource parameterSource) Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.<T> T
executeFunction
(Class<T> returnType, Object... args) Execute the stored function and return the results obtained as an Object of the specified return type.<T> T
executeFunction
(Class<T> returnType, Map<String, ?> args) Execute the stored function and return the results obtained as an Object of the specified return type.<T> T
executeFunction
(Class<T> returnType, SqlParameterSource args) Execute the stored function and return the results obtained as an Object of the specified return type.<T> T
executeObject
(Class<T> returnType, Object... args) Execute the stored procedure and return the single out parameter as an Object of the specified return type.<T> T
executeObject
(Class<T> returnType, Map<String, ?> args) Execute the stored procedure and return the single out parameter as an Object of the specified return type.<T> T
executeObject
(Class<T> returnType, SqlParameterSource args) Execute the stored procedure and return the single out parameter as an Object of the specified return type.returningResultSet
(String parameterName, RowMapper<?> rowMapper) Used to specify when a ResultSet is returned by the stored procedure and you want it mapped by aRowMapper
.useInParameterNames
(String... inParameterNames) Not used yet.withCatalogName
(String catalogName) Optionally, specify the name of the catalog that contains the stored procedure.withFunctionName
(String functionName) Specify the procedure name to be used - this implies that we will be calling a stored function.Indicates that parameters should be bound by name.Turn off any processing of parameter meta-data information obtained via JDBC.withProcedureName
(String procedureName) Specify the procedure name to be used - this implies that we will be calling a stored procedure.Indicates the procedure's return value should be included in the results returned.withSchemaName
(String schemaName) Optionally, specify the name of the schema that contains the stored procedure.Methods inherited from class org.springframework.jdbc.core.simple.AbstractJdbcCall
addDeclaredParameter, addDeclaredRowMapper, checkCompiled, compile, compileInternal, doExecute, doExecute, doExecute, getCallableStatementFactory, getCallParameters, getCallString, getCatalogName, getInParameterNames, getJdbcTemplate, getProcedureName, getScalarOutParameterName, getSchemaName, isCompiled, isFunction, isNamedBinding, isReturnValueRequired, matchInParameterValuesWithCallParameters, matchInParameterValuesWithCallParameters, onCompileInternal, setAccessCallParameterMetaData, setCatalogName, setFunction, setInParameterNames, setNamedBinding, setProcedureName, setReturnValueRequired, setSchemaName
-
Constructor Details
-
SimpleJdbcCall
Constructor that takes one parameter with the JDBC DataSource to use when creating the underlying JdbcTemplate.- Parameters:
dataSource
- theDataSource
to use- See Also:
-
SimpleJdbcCall
Alternative Constructor that takes one parameter with the JdbcTemplate to be used.- Parameters:
jdbcTemplate
- theJdbcTemplate
to use- See Also:
-
-
Method Details
-
withProcedureName
Description copied from interface:SimpleJdbcCallOperations
Specify the procedure name to be used - this implies that we will be calling a stored procedure.- Specified by:
withProcedureName
in interfaceSimpleJdbcCallOperations
- Parameters:
procedureName
- the name of the stored procedure- Returns:
- the instance of this SimpleJdbcCall
-
withFunctionName
Description copied from interface:SimpleJdbcCallOperations
Specify the procedure name to be used - this implies that we will be calling a stored function.- Specified by:
withFunctionName
in interfaceSimpleJdbcCallOperations
- Parameters:
functionName
- the name of the stored function- Returns:
- the instance of this SimpleJdbcCall
-
withSchemaName
Description copied from interface:SimpleJdbcCallOperations
Optionally, specify the name of the schema that contains the stored procedure.- Specified by:
withSchemaName
in interfaceSimpleJdbcCallOperations
- Parameters:
schemaName
- the name of the schema- Returns:
- the instance of this SimpleJdbcCall
-
withCatalogName
Description copied from interface:SimpleJdbcCallOperations
Optionally, specify the name of the catalog that contains the stored procedure.To provide consistency with the Oracle DatabaseMetaData, this is used to specify the package name if the procedure is declared as part of a package.
- Specified by:
withCatalogName
in interfaceSimpleJdbcCallOperations
- Parameters:
catalogName
- the catalog or package name- Returns:
- the instance of this SimpleJdbcCall
-
withReturnValue
Description copied from interface:SimpleJdbcCallOperations
Indicates the procedure's return value should be included in the results returned.- Specified by:
withReturnValue
in interfaceSimpleJdbcCallOperations
- Returns:
- the instance of this SimpleJdbcCall
-
declareParameters
Description copied from interface:SimpleJdbcCallOperations
Specify one or more parameters if desired. These parameters will be supplemented with any parameter information retrieved from the database meta-data.Note that only parameters declared as
SqlParameter
andSqlInOutParameter
will be used to provide input values. This is different from theStoredProcedure
class which - for backwards compatibility reasons - allows input values to be provided for parameters declared asSqlOutParameter
.- Specified by:
declareParameters
in interfaceSimpleJdbcCallOperations
- Parameters:
sqlParameters
- the parameters to use- Returns:
- the instance of this SimpleJdbcCall
-
useInParameterNames
Description copied from interface:SimpleJdbcCallOperations
Not used yet.- Specified by:
useInParameterNames
in interfaceSimpleJdbcCallOperations
-
returningResultSet
Description copied from interface:SimpleJdbcCallOperations
Used to specify when a ResultSet is returned by the stored procedure and you want it mapped by aRowMapper
. The results will be returned using the parameter name specified. Multiple ResultSets must be declared in the correct order.If the database you are using uses ref cursors then the name specified must match the name of the parameter declared for the procedure in the database.
- Specified by:
returningResultSet
in interfaceSimpleJdbcCallOperations
- Parameters:
parameterName
- the name of the returned results and/or the name of the ref cursor parameterrowMapper
- the RowMapper implementation that will map the data returned for each row
-
withoutProcedureColumnMetaDataAccess
Description copied from interface:SimpleJdbcCallOperations
Turn off any processing of parameter meta-data information obtained via JDBC.- Specified by:
withoutProcedureColumnMetaDataAccess
in interfaceSimpleJdbcCallOperations
- Returns:
- the instance of this SimpleJdbcCall
-
withNamedBinding
Description copied from interface:SimpleJdbcCallOperations
Indicates that parameters should be bound by name.- Specified by:
withNamedBinding
in interfaceSimpleJdbcCallOperations
- Returns:
- the instance of this SimpleJdbcCall
-
executeFunction
Description copied from interface:SimpleJdbcCallOperations
Execute the stored function and return the results obtained as an Object of the specified return type.- Specified by:
executeFunction
in interfaceSimpleJdbcCallOperations
- Parameters:
returnType
- the type of the value to returnargs
- optional array containing the in parameter values to be used in the call. Parameter values must be provided in the same order as the parameters are defined for the stored procedure.
-
executeFunction
Description copied from interface:SimpleJdbcCallOperations
Execute the stored function and return the results obtained as an Object of the specified return type.- Specified by:
executeFunction
in interfaceSimpleJdbcCallOperations
- Parameters:
returnType
- the type of the value to returnargs
- a Map containing the parameter values to be used in the call
-
executeFunction
Description copied from interface:SimpleJdbcCallOperations
Execute the stored function and return the results obtained as an Object of the specified return type.- Specified by:
executeFunction
in interfaceSimpleJdbcCallOperations
- Parameters:
returnType
- the type of the value to returnargs
- the MapSqlParameterSource containing the parameter values to be used in the call
-
executeObject
Description copied from interface:SimpleJdbcCallOperations
Execute the stored procedure and return the single out parameter as an Object of the specified return type. In the case where there are multiple out parameters, the first one is returned and additional out parameters are ignored.- Specified by:
executeObject
in interfaceSimpleJdbcCallOperations
- Parameters:
returnType
- the type of the value to returnargs
- optional array containing the in parameter values to be used in the call. Parameter values must be provided in the same order as the parameters are defined for the stored procedure.
-
executeObject
Description copied from interface:SimpleJdbcCallOperations
Execute the stored procedure and return the single out parameter as an Object of the specified return type. In the case where there are multiple out parameters, the first one is returned and additional out parameters are ignored.- Specified by:
executeObject
in interfaceSimpleJdbcCallOperations
- Parameters:
returnType
- the type of the value to returnargs
- a Map containing the parameter values to be used in the call
-
executeObject
Description copied from interface:SimpleJdbcCallOperations
Execute the stored procedure and return the single out parameter as an Object of the specified return type. In the case where there are multiple out parameters, the first one is returned and additional out parameters are ignored.- Specified by:
executeObject
in interfaceSimpleJdbcCallOperations
- Parameters:
returnType
- the type of the value to returnargs
- the MapSqlParameterSource containing the parameter values to be used in the call
-
execute
Description copied from interface:SimpleJdbcCallOperations
Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.- Specified by:
execute
in interfaceSimpleJdbcCallOperations
- Parameters:
args
- optional array containing the in parameter values to be used in the call. Parameter values must be provided in the same order as the parameters are defined for the stored procedure.- Returns:
- a Map of output params
-
execute
Description copied from interface:SimpleJdbcCallOperations
Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.- Specified by:
execute
in interfaceSimpleJdbcCallOperations
- Parameters:
args
- a Map containing the parameter values to be used in the call- Returns:
- a Map of output params
-
execute
Description copied from interface:SimpleJdbcCallOperations
Execute the stored procedure and return a map of output params, keyed by name as in parameter declarations.- Specified by:
execute
in interfaceSimpleJdbcCallOperations
- Parameters:
parameterSource
- the SqlParameterSource containing the parameter values to be used in the call- Returns:
- a Map of output params
-