| java.lang.Object org.springframework.jdbc.object.RdbmsOperation org.springframework.jdbc.object.SqlOperation org.springframework.jdbc.object.SqlUpdate
All known Subclasses: org.springframework.jdbc.object.BatchSqlUpdate,
SqlUpdate | public class SqlUpdate extends SqlOperation (Code) | | Reusable operation object representing a SQL update.
This class provides a number of update methods,
analogous to the execute methods of query objects.
This class is concrete. Although it can be subclassed (for example
to add a custom update method) it can easily be parameterized by setting
SQL and declaring parameters.
Like all RdbmsOperation classes that ship with the Spring
Framework, SqlQuery instances are thread-safe after their
initialization is complete. That is, after they are constructed and configured
via their setter methods, they can be used safely from multiple threads.
author: Rod Johnson author: Thomas Risberg author: Juergen Hoeller See Also: SqlQuery |
Constructor Summary | |
public | SqlUpdate() Constructor to allow use as a JavaBean. | public | SqlUpdate(DataSource ds, String sql) Constructs an update object with a given DataSource and SQL. | public | SqlUpdate(DataSource ds, String sql, int[] types) Construct an update object with a given DataSource, SQL
and anonymous parameters. | public | SqlUpdate(DataSource ds, String sql, int[] types, int maxRowsAffected) Construct an update object with a given DataSource, SQL,
anonymous parameters and specifying the maximum number of rows
that may be affected. |
Method Summary | |
protected void | checkRowsAffected(int rowsAffected) Check the given number of affected rows against the
specified maximum number or required number. | public void | setMaxRowsAffected(int maxRowsAffected) Set the maximum number of rows that may be affected by this update. | public void | setRequiredRowsAffected(int requiredRowsAffected) Set the exact number of rows that must be affected by this update. | public int | update(Object[] params) Generic method to execute the update given parameters. | public int | update(Object[] params, KeyHolder generatedKeyHolder) Method to execute the update given arguments and
retrieve the generated keys using a KeyHolder. | public int | update() Convenience method to execute an update with no parameters. | public int | update(int p1) Convenient method to execute an update given one int arg. | public int | update(int p1, int p2) Convenient method to execute an update given two int args. | public int | update(long p1) Convenient method to execute an update given one long arg. | public int | update(long p1, long p2) Convenient method to execute an update given two long args. | public int | update(String p) Convenient method to execute an update given one String arg. | public int | update(String p1, String p2) Convenient method to execute an update given two String args. | public int | updateByNamedParam(Map paramMap) Generic method to execute the update given named parameters. | public int | updateByNamedParam(Map paramMap, KeyHolder generatedKeyHolder) Method to execute the update given arguments and
retrieve the generated keys using a KeyHolder. |
SqlUpdate | public SqlUpdate(DataSource ds, String sql)(Code) | | Constructs an update object with a given DataSource and SQL.
Parameters: ds - DataSource to use to obtain connections Parameters: sql - SQL statement to execute |
SqlUpdate | public SqlUpdate(DataSource ds, String sql, int[] types)(Code) | | Construct an update object with a given DataSource, SQL
and anonymous parameters.
Parameters: ds - DataSource to use to obtain connections Parameters: sql - SQL statement to execute Parameters: types - SQL types of the parameters, as defined in thejava.sql.Types class See Also: java.sql.Types |
SqlUpdate | public SqlUpdate(DataSource ds, String sql, int[] types, int maxRowsAffected)(Code) | | Construct an update object with a given DataSource, SQL,
anonymous parameters and specifying the maximum number of rows
that may be affected.
Parameters: ds - DataSource to use to obtain connections Parameters: sql - SQL statement to execute Parameters: types - SQL types of the parameters, as defined in thejava.sql.Types class Parameters: maxRowsAffected - the maximum number of rows that maybe affected by the update See Also: java.sql.Types |
setMaxRowsAffected | public void setMaxRowsAffected(int maxRowsAffected)(Code) | | Set the maximum number of rows that may be affected by this update.
The default value is 0, which does not limit the number of rows affected.
Parameters: maxRowsAffected - the maximum number of rows that can be affected bythis update without this class's update method considering it an error |
setRequiredRowsAffected | public void setRequiredRowsAffected(int requiredRowsAffected)(Code) | | Set the exact number of rows that must be affected by this update.
The default value is 0, which allows any number of rows to be affected.
This is an alternative to setting the maximum number of rows
that may be affected.
Parameters: requiredRowsAffected - the exact number of rows that must be affectedby this update without this class's update method considering it an error |
update | public int update(Object[] params) throws DataAccessException(Code) | | Generic method to execute the update given parameters.
All other update methods invoke this method.
Parameters: params - array of parameters objects the number of rows affected by the update |
update | public int update(Object[] params, KeyHolder generatedKeyHolder) throws DataAccessException(Code) | | Method to execute the update given arguments and
retrieve the generated keys using a KeyHolder.
Parameters: params - array of parameter objects Parameters: generatedKeyHolder - KeyHolder that will hold the generated keys the number of rows affected by the update |
update | public int update(int p1, int p2) throws DataAccessException(Code) | | Convenient method to execute an update given two int args.
|
update | public int update(long p1, long p2) throws DataAccessException(Code) | | Convenient method to execute an update given two long args.
|
updateByNamedParam | public int updateByNamedParam(Map paramMap) throws DataAccessException(Code) | | Generic method to execute the update given named parameters.
All other update methods invoke this method.
Parameters: paramMap - Map of parameter name to parameter object,matching named parameters specified in the SQL statement the number of rows affected by the update |
updateByNamedParam | public int updateByNamedParam(Map paramMap, KeyHolder generatedKeyHolder) throws DataAccessException(Code) | | Method to execute the update given arguments and
retrieve the generated keys using a KeyHolder.
Parameters: paramMap - Map of parameter name to parameter object,matching named parameters specified in the SQL statement Parameters: generatedKeyHolder - KeyHolder that will hold the generated keys the number of rows affected by the update |
Fields inherited from org.springframework.jdbc.object.RdbmsOperation | final protected Log logger(Code)(Java Doc)
|
|
|