public class PreparedStatementCreatorFactory
extends java.lang.Object
PreparedStatementCreator
objects with different parameters based on a SQL statement and a single
set of parameter declarations.Modifier and Type | Class and Description |
---|---|
private class |
PreparedStatementCreatorFactory.PreparedStatementCreatorImpl
PreparedStatementCreator implementation returned by this class.
|
Modifier and Type | Field and Description |
---|---|
private java.util.List<SqlParameter> |
declaredParameters
List of SqlParameter objects (may not be
null ) |
private java.lang.String[] |
generatedKeysColumnNames |
private NativeJdbcExtractor |
nativeJdbcExtractor |
private int |
resultSetType |
private boolean |
returnGeneratedKeys |
private java.lang.String |
sql
The SQL, which won't change when the parameters change
|
private boolean |
updatableResults |
Constructor and Description |
---|
PreparedStatementCreatorFactory(java.lang.String sql)
Create a new factory.
|
PreparedStatementCreatorFactory(java.lang.String sql,
int... types)
Create a new factory with the given SQL and JDBC types.
|
PreparedStatementCreatorFactory(java.lang.String sql,
java.util.List<SqlParameter> declaredParameters)
Create a new factory with the given SQL and parameters.
|
Modifier and Type | Method and Description |
---|---|
void |
addParameter(SqlParameter param)
Add a new declared parameter.
|
PreparedStatementCreator |
newPreparedStatementCreator(java.util.List<?> params)
Return a new PreparedStatementCreator for the given parameters.
|
PreparedStatementCreator |
newPreparedStatementCreator(java.lang.Object[] params)
Return a new PreparedStatementCreator for the given parameters.
|
PreparedStatementCreator |
newPreparedStatementCreator(java.lang.String sqlToUse,
java.lang.Object[] params)
Return a new PreparedStatementCreator for the given parameters.
|
PreparedStatementSetter |
newPreparedStatementSetter(java.util.List<?> params)
Return a new PreparedStatementSetter for the given parameters.
|
PreparedStatementSetter |
newPreparedStatementSetter(java.lang.Object[] params)
Return a new PreparedStatementSetter for the given parameters.
|
void |
setGeneratedKeysColumnNames(java.lang.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.
|
private final java.lang.String sql
private final java.util.List<SqlParameter> declaredParameters
null
)private int resultSetType
private boolean updatableResults
private boolean returnGeneratedKeys
private java.lang.String[] generatedKeysColumnNames
private NativeJdbcExtractor nativeJdbcExtractor
public PreparedStatementCreatorFactory(java.lang.String sql)
addParameter(org.springframework.jdbc.core.SqlParameter)
method or have no parameters.sql
- the SQL statement to executepublic PreparedStatementCreatorFactory(java.lang.String sql, int... types)
sql
- the SQL statement to executetypes
- int array of JDBC typespublic PreparedStatementCreatorFactory(java.lang.String sql, java.util.List<SqlParameter> declaredParameters)
sql
- the SQL statement to executedeclaredParameters
- list of SqlParameter
objectspublic void addParameter(SqlParameter param)
Order of parameter addition is significant.
param
- the parameter to add to the list of declared parameterspublic void setResultSetType(int resultSetType)
resultSetType
- the ResultSet typeResultSet.TYPE_FORWARD_ONLY
,
ResultSet.TYPE_SCROLL_INSENSITIVE
,
ResultSet.TYPE_SCROLL_SENSITIVE
public void setUpdatableResults(boolean updatableResults)
public void setReturnGeneratedKeys(boolean returnGeneratedKeys)
public void setGeneratedKeysColumnNames(java.lang.String... names)
public void setNativeJdbcExtractor(NativeJdbcExtractor nativeJdbcExtractor)
public PreparedStatementSetter newPreparedStatementSetter(java.util.List<?> params)
params
- list of parameters (may be null
)public PreparedStatementSetter newPreparedStatementSetter(java.lang.Object[] params)
params
- the parameter array (may be null
)public PreparedStatementCreator newPreparedStatementCreator(java.util.List<?> params)
params
- list of parameters (may be null
)public PreparedStatementCreator newPreparedStatementCreator(java.lang.Object[] params)
params
- the parameter array (may be null
)public PreparedStatementCreator newPreparedStatementCreator(java.lang.String sqlToUse, java.lang.Object[] params)
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
)