Top Description Inners Fields Constructors Methods
org.springframework.jdbc.core

public Class CallableStatementCreatorFactory

extends Object
Class Inheritance
Imports
java.sql.CallableStatement, .Connection, .ResultSet, .SQLException, java.util.ArrayList, .HashMap, .List, .Map, org.springframework.dao.InvalidDataAccessApiUsageException, org.springframework.lang.Nullable

Helper class that efficiently creates multiple CallableStatementCreator objects with different parameters based on an SQL statement and a single set of parameter declarations.
Authors
Rod Johnson, Thomas Risberg, Juergen Hoeller

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
CallableStatementCreatorFactory.CallableStatementCreatorImpl

CallableStatementCreator implementation returned by this class.

Field Summary

Modifier and TypeField and Description
private final String
callString

The SQL call string, which won't change when the parameters change.

private final List<SqlParameter>
declaredParameters

List of SqlParameter objects.

private int
private boolean

Constructor Summary

AccessConstructor and Description
public
CallableStatementCreatorFactory(String
the SQL call string
callString
)

Create a new factory.

public
CallableStatementCreatorFactory(String
the SQL call string
callString
,
List<SqlParameter>
list of SqlParameter objects
declaredParameters
)

Create a new factory with the given SQL and the given parameters.

Method Summary

Modifier and TypeMethod and Description
public void
addParameter(SqlParameter
the parameter to add to the list of declared parameters
param
)

Add a new declared parameter.

public final String
getCallString()

Return the SQL call string.

public CallableStatementCreator
newCallableStatementCreator(Map<String, ?>
list of parameters (may be null)
params
)

Return a new CallableStatementCreator instance given these parameters.

public CallableStatementCreator
newCallableStatementCreator(ParameterMapper
the ParameterMapper implementation that will return a Map of parameters
inParamMapper
)

Return a new CallableStatementCreator instance given this parameter mapper.

public void
setResultSetType(int
the ResultSet type
resultSetType
)

Set whether to use prepared statements that return a specific type of ResultSet.

public void
setUpdatableResults(boolean updatableResults)

Set whether to use prepared statements capable of returning updatable ResultSets.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callStringback to summary
private final String callString

The SQL call string, which won't change when the parameters change.

declaredParametersback to summary
private final List<SqlParameter> declaredParameters

List of SqlParameter objects. May not be null.

resultSetTypeback to summary
private int resultSetType
updatableResultsback to summary
private boolean updatableResults

Constructor Detail

CallableStatementCreatorFactoryback to summary
public CallableStatementCreatorFactory(String callString)

Create a new factory. Will need to add parameters via the addParameter method or have no parameters.

Parameters
callString:String

the SQL call string

CallableStatementCreatorFactoryback to summary
public CallableStatementCreatorFactory(String callString, List<SqlParameter> declaredParameters)

Create a new factory with the given SQL and the given parameters.

Parameters
callString:String

the SQL call string

declaredParameters:List<SqlParameter>

list of SqlParameter objects

Method Detail

addParameterback to summary
public void addParameter(SqlParameter param)

Add a new declared parameter.

Order of parameter addition is significant.

Parameters
param:SqlParameter

the parameter to add to the list of declared parameters

getCallStringback to summary
public final String getCallString()

Return the SQL call string.

Since
5.1.3
newCallableStatementCreatorback to summary
public CallableStatementCreator newCallableStatementCreator(Map<String, ?> params)

Return a new CallableStatementCreator instance given these parameters.

Parameters
params:Map<String, ?>

list of parameters (may be null)

newCallableStatementCreatorback to summary
public CallableStatementCreator newCallableStatementCreator(ParameterMapper inParamMapper)

Return a new CallableStatementCreator instance given this parameter mapper.

Parameters
inParamMapper:ParameterMapper

the ParameterMapper implementation that will return a Map of parameters

setResultSetTypeback to summary
public void setResultSetType(int resultSetType)

Set whether to use prepared statements that return a specific type of ResultSet. specific type of ResultSet.

Parameters
resultSetType:int

the ResultSet type

See Also
java.sql.ResultSet#TYPE_FORWARD_ONLY, java.sql.ResultSet#TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet#TYPE_SCROLL_SENSITIVE
setUpdatableResultsback to summary
public void setUpdatableResults(boolean updatableResults)

Set whether to use prepared statements capable of returning updatable ResultSets.

org.springframework.jdbc.core back to summary

private Class CallableStatementCreatorFactory.CallableStatementCreatorImpl

extends Object
implements CallableStatementCreator, SqlProvider, ParameterDisposer
Class Inheritance
  • java.lang.Object
  • org.springframework.jdbc.core.CallableStatementCreatorFactory.CallableStatementCreatorImpl
All Implemented Interfaces
org.springframework.jdbc.core.ParameterDisposer, org.springframework.jdbc.core.SqlProvider, org.springframework.jdbc.core.CallableStatementCreator

CallableStatementCreator implementation returned by this class.

Field Summary

Modifier and TypeField and Description
private ParameterMapper
private Map<String, ?>

Constructor Summary

AccessConstructor and Description
public
CallableStatementCreatorImpl(ParameterMapper
the ParameterMapper implementation for mapping input parameters
inParamMapper
)

Create a new CallableStatementCreatorImpl.

public
CallableStatementCreatorImpl(Map<String, ?>
list of SqlParameter objects
inParams
)

Create a new CallableStatementCreatorImpl.

Method Summary

Modifier and TypeMethod and Description
public void
cleanupParameters()

Implements org.springframework.jdbc.core.ParameterDisposer.cleanupParameters.

Close the resources allocated by parameters that the implementing object holds, for example in case of a DisposableSqlTypeValue (like an SqlLobValue).

public CallableStatement
createCallableStatement(Connection
the Connection to use to create statement
con
)

Implements org.springframework.jdbc.core.CallableStatementCreator.createCallableStatement.

Create a callable statement in this connection.

public String
getSql()

Implements org.springframework.jdbc.core.SqlProvider.getSql.

Return the SQL string for this object, i.e. typically the SQL used for creating statements.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

inParameterMapperback to summary
private ParameterMapper inParameterMapper
Annotations
@Nullable
inParametersback to summary
private Map<String, ?> inParameters
Annotations
@Nullable

Constructor Detail

CallableStatementCreatorImplback to summary
public CallableStatementCreatorImpl(ParameterMapper inParamMapper)

Create a new CallableStatementCreatorImpl.

Parameters
inParamMapper:ParameterMapper

the ParameterMapper implementation for mapping input parameters

CallableStatementCreatorImplback to summary
public CallableStatementCreatorImpl(Map<String, ?> inParams)

Create a new CallableStatementCreatorImpl.

Parameters
inParams:Map<String, ?>

list of SqlParameter objects

Method Detail

cleanupParametersback to summary
public void cleanupParameters()

Implements org.springframework.jdbc.core.ParameterDisposer.cleanupParameters.

Doc from org.springframework.jdbc.core.ParameterDisposer.cleanupParameters.

Close the resources allocated by parameters that the implementing object holds, for example in case of a DisposableSqlTypeValue (like an SqlLobValue).

Annotations
@Override
createCallableStatementback to summary
public CallableStatement createCallableStatement(Connection con) throws SQLException

Implements org.springframework.jdbc.core.CallableStatementCreator.createCallableStatement.

Doc from org.springframework.jdbc.core.CallableStatementCreator.createCallableStatement.

Create a callable statement in this connection. Allows implementations to use CallableStatements.

Parameters
con:Connection

the Connection to use to create statement

Returns:CallableStatement

a callable statement

Annotations
@Override
Exceptions
SQLException:
there is no need to catch SQLExceptions that may be thrown in the implementation of this method. The JdbcTemplate class will handle them.
getSqlback to summary
public String getSql()

Implements org.springframework.jdbc.core.SqlProvider.getSql.

Doc from org.springframework.jdbc.core.SqlProvider.getSql.

Return the SQL string for this object, i.e. typically the SQL used for creating statements.

Returns:String

the SQL string, or null if not available

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override