类 PreparedStatementCreatorFactory
- java.lang.Object
- org.springframework.jdbc.core.PreparedStatementCreatorFactory
public class PreparedStatementCreatorFactory extends Object
Helper class that efficiently creates multiplePreparedStatementCreator
objects with different parameters based on an SQL statement and a single set of parameter declarations.- 作者:
- Rod Johnson, Thomas Risberg, Juergen Hoeller
构造器概要
构造器 构造器 说明 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.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addParameter(SqlParameter param)
Add a new declared parameter.String
getSql()
Return the SQL statement to execute.PreparedStatementCreator
newPreparedStatementCreator(Object[] params)
Return a new PreparedStatementCreator for the given parameters.PreparedStatementCreator
newPreparedStatementCreator(String sqlToUse, Object[] params)
Return a new PreparedStatementCreator for the given parameters.PreparedStatementCreator
newPreparedStatementCreator(List<?> 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
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.
构造器详细资料
PreparedStatementCreatorFactory
public PreparedStatementCreatorFactory(String sql)
Create a new factory. Will need to add parameters via theaddParameter(org.springframework.jdbc.core.SqlParameter)
method or have no parameters.- 参数:
sql
- the SQL statement to execute
PreparedStatementCreatorFactory
public PreparedStatementCreatorFactory(String sql, int... types)
Create a new factory with the given SQL and JDBC types.- 参数:
sql
- the SQL statement to executetypes
- int array of JDBC types
PreparedStatementCreatorFactory
public PreparedStatementCreatorFactory(String sql, List<SqlParameter> declaredParameters)
Create a new factory with the given SQL and parameters.- 参数:
sql
- the SQL statement to executedeclaredParameters
- list ofSqlParameter
objects
方法详细资料
addParameter
public void addParameter(SqlParameter param)
Add a new declared parameter.Order of parameter addition is significant.
- 参数:
param
- the parameter to add to the list of declared parameters
setResultSetType
public void setResultSetType(int resultSetType)
Set whether to use prepared statements that return a specific type of ResultSet.- 参数:
resultSetType
- the ResultSet type- 另请参阅:
ResultSet.TYPE_FORWARD_ONLY
,ResultSet.TYPE_SCROLL_INSENSITIVE
,ResultSet.TYPE_SCROLL_SENSITIVE
setUpdatableResults
public void setUpdatableResults(boolean updatableResults)
Set whether to use prepared statements capable of returning updatable ResultSets.
setReturnGeneratedKeys
public void setReturnGeneratedKeys(boolean returnGeneratedKeys)
Set whether prepared statements should be capable of returning auto-generated keys.
setGeneratedKeysColumnNames
public void setGeneratedKeysColumnNames(String... names)
Set the column names of the auto-generated keys.
newPreparedStatementSetter
public PreparedStatementSetter newPreparedStatementSetter(@Nullable List<?> params)
Return a new PreparedStatementSetter for the given parameters.- 参数:
params
- list of parameters (may benull
)
newPreparedStatementSetter
public PreparedStatementSetter newPreparedStatementSetter(@Nullable Object[] params)
Return a new PreparedStatementSetter for the given parameters.- 参数:
params
- the parameter array (may benull
)
newPreparedStatementCreator
public PreparedStatementCreator newPreparedStatementCreator(@Nullable List<?> params)
Return a new PreparedStatementCreator for the given parameters.- 参数:
params
- list of parameters (may benull
)
newPreparedStatementCreator
public PreparedStatementCreator newPreparedStatementCreator(@Nullable Object[] params)
Return a new PreparedStatementCreator for the given parameters.- 参数:
params
- the parameter array (may benull
)
newPreparedStatementCreator
public PreparedStatementCreator newPreparedStatementCreator(String sqlToUse, @Nullable Object[] params)
Return a new PreparedStatementCreator for the given 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 benull
)