Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework » jdbc » object » [javadoc | source]
org.springframework.jdbc.object
public class: SqlUpdate [javadoc | source]
java.lang.Object
   org.springframework.jdbc.object.RdbmsOperation
      org.springframework.jdbc.object.SqlOperation
         org.springframework.jdbc.object.SqlUpdate

All Implemented Interfaces:
    InitializingBean

Direct Known Subclasses:
    OwnerUpdate, PetUpdate, VisitInsert, BatchSqlUpdate, PetInsert, OwnerInsert

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.

Fields inherited from org.springframework.jdbc.object.RdbmsOperation:
logger
Constructor:
 public SqlUpdate() 
 public SqlUpdate(DataSource ds,
    String sql) 
    Constructs an update object with a given DataSource and SQL.
    Parameters:
    ds - DataSource to use to obtain connections
    sql - SQL statement to execute
 public SqlUpdate(DataSource ds,
    String sql,
    int[] types) 
    Construct an update object with a given DataSource, SQL and anonymous parameters.
    Parameters:
    ds - DataSource to use to obtain connections
    sql - SQL statement to execute
    types - SQL types of the parameters, as defined in the java.sql.Types class
    Also see:
    java.sql.Types
 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.
    Parameters:
    ds - DataSource to use to obtain connections
    sql - SQL statement to execute
    types - SQL types of the parameters, as defined in the java.sql.Types class
    maxRowsAffected - the maximum number of rows that may be affected by the update
    Also see:
    java.sql.Types
Method from org.springframework.jdbc.object.SqlUpdate Summary:
checkRowsAffected,   setMaxRowsAffected,   setRequiredRowsAffected,   update,   update,   update,   update,   update,   update,   update,   update,   update,   updateByNamedParam,   updateByNamedParam
Methods from org.springframework.jdbc.object.SqlOperation:
compileInternal,   getParsedSql,   newPreparedStatementCreator,   newPreparedStatementCreator,   newPreparedStatementSetter,   onCompileInternal
Methods from org.springframework.jdbc.object.RdbmsOperation:
afterPropertiesSet,   allowsUnusedParameters,   checkCompiled,   compile,   compileInternal,   declareParameter,   getDeclaredParameters,   getGeneratedKeysColumnNames,   getJdbcTemplate,   getResultSetType,   getSql,   isCompiled,   isReturnGeneratedKeys,   isUpdatableResults,   setDataSource,   setFetchSize,   setGeneratedKeysColumnNames,   setJdbcTemplate,   setMaxRows,   setParameters,   setQueryTimeout,   setResultSetType,   setReturnGeneratedKeys,   setSql,   setTypes,   setUpdatableResults,   supportsLobParameters,   validateNamedParameters,   validateParameters
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.jdbc.object.SqlUpdate Detail:
 protected  void checkRowsAffected(int rowsAffected) throws JdbcUpdateAffectedIncorrectNumberOfRowsException 
    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. The default value is 0, which does not limit the number of rows affected.
 public  void setRequiredRowsAffected(int requiredRowsAffected) 
    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.

 public int update() throws DataAccessException 
    Convenience method to execute an update with no parameters.
 public int update(Object[] params) throws DataAccessException 
    Generic method to execute the update given parameters. All other update methods invoke this method.
 public int update(int p1) throws DataAccessException 
    Convenient method to execute an update given one int arg.
 public int update(long p1) throws DataAccessException 
    Convenient method to execute an update given one long arg.
 public int update(String p) throws DataAccessException 
    Convenient method to execute an update given one String arg.
 public int update(Object[] params,
    KeyHolder generatedKeyHolder) throws DataAccessException 
    Method to execute the update given arguments and retrieve the generated keys using a KeyHolder.
 public int update(int p1,
    int p2) throws DataAccessException 
    Convenient method to execute an update given two int args.
 public int update(long p1,
    long p2) throws DataAccessException 
    Convenient method to execute an update given two long args.
 public int update(String p1,
    String p2) throws DataAccessException 
    Convenient method to execute an update given two String args.
 public int updateByNamedParam(Map paramMap) throws DataAccessException 
    Generic method to execute the update given named parameters. All other update methods invoke this method.
 public int updateByNamedParam(Map paramMap,
    KeyHolder generatedKeyHolder) throws DataAccessException 
    Method to execute the update given arguments and retrieve the generated keys using a KeyHolder.