org.opensubsystems.core.persist.db
Class DatabaseCreateMultipleDataObjectsOperation
java.lang.Object
org.opensubsystems.core.persist.db.DatabaseOperation
org.opensubsystems.core.persist.db.DatabaseUpdateOperation
org.opensubsystems.core.persist.db.DatabaseCreateMultipleDataObjectsOperation
- All Implemented Interfaces:
- DatabaseOperations
public class DatabaseCreateMultipleDataObjectsOperation
- extends DatabaseUpdateOperation
Adapter to simplify writing of batched database inserts, 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 insert
public int create(
final Collection colDataObject
) throws OSSException
{
DatabaseBatchCreateOperation dbop = new DatabaseBatchCreateOperation(
this, m_schema.getInsertMyData(), m_schema, dataType, colDataObject);
dbop.executeUpdate();
return ((Integer)dbop.getReturnData()).intValue();
}
- Version:
- $Id: DatabaseCreateMultipleDataObjectsOperation.java,v 1.10 2007/01/28 06:54:42 bastafidli Exp $
- Author:
- Miro Halas
- Code reviewer:
- Miro Halas
- Code reviewed:
- 1.7 2006/07/26 23:44:20 jlegeny
|
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DatabaseCreateMultipleDataObjectsOperation
public DatabaseCreateMultipleDataObjectsOperation(DatabaseFactoryImpl factory,
java.lang.String query,
ModifiableDatabaseSchema schema,
java.util.Collection colDataObject,
boolean bFetchGeneratedValues)
- Constructor
- Parameters:
factory - - factory which is executing this operationquery - - query to insert dataschema - - schema to set the data to the statementcolDataObject - - collection of data objects that will be createdbFetchGeneratedValues - - flag signaling if there have to be returned
generated values
true = there will be returned generated values
false = will be returned number of inserted records
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 operationcntConnection - - 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.