org.opensubsystems.core.persist.db
Class DatabaseUpdateMultipleDataObjectsOperation

java.lang.Object
  extended by org.opensubsystems.core.persist.db.DatabaseOperation
      extended by org.opensubsystems.core.persist.db.DatabaseUpdateOperation
          extended by org.opensubsystems.core.persist.db.DatabaseUpdateMultipleDataObjectsOperation
All Implemented Interfaces:
DatabaseOperations

public class DatabaseUpdateMultipleDataObjectsOperation
extends DatabaseUpdateOperation

Adapter to simplify writing of batched database updates, which takes care of requesting and returning connections, transaction management and exception handling. To use this adapter you just need to create an instance of this class and call executeUpdate method. Example of method in factory which creates collection of data using batch update public int create( final Collection colDataObject ) throws OSSException { DatabaseBatchUpdateOperation dbop = new DatabaseBatchUpdateOperation( this, m_schema.getUpdateMyData(), m_schema, dataType, colDataObject); dbop.executeUpdate(); return ((Integer)dbop.getReturnData()).intValue(); }

Version:
$Id: DatabaseUpdateMultipleDataObjectsOperation.java,v 1.7 2007/01/10 05:10:20 bastafidli Exp $
Author:
Julian Legeny
Code reviewer:
Miro Halas
Code reviewed:
1.6 2006/07/26 23:44:33 jlegeny

Field Summary
 
Fields inherited from class org.opensubsystems.core.persist.db.DatabaseOperation
m_data, m_dbschema, m_factory, m_iDataType, m_returnData, m_strQuery
 
Fields inherited from interface org.opensubsystems.core.persist.db.DatabaseOperations
DBOP_DELETE, DBOP_INSERT, DBOP_SELECT, DBOP_UPDATE
 
Constructor Summary
DatabaseUpdateMultipleDataObjectsOperation(DatabaseFactoryImpl factory, java.lang.String query, ModifiableDatabaseSchema schema, java.util.Collection colDataObject)
          Constructor
 
Method Summary
protected  void performOperation(DatabaseFactoryImpl dbfactory, java.sql.Connection cntConnection, java.sql.PreparedStatement pstmQuery)
          Define content of this method to perform the database operation using the provided connection and optional prepared statement.
 
Methods inherited from class org.opensubsystems.core.persist.db.DatabaseUpdateOperation
executeUpdate, handleKnownError, handleSQLException, handleUnknownError, prepareData, setValuesForInsert, setValuesForUpdate
 
Methods inherited from class org.opensubsystems.core.persist.db.DatabaseOperation
getReturnData, setReturnData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseUpdateMultipleDataObjectsOperation

public DatabaseUpdateMultipleDataObjectsOperation(DatabaseFactoryImpl factory,
                                                  java.lang.String query,
                                                  ModifiableDatabaseSchema schema,
                                                  java.util.Collection colDataObject)
Constructor

Parameters:
factory - - factory which is executing this operation
query - - query to update data
schema - - schema to set the data to the statement
colDataObject - - collection of data objects that will be updated
Method Detail

performOperation

protected void performOperation(DatabaseFactoryImpl dbfactory,
                                java.sql.Connection cntConnection,
                                java.sql.PreparedStatement pstmQuery)
                         throws OSSException,
                                java.sql.SQLException
Define content of this method to perform the database operation using the provided connection and optional prepared statement.

Overrides:
performOperation in class DatabaseUpdateOperation
Parameters:
dbfactory - - database factory used for this operation
cntConnection - - ready to use connection to perform the database operation. No need to return this connection.
pstmQuery - - prepared statement for query passed in as a parameter to the constructor. No need to close this statement. If no query was passed into constructor, this will be null.
Throws:
OSSException - - an error has occured
java.sql.SQLException - - an error has occured


Copyright © 2003 - 2006 OpenSubsystems s.r.o.