Class DatabaseCreateSingleDataObjectOperation

  extended by org.opensubsystems.core.persist.db.DatabaseOperation
      extended by org.opensubsystems.core.persist.db.DatabaseUpdateOperation
          extended by org.opensubsystems.core.persist.db.DatabaseCreateSingleDataObjectOperation
All Implemented Interfaces:

public class DatabaseCreateSingleDataObjectOperation
extends DatabaseUpdateOperation

Adapter to simplify writing of database updates that insert single data object to the database. The adapter 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 single data object public int create( final BasicDataObject data ) throws OSSException { DatabaseCreateSingleDataObjectOperation dbop = new DatabaseCreateSingleDataObjectOperation( this, m_schema.getInsertMyData(), m_schema.isInDomain(), m_schema, dataType, data); dbop.executeUpdate(); return ((Integer)dbop.getReturnData()).intValue(); }

$Id:,v 1.10 2007/01/28 06:54:42 bastafidli Exp $
Julian Legeny
Code reviewer:
Miro Halas
Code reviewed:
1.1 2006/07/26 23:44:50 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
Constructor Summary
DatabaseCreateSingleDataObjectOperation(DatabaseFactoryImpl factory, java.lang.String strQueryToPrepare, ModifiableDatabaseSchema schema, java.lang.Object data)
          Constructor to use when database update doesn't require any prepared statement.
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


public DatabaseCreateSingleDataObjectOperation(DatabaseFactoryImpl factory,
                                               java.lang.String strQueryToPrepare,
                                               ModifiableDatabaseSchema schema,
                                               java.lang.Object data)
Constructor to use when database update doesn't require any prepared statement.

factory - - factory which is executing this operation
strQueryToPrepare - - query which should be used to construct prepared statement which will be passed in to executeUpdate
schema - - database schema used with this operation
data - - data used for operation
Method Detail


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

performOperation in class DatabaseUpdateOperation
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.
OSSException - - an error has occured
java.sql.SQLException - - an error has occured

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