public class SimpleJdbcCall extends AbstractJdbcCall implements 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 insert 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.
DatabaseMetaData,
JdbcTemplatelogger| Constructor and Description |
|---|
SimpleJdbcCall(javax.sql.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.
|
| Modifier and Type | Method and Description |
|---|---|
SimpleJdbcCall |
declareParameters(SqlParameter... sqlParameters)
Specify one or more parameters if desired.
|
java.util.Map<java.lang.String,java.lang.Object> |
execute(java.util.Map<java.lang.String,?> args)
Execute the stored procedure and return a map of output params, keyed by name
as in parameter declarations.
|
java.util.Map<java.lang.String,java.lang.Object> |
execute(java.lang.Object... args)
Execute the stored procedure and return a map of output params, keyed by name
as in parameter declarations.
|
java.util.Map<java.lang.String,java.lang.Object> |
execute(SqlParameterSource parameterSource)
Execute the stored procedure and return a map of output params, keyed by name
as in parameter declarations.
|
<T> T |
executeFunction(java.lang.Class<T> returnType,
java.util.Map<java.lang.String,?> args)
Execute the stored function and return the results obtained as an Object of the
specified return type.
|
<T> T |
executeFunction(java.lang.Class<T> returnType,
java.lang.Object... args)
Execute the stored function and return the results obtained as an Object of the
specified return type.
|
<T> T |
executeFunction(java.lang.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(java.lang.Class<T> returnType,
java.util.Map<java.lang.String,?> args)
Execute the stored procedure and return the single out parameter as an Object
of the specified return type.
|
<T> T |
executeObject(java.lang.Class<T> returnType,
java.lang.Object... args)
Execute the stored procedure and return the single out parameter as an Object
of the specified return type.
|
<T> T |
executeObject(java.lang.Class<T> returnType,
SqlParameterSource args)
Execute the stored procedure and return the single out parameter as an Object
of the specified return type.
|
SimpleJdbcCall |
returningResultSet(java.lang.String parameterName,
RowMapper<?> rowMapper)
Used to specify when a ResultSet is returned by the stored procedure and you want it
mapped by a
RowMapper. |
SimpleJdbcCall |
useInParameterNames(java.lang.String... inParameterNames)
Not used yet
|
SimpleJdbcCall |
withCatalogName(java.lang.String catalogName)
Optionally, specify the name of the catalog that contins the stored procedure.
|
SimpleJdbcCall |
withFunctionName(java.lang.String functionName)
Specify the procedure name to be used - this implies that we will be calling a stored function.
|
SimpleJdbcCall |
withNamedBinding()
Indicates that parameters should be bound by name.
|
SimpleJdbcCall |
withoutProcedureColumnMetaDataAccess()
Turn off any processing of parameter meta-data information obtained via JDBC.
|
SimpleJdbcCall |
withProcedureName(java.lang.String procedureName)
Specify the procedure name to be used - this implies that we will be calling a stored procedure.
|
SimpleJdbcCall |
withReturnValue()
Indicates the procedure's return value should be included in the results returned.
|
SimpleJdbcCall |
withSchemaName(java.lang.String schemaName)
Optionally, specify the name of the schema that contins the stored procedure.
|
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, setSchemaNamepublic SimpleJdbcCall(javax.sql.DataSource dataSource)
dataSource - the DataSource to useJdbcAccessor.setDataSource(javax.sql.DataSource)public SimpleJdbcCall(JdbcTemplate jdbcTemplate)
jdbcTemplate - the JdbcTemplate to useJdbcAccessor.setDataSource(javax.sql.DataSource)public SimpleJdbcCall withProcedureName(java.lang.String procedureName)
SimpleJdbcCallOperationswithProcedureName in interface SimpleJdbcCallOperationsprocedureName - the name of the stored procedurepublic SimpleJdbcCall withFunctionName(java.lang.String functionName)
SimpleJdbcCallOperationswithFunctionName in interface SimpleJdbcCallOperationsfunctionName - the name of the stored functionpublic SimpleJdbcCall withSchemaName(java.lang.String schemaName)
SimpleJdbcCallOperationswithSchemaName in interface SimpleJdbcCallOperationsschemaName - the name of the schemapublic SimpleJdbcCall withCatalogName(java.lang.String catalogName)
SimpleJdbcCallOperationsTo provide consistency with the Oracle DatabaseMetaData, this is used to specify the package name if the procedure is declared as part of a package.
withCatalogName in interface SimpleJdbcCallOperationscatalogName - the catalog or package namepublic SimpleJdbcCall withReturnValue()
SimpleJdbcCallOperationswithReturnValue in interface SimpleJdbcCallOperationspublic SimpleJdbcCall declareParameters(SqlParameter... sqlParameters)
SimpleJdbcCallOperationsNote that 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.
declareParameters in interface SimpleJdbcCallOperationssqlParameters - the parameters to usepublic SimpleJdbcCall useInParameterNames(java.lang.String... inParameterNames)
SimpleJdbcCallOperationsuseInParameterNames in interface SimpleJdbcCallOperationspublic SimpleJdbcCall returningResultSet(java.lang.String parameterName, RowMapper<?> rowMapper)
SimpleJdbcCallOperationsRowMapper. 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.
returningResultSet in interface SimpleJdbcCallOperationsparameterName - 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 rowpublic SimpleJdbcCall withoutProcedureColumnMetaDataAccess()
SimpleJdbcCallOperationswithoutProcedureColumnMetaDataAccess in interface SimpleJdbcCallOperationspublic SimpleJdbcCall withNamedBinding()
SimpleJdbcCallOperationswithNamedBinding in interface SimpleJdbcCallOperationspublic <T> T executeFunction(java.lang.Class<T> returnType,
java.lang.Object... args)
SimpleJdbcCallOperationsexecuteFunction in interface SimpleJdbcCallOperationsreturnType - 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.public <T> T executeFunction(java.lang.Class<T> returnType,
java.util.Map<java.lang.String,?> args)
SimpleJdbcCallOperationsexecuteFunction in interface SimpleJdbcCallOperationsreturnType - the type of the value to returnargs - Map containing the parameter values to be used in the callpublic <T> T executeFunction(java.lang.Class<T> returnType,
SqlParameterSource args)
SimpleJdbcCallOperationsexecuteFunction in interface SimpleJdbcCallOperationsreturnType - the type of the value to returnargs - MapSqlParameterSource containing the parameter values to be used in the callpublic <T> T executeObject(java.lang.Class<T> returnType,
java.lang.Object... args)
SimpleJdbcCallOperationsexecuteObject in interface SimpleJdbcCallOperationsreturnType - 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.public <T> T executeObject(java.lang.Class<T> returnType,
java.util.Map<java.lang.String,?> args)
SimpleJdbcCallOperationsexecuteObject in interface SimpleJdbcCallOperationsreturnType - the type of the value to returnargs - Map containing the parameter values to be used in the callpublic <T> T executeObject(java.lang.Class<T> returnType,
SqlParameterSource args)
SimpleJdbcCallOperationsexecuteObject in interface SimpleJdbcCallOperationsreturnType - the type of the value to returnargs - MapSqlParameterSource containing the parameter values to be used in the callpublic java.util.Map<java.lang.String,java.lang.Object> execute(java.lang.Object... args)
SimpleJdbcCallOperationsexecute in interface SimpleJdbcCallOperationsargs - 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.public java.util.Map<java.lang.String,java.lang.Object> execute(java.util.Map<java.lang.String,?> args)
SimpleJdbcCallOperationsexecute in interface SimpleJdbcCallOperationsargs - Map containing the parameter values to be used in the callpublic java.util.Map<java.lang.String,java.lang.Object> execute(SqlParameterSource parameterSource)
SimpleJdbcCallOperationsexecute in interface SimpleJdbcCallOperationsparameterSource - SqlParameterSource containing the parameter values to be used in the call