public abstract class DatabaseQueryMechanism extends Object implements Cloneable, Serializable
Purpose: Abstract class for all database query mechanism objects. DatabaseQueryMechanism is actually a helper class and currently is required for all types of queries. Most of the work performed by the query framework is performed in the query mechanism. The query mechanism contains the internal knowledge necessary to perform the specific database operation.
Responsibilities: Provide a common protocol for query mechanism objects. Provides all of the database specific work for the assigned query.
Modifier and Type | Field and Description |
---|---|
protected DatabaseQuery |
query
The database query that uses this mechanism.
|
Constructor and Description |
---|
DatabaseQueryMechanism()
Initialize the state of the query.
|
DatabaseQueryMechanism(DatabaseQuery query)
Initialize the state of the query
|
Modifier and Type | Method and Description |
---|---|
protected void |
addObjectDeletedDuringCommit()
Remove the query object from the identity map.
|
protected void |
addWriteLockFieldForInsert()
Add the initial write lock value to the row for insert.
|
Object |
buildObjectsFromRows(Vector rows)
Build the objects for the rows, and answer them
|
void |
buildSelectionCriteria(AbstractSession session)
Internal:
In the case of EJBQL, an expression needs to be generated.
|
Object |
checkCacheForObject(AbstractRecord translationRow,
AbstractSession session)
Perform a cache lookup for the query.
|
protected Object |
clone()
Clone the mechanism
|
DatabaseQueryMechanism |
clone(DatabaseQuery queryClone)
Clone the mechanism for the specified query clone.
|
abstract DatabaseCall |
cursorSelectAllRows()
Read all rows from the database using a cursored stream.
|
abstract Integer |
deleteAll() |
abstract Integer |
deleteObject()
Delete an object
This should be overriden by subclasses.
|
void |
deleteObjectForWrite()
Delete an object from the database.
|
abstract Integer |
executeNoSelect()
Execute a non selecting SQL call
This should be overriden by subclasses.
|
abstract Vector |
executeSelect()
Execute a select SQL call and return the rows.
|
Object |
executeWrite()
Check whether the object already exists on the database; then
perform an insert, update or delete, as appropriate.
|
Object |
executeWriteWithChangeSet()
Check whether the object already exists on the database; then
perform an insert or update, as appropriate.
|
protected ClassDescriptor |
getDescriptor()
Convenience method
|
AbstractRecord |
getModifyRow()
Convenience method
|
DatabaseQuery |
getQuery()
Return the query that uses the mechanism.
|
protected ReadObjectQuery |
getReadObjectQuery()
Convenience method
|
Expression |
getSelectionCriteria()
Return the selection criteria for the mechanism.
|
protected AbstractSession |
getSession()
Convenience method
|
protected AbstractRecord |
getTranslationRow()
Convenience method
|
protected WriteObjectQuery |
getWriteObjectQuery()
Convenience method
|
abstract void |
insertObject()
Insert an object.
|
void |
insertObject(boolean reprepare)
Insert an object and provide the opportunity to reprepare prior to the insert.
|
void |
insertObjectForWrite()
Insert an object in the database.
|
void |
insertObjectForWriteWithChangeSet()
Insert an object in the database.
|
boolean |
isCallQueryMechanism()
Return true if this is a call query mechanism
|
boolean |
isEJBQLCallQueryMechanism()
Delete a collection of objects
This should be overriden by subclasses.
|
boolean |
isExpressionQueryMechanism()
Return true if this is an expression query mechanism
|
boolean |
isQueryByExampleMechanism()
Return true if this is a query by example mechanism
|
boolean |
isStatementQueryMechanism()
Return true if this is a statement query mechanism
|
protected void |
performUserDefinedDelete()
Delete the object using the user defined query.
|
protected void |
performUserDefinedInsert()
Insert the object using the user defined query.
|
protected void |
performUserDefinedUpdate()
Update the object using the user defined query.
|
protected void |
performUserDefinedWrite(WriteObjectQuery userDefinedWriteQuery)
Write the object using the specified user-defined query.
|
void |
prepare()
This is different from 'prepareForExecution()'
in that this is called on the original query,
and the other is called on the clone of the query.
|
abstract void |
prepareCursorSelectAllRows()
Pre-pare for a cursored execute.
|
abstract void |
prepareDeleteAll()
Prepare for a delete all.
|
abstract void |
prepareDeleteObject()
Prepare for a delete.
|
abstract void |
prepareDoesExist(DatabaseField field)
Pre-pare for a select execute.
|
abstract void |
prepareExecuteNoSelect()
Prepare for a raw (non-object), non-selecting call.
|
abstract void |
prepareExecuteSelect()
Prepare for a raw (non-object) select call.
|
void |
prepareForExecution()
All the query mechanism related things are initialized here.
|
abstract void |
prepareInsertObject()
Prepare for an insert.
|
abstract void |
prepareReportQuerySelectAllRows()
Pre-pare for a select execute.
|
abstract void |
prepareReportQuerySubSelect()
Pre-pare a report query for a sub-select.
|
abstract void |
prepareSelectAllRows()
Prepare for a select returning (possibly) multiple rows.
|
abstract void |
prepareSelectOneRow()
Prepare for a select returning a single row.
|
abstract void |
prepareUpdateAll()
Prepare for an update all.
|
abstract void |
prepareUpdateObject()
Prepare for an update.
|
protected void |
registerObjectInIdentityMap()
Store the query object in the identity map.
|
abstract Vector |
selectAllReportQueryRows()
INTERNAL:
Read all rows from the database.
|
abstract Vector |
selectAllRows()
Read and return rows from the database.
|
abstract AbstractRecord |
selectOneRow()
Read and return a row from the database.
|
abstract AbstractRecord |
selectRowForDoesExist(DatabaseField field)
Read and return a row from the database for an existence check.
|
void |
setQuery(DatabaseQuery query)
Set the query that uses this mechanism.
|
void |
shallowDeleteObjectForWrite(Object object,
WriteObjectQuery writeQuery,
CommitManager commitManager)
INTERNAL:
Shallow delete the specified object.
|
void |
shallowInsertObjectForWrite(Object object,
WriteObjectQuery writeQuery,
CommitManager commitManager)
INTERNAL:
Shallow insert the specified object.
|
abstract Integer |
updateAll()
Issue update SQL statement
|
void |
updateChangeSet(ClassDescriptor desc,
ObjectChangeSet objectChangeSet,
AbstractRecord row,
Object object)
Update the change set with all of the field values in the row.
|
protected void |
updateChangeSet(ClassDescriptor desc,
ObjectChangeSet objectChangeSet,
DatabaseField field,
Object object) |
protected void |
updateChangeSet(ClassDescriptor desc,
ObjectChangeSet objectChangeSet,
DatabaseField field,
Object object,
Collection handledMappings) |
protected void |
updateChangeSet(DatabaseMapping mapping,
ObjectChangeSet objectChangeSet,
DatabaseField field,
Object object,
Collection handledMappings) |
protected void |
updateForeignKeyFieldAfterInsert()
Update the foreign key fields when resolving a bi-directonal reference in a UOW.
|
protected void |
updateForeignKeyFieldBeforeDelete()
Null out the foreign key fields when resolving a bi-directonal reference in a UOW.
|
protected abstract void |
updateForeignKeyFieldShallow(WriteObjectQuery writeQuery)
Update the foreign key fields when resolving a bi-directonal reference in a UOW.
|
abstract Integer |
updateObject()
Update an object.
|
protected void |
updateObjectAndRowWithReturnRow(Collection returnFields,
boolean isFirstCallForInsert) |
protected void |
updateObjectAndRowWithSequenceNumber()
Update the object's primary key by fetching a new sequence number from the accessor.
|
void |
updateObjectForWrite()
Update the object
|
void |
updateObjectForWriteWithChangeSet()
Update the object
|
protected DatabaseQuery query
public DatabaseQueryMechanism()
public DatabaseQueryMechanism(DatabaseQuery query)
query
- - owner of mechanismprotected void addObjectDeletedDuringCommit()
protected void addWriteLockFieldForInsert()
public void buildSelectionCriteria(AbstractSession session)
public Object checkCacheForObject(AbstractRecord translationRow, AbstractSession session)
public DatabaseQueryMechanism clone(DatabaseQuery queryClone)
public abstract DatabaseCall cursorSelectAllRows() throws DatabaseException
DatabaseException
- - an error has occurred on the databasepublic boolean isEJBQLCallQueryMechanism()
DatabaseException
- - an error has occurred on the databasepublic Object buildObjectsFromRows(Vector rows) throws DatabaseException
DatabaseException
- - an error has occurred on the databasepublic abstract Integer deleteAll() throws DatabaseException
DatabaseException
public abstract Integer deleteObject() throws DatabaseException
DatabaseException
public void deleteObjectForWrite()
public abstract Integer executeNoSelect() throws DatabaseException
DatabaseException
public abstract Vector executeSelect() throws DatabaseException
DatabaseException
public Object executeWrite() throws DatabaseException, OptimisticLockException
public Object executeWriteWithChangeSet() throws DatabaseException, OptimisticLockException
protected ClassDescriptor getDescriptor()
public AbstractRecord getModifyRow()
public DatabaseQuery getQuery()
protected ReadObjectQuery getReadObjectQuery()
public Expression getSelectionCriteria()
protected AbstractSession getSession()
protected AbstractRecord getTranslationRow()
protected WriteObjectQuery getWriteObjectQuery()
public abstract void insertObject() throws DatabaseException
DatabaseException
public void insertObject(boolean reprepare)
public void insertObjectForWrite()
public void insertObjectForWriteWithChangeSet()
public boolean isCallQueryMechanism()
public boolean isExpressionQueryMechanism()
public boolean isQueryByExampleMechanism()
public boolean isStatementQueryMechanism()
protected void performUserDefinedDelete()
protected void performUserDefinedInsert()
protected void performUserDefinedUpdate()
protected void performUserDefinedWrite(WriteObjectQuery userDefinedWriteQuery)
public void prepare() throws QueryException
QueryException
public abstract void prepareCursorSelectAllRows() throws QueryException
QueryException
public abstract void prepareDeleteAll() throws QueryException
QueryException
public abstract void prepareDeleteObject() throws QueryException
QueryException
public abstract void prepareDoesExist(DatabaseField field) throws QueryException
QueryException
public abstract void prepareExecuteNoSelect() throws QueryException
QueryException
public abstract void prepareExecuteSelect() throws QueryException
QueryException
public void prepareForExecution() throws QueryException
QueryException
public abstract void prepareInsertObject() throws QueryException
QueryException
public abstract void prepareReportQuerySelectAllRows() throws QueryException
QueryException
public abstract void prepareReportQuerySubSelect() throws QueryException
QueryException
public abstract void prepareSelectAllRows() throws QueryException
QueryException
public abstract void prepareSelectOneRow() throws QueryException
QueryException
public abstract void prepareUpdateObject() throws QueryException
QueryException
public abstract void prepareUpdateAll() throws QueryException
QueryException
protected void registerObjectInIdentityMap()
public abstract Vector selectAllReportQueryRows() throws DatabaseException
DatabaseException
public abstract Vector selectAllRows() throws DatabaseException
DatabaseException
public abstract AbstractRecord selectOneRow() throws DatabaseException
DatabaseException
public abstract AbstractRecord selectRowForDoesExist(DatabaseField field) throws DatabaseException
DatabaseException
public void setQuery(DatabaseQuery query)
public void shallowDeleteObjectForWrite(Object object, WriteObjectQuery writeQuery, CommitManager commitManager) throws DatabaseException, OptimisticLockException
public void shallowInsertObjectForWrite(Object object, WriteObjectQuery writeQuery, CommitManager commitManager) throws DatabaseException, OptimisticLockException
protected void updateForeignKeyFieldAfterInsert()
protected void updateForeignKeyFieldBeforeDelete()
public abstract Integer updateAll() throws DatabaseException
DatabaseException
public abstract Integer updateObject() throws DatabaseException
DatabaseException
protected abstract void updateForeignKeyFieldShallow(WriteObjectQuery writeQuery)
protected void updateObjectAndRowWithReturnRow(Collection returnFields, boolean isFirstCallForInsert)
public void updateChangeSet(ClassDescriptor desc, ObjectChangeSet objectChangeSet, AbstractRecord row, Object object)
protected void updateChangeSet(ClassDescriptor desc, ObjectChangeSet objectChangeSet, DatabaseField field, Object object)
protected void updateChangeSet(ClassDescriptor desc, ObjectChangeSet objectChangeSet, DatabaseField field, Object object, Collection handledMappings)
protected void updateChangeSet(DatabaseMapping mapping, ObjectChangeSet objectChangeSet, DatabaseField field, Object object, Collection handledMappings)
protected void updateObjectAndRowWithSequenceNumber() throws DatabaseException
DatabaseException
public void updateObjectForWrite()
public void updateObjectForWriteWithChangeSet()
Copyright © 2021. All rights reserved.