public class

PreparedStatementCreatorFactory

extends Object
java.lang.Object
   ↳ org.springframework.jdbc.core.PreparedStatementCreatorFactory

Class Overview

Helper class that efficiently creates multiple PreparedStatementCreator objects with different parameters based on a SQL statement and a single set of parameter declarations.

Summary

Public Constructors
PreparedStatementCreatorFactory(String sql)
Create a new factory.
PreparedStatementCreatorFactory(String sql, int[] types)
Create a new factory with the given SQL and JDBC types.
PreparedStatementCreatorFactory(String sql, List<SqlParameter> declaredParameters)
Create a new factory with the given SQL and parameters.
Public Methods
void addParameter(SqlParameter param)
Add a new declared parameter.
PreparedStatementCreator newPreparedStatementCreator(Object[] params)
Return a new PreparedStatementCreator for the given parameters.
PreparedStatementCreator newPreparedStatementCreator(List<?> params)
Return a new PreparedStatementCreator for the given parameters.
PreparedStatementCreator newPreparedStatementCreator(String sqlToUse, Object[] params)
Return a new PreparedStatementCreator for the given parameters.
PreparedStatementSetter newPreparedStatementSetter(Object[] params)
Return a new PreparedStatementSetter for the given parameters.
PreparedStatementSetter newPreparedStatementSetter(List params)
Return a new PreparedStatementSetter for the given parameters.
void setGeneratedKeysColumnNames(String[] names)
Set the column names of the auto-generated keys.
void setNativeJdbcExtractor(NativeJdbcExtractor nativeJdbcExtractor)
Specify the NativeJdbcExtractor to use for unwrapping PreparedStatements, if any.
void setResultSetType(int resultSetType)
Set whether to use prepared statements that return a specific type of ResultSet.
void setReturnGeneratedKeys(boolean returnGeneratedKeys)
Set whether prepared statements should be capable of returning auto-generated keys.
void setUpdatableResults(boolean updatableResults)
Set whether to use prepared statements capable of returning updatable ResultSets.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public PreparedStatementCreatorFactory (String sql)

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

public PreparedStatementCreatorFactory (String sql, int[] types)

Create a new factory with the given SQL and JDBC types.

Parameters
sql SQL to execute
types int array of JDBC types

public PreparedStatementCreatorFactory (String sql, List<SqlParameter> declaredParameters)

Create a new factory with the given SQL and parameters.

Parameters
sql SQL
declaredParameters list of SqlParameter objects
See Also

Public Methods

public void addParameter (SqlParameter param)

Add a new declared parameter.

Order of parameter addition is significant.

Parameters
param the parameter to add to the list of declared parameters

public PreparedStatementCreator newPreparedStatementCreator (Object[] params)

Return a new PreparedStatementCreator for the given parameters.

Parameters
params the parameter array (may be null)

public PreparedStatementCreator newPreparedStatementCreator (List<?> params)

Return a new PreparedStatementCreator for the given parameters.

Parameters
params list of parameters (may be null)

public PreparedStatementCreator newPreparedStatementCreator (String sqlToUse, Object[] params)

Return a new PreparedStatementCreator for the given parameters.

Parameters
sqlToUse the actual SQL statement to use (if different from the factory's, for example because of named parameter expanding)
params the parameter array (may be null)

public PreparedStatementSetter newPreparedStatementSetter (Object[] params)

Return a new PreparedStatementSetter for the given parameters.

Parameters
params the parameter array (may be null)

public PreparedStatementSetter newPreparedStatementSetter (List params)

Return a new PreparedStatementSetter for the given parameters.

Parameters
params list of parameters (may be null)

public void setGeneratedKeysColumnNames (String[] names)

Set the column names of the auto-generated keys.

public void setNativeJdbcExtractor (NativeJdbcExtractor nativeJdbcExtractor)

Specify the NativeJdbcExtractor to use for unwrapping PreparedStatements, if any.

public void setResultSetType (int resultSetType)

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

Parameters
resultSetType the ResultSet type

public void setReturnGeneratedKeys (boolean returnGeneratedKeys)

Set whether prepared statements should be capable of returning auto-generated keys.

public void setUpdatableResults (boolean updatableResults)

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