org.opensubsystems.core.persist.db
Class DatabaseCreateSingleDataObjectOperation
java.lang.Object
org.opensubsystems.core.persist.db.DatabaseOperation
org.opensubsystems.core.persist.db.DatabaseUpdateOperation
org.opensubsystems.core.persist.db.DatabaseCreateSingleDataObjectOperation
- All Implemented Interfaces:
- DatabaseOperations
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();
}
- Version:
- $Id: DatabaseCreateSingleDataObjectOperation.java,v 1.10 2007/01/28 06:54:42 bastafidli Exp $
- Author:
- Julian Legeny
- Code reviewer:
- Miro Halas
- Code reviewed:
- 1.1 2006/07/26 23:44:50 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 |
DatabaseCreateSingleDataObjectOperation
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.
- Parameters:
factory - - factory which is executing this operationstrQueryToPrepare - - query which should be used to construct prepared
statement which will be passed in to executeUpdateschema - - database schema used with this operationdata - - data used for operation
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.