org.springframework.jdbc.object
Class SqlCall

java.lang.Object
  extended by org.springframework.jdbc.object.RdbmsOperation
      extended by org.springframework.jdbc.object.SqlCall
All Implemented Interfaces:
InitializingBean
Direct Known Subclasses:
StoredProcedure

public abstract class SqlCall
extends RdbmsOperation

RdbmsOperation using a JdbcTemplate and representing a SQL-based call such as a stored procedure or a stored function.

Configures a CallableStatementCreatorFactory based on the declared parameters.

Author:
Rod Johnson, Thomas Risberg
See Also:
CallableStatementCreatorFactory

Field Summary
private  CallableStatementCreatorFactory callableStatementFactory
          Object enabling us to create CallableStatementCreators efficiently, based on this class's declared parameters.
private  java.lang.String callString
          Call string as defined in java.sql.CallableStatement.
private  boolean function
          Flag used to indicate that this call is for a function and to use the {? = call get_invoice_count(?)} syntax.
private  boolean sqlReadyForUse
          Flag used to indicate that the sql for this call should be used exactly as it is defined.
 
Fields inherited from class org.springframework.jdbc.object.RdbmsOperation
logger
 
Constructor Summary
SqlCall()
          Constructor to allow use as a JavaBean.
SqlCall(javax.sql.DataSource ds, java.lang.String sql)
          Create a new SqlCall object with SQL, but without parameters.
 
Method Summary
protected  void compileInternal()
          Overridden method to configure the CallableStatementCreatorFactory based on our declared parameters.
 java.lang.String getCallString()
          Get the call string.
 boolean isFunction()
          Return whether this call is for a function.
 boolean isSqlReadyForUse()
          Return whether the SQL can be used as is.
protected  CallableStatementCreator newCallableStatementCreator(java.util.Map<java.lang.String,?> inParams)
          Return a CallableStatementCreator to perform an operation with this parameters.
protected  CallableStatementCreator newCallableStatementCreator(ParameterMapper inParamMapper)
          Return a CallableStatementCreator to perform an operation with the parameters returned from this ParameterMapper.
protected  void onCompileInternal()
          Hook method that subclasses may override to react to compilation.
 void setFunction(boolean function)
          Set whether this call is for a function.
 void setSqlReadyForUse(boolean sqlReadyForUse)
          Set whether the SQL can be used as is.
 
Methods inherited from class org.springframework.jdbc.object.RdbmsOperation
afterPropertiesSet, allowsUnusedParameters, checkCompiled, compile, declareParameter, getDeclaredParameters, getGeneratedKeysColumnNames, getJdbcTemplate, getResultSetType, getSql, isCompiled, isReturnGeneratedKeys, isUpdatableResults, setDataSource, setFetchSize, setGeneratedKeysColumnNames, setJdbcTemplate, setMaxRows, setParameters, setQueryTimeout, setResultSetType, setReturnGeneratedKeys, setSql, setTypes, setUpdatableResults, supportsLobParameters, validateNamedParameters, validateParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

callableStatementFactory

private CallableStatementCreatorFactory callableStatementFactory
Object enabling us to create CallableStatementCreators efficiently, based on this class's declared parameters.


function

private boolean function
Flag used to indicate that this call is for a function and to use the {? = call get_invoice_count(?)} syntax.


sqlReadyForUse

private boolean sqlReadyForUse
Flag used to indicate that the sql for this call should be used exactly as it is defined. No need to add the escape syntax and parameter place holders.


callString

private java.lang.String callString
Call string as defined in java.sql.CallableStatement. String of form {call add_invoice(?, ?, ?)} or {? = call get_invoice_count(?)} if isFunction is set to true Updated after each parameter is added.

Constructor Detail

SqlCall

public SqlCall()
Constructor to allow use as a JavaBean. A DataSource, SQL and any parameters must be supplied before invoking the compile method and using this object.

See Also:
RdbmsOperation.setDataSource(javax.sql.DataSource), RdbmsOperation.setSql(java.lang.String), RdbmsOperation.compile()

SqlCall

public SqlCall(javax.sql.DataSource ds,
               java.lang.String sql)
Create a new SqlCall object with SQL, but without parameters. Must add parameters or settle with none.

Parameters:
ds - DataSource to obtain connections from
sql - SQL to execute
Method Detail

setFunction

public void setFunction(boolean function)
Set whether this call is for a function.


isFunction

public boolean isFunction()
Return whether this call is for a function.


setSqlReadyForUse

public void setSqlReadyForUse(boolean sqlReadyForUse)
Set whether the SQL can be used as is.


isSqlReadyForUse

public boolean isSqlReadyForUse()
Return whether the SQL can be used as is.


compileInternal

protected final void compileInternal()
Overridden method to configure the CallableStatementCreatorFactory based on our declared parameters.

Specified by:
compileInternal in class RdbmsOperation
See Also:
RdbmsOperation.compileInternal()

onCompileInternal

protected void onCompileInternal()
Hook method that subclasses may override to react to compilation. This implementation does nothing.


getCallString

public java.lang.String getCallString()
Get the call string.


newCallableStatementCreator

protected CallableStatementCreator newCallableStatementCreator(java.util.Map<java.lang.String,?> inParams)
Return a CallableStatementCreator to perform an operation with this parameters.

Parameters:
inParams - parameters. May be null.

newCallableStatementCreator

protected CallableStatementCreator newCallableStatementCreator(ParameterMapper inParamMapper)
Return a CallableStatementCreator to perform an operation with the parameters returned from this ParameterMapper.

Parameters:
inParamMapper - parametermapper. May not be null.