|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.jdbc.object.RdbmsOperation
org.springframework.jdbc.object.SqlOperation
org.springframework.jdbc.object.SqlUpdate
RdbmsOperation subclass representing a SQL update. Like a query, an update object is reusable. Like all RdbmsOperation objects, an update can have parameters and is defined in SQL.
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.
Field Summary |
Fields inherited from class org.springframework.jdbc.object.RdbmsOperation |
logger |
Constructor Summary | |
SqlUpdate()
Constructor to allow use as a JavaBean. |
|
SqlUpdate(javax.sql.DataSource ds,
java.lang.String sql)
Constructs an update object with a given DataSource and SQL. |
|
SqlUpdate(javax.sql.DataSource ds,
java.lang.String sql,
int[] types)
Construct an update object with a given DataSource, SQL and anonymous parameters. |
|
SqlUpdate(javax.sql.DataSource ds,
java.lang.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 respectively required number. |
void |
setMaxRowsAffected(int maxRowsAffected)
Set the maximum number of rows that may be affected by this update. |
void |
setRequiredRowsAffected(int requiredRowsAffected)
Set the exact number of rows that must be affected by this update. |
int |
update()
Convenience method to execute an update with no parameters. |
int |
update(int p1)
Convenient method to execute an update given one int arg. |
int |
update(int p1,
int p2)
Convenient method to execute an update given two int args. |
int |
update(long p1)
Convenient method to execute an update given one long arg. |
int |
update(long p1,
long p2)
Convenient method to execute an update given two long args. |
int |
update(java.lang.Object[] args)
Generic method to execute the update given arguments. |
int |
update(java.lang.Object[] args,
KeyHolder generatedKeyHolder)
Method to execute the update given arguments and retrieve the generated keys using a KeyHolder. |
int |
update(java.lang.String p)
Convenient method to execute an update given one String arg. |
int |
update(java.lang.String p1,
java.lang.String p2)
Convenient method to execute an update given two String args. |
Methods inherited from class org.springframework.jdbc.object.SqlOperation |
compileInternal, newPreparedStatementCreator, newPreparedStatementSetter, onCompileInternal |
Methods inherited from class org.springframework.jdbc.object.RdbmsOperation |
afterPropertiesSet, compile, declareParameter, getDeclaredParameters, getGeneratedKeysColumnNames, getJdbcTemplate, getResultSetType, getSql, isCompiled, isReturnGeneratedKeys, isUpdatableResults, setDataSource, setGeneratedKeysColumnNames, setJdbcTemplate, setResultSetType, setReturnGeneratedKeys, setSql, setTypes, setUpdatableResults, supportsLobParameters, validateParameters |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SqlUpdate()
public SqlUpdate(javax.sql.DataSource ds, java.lang.String sql)
ds
- DataSource to use to obtain connectionssql
- SQL statement to executepublic SqlUpdate(javax.sql.DataSource ds, java.lang.String sql, int[] types)
ds
- DataSource to use to obtain connectionssql
- SQL statement to executetypes
- anonymous parameter declarationspublic SqlUpdate(javax.sql.DataSource ds, java.lang.String sql, int[] types, int maxRowsAffected)
ds
- DataSource to use to obtain connectionssql
- SQL statement to executetypes
- anonymous parameter declarations.maxRowsAffected
- the maximum number of rows that may
be affected by the updateMethod Detail |
public void setMaxRowsAffected(int maxRowsAffected)
maxRowsAffected
- the maximum number of rows that can be affected by
this update without this class's update method considering it an errorpublic void setRequiredRowsAffected(int requiredRowsAffected)
This is an alternative to setting the maximum number of rows that may be affected.
requiredRowsAffected
- the exact number of rows that must be affected
by this update without this class's update method considering it an errorprotected void checkRowsAffected(int rowsAffected) throws JdbcUpdateAffectedIncorrectNumberOfRowsException
rowsAffected
- the number of affected rows
JdbcUpdateAffectedIncorrectNumberOfRowsException
- if the actually affected rows are out of boundssetMaxRowsAffected(int)
,
setRequiredRowsAffected(int)
public int update(java.lang.Object[] args) throws DataAccessException
args
- array of object arguments
DataAccessException
public int update(java.lang.Object[] args, KeyHolder generatedKeyHolder) throws DataAccessException
args
- array of object argumentsgeneratedKeyHolder
- KeyHolder that will hold the generated keys
DataAccessException
public int update() throws DataAccessException
DataAccessException
public int update(int p1) throws DataAccessException
DataAccessException
public int update(int p1, int p2) throws DataAccessException
DataAccessException
public int update(long p1) throws DataAccessException
DataAccessException
public int update(long p1, long p2) throws DataAccessException
DataAccessException
public int update(java.lang.String p) throws DataAccessException
DataAccessException
public int update(java.lang.String p1, java.lang.String p2) throws DataAccessException
DataAccessException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |