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. |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| public void | buildSelectionCriteria(AbstractSession session)
Internal: In the case of EJBQL, an expression needs to be generated. |
| public Object | checkCacheForObject(AbstractRecord translationRow, AbstractSession session)
Perform a cache lookup for the query. |
| public Object | |
| public DatabaseQueryMechanism | |
| public abstract DatabaseCall | |
| public abstract Integer | |
| public abstract Integer | |
| public abstract Object | Returns: true if the first result is a result set and false if it is an update count or there are no results other than through INOUT and OUT parameterts, if any.Execute a execute SQL call. |
| public void | |
| public abstract Object | Returns: the row count.Execute a non selecting SQL call This should be overridden by subclasses. |
| public abstract Vector | |
| public Object | executeWrite()
Check whether the object already exists on the database; then perform an insert or update, as appropriate. |
| public Object | executeWriteWithChangeSet()
Check whether the object already exists on the cadatabase; then perform an insert or update, as appropriate. |
| public abstract DatabaseCall | generateKeysExecuteNoSelect()
Execute a non selecting SQL call, that returns the generated keys This should be overridden by subclasses. |
| protected ClassDescriptor | |
| protected AbstractSession | |
| public AbstractRecord | |
| public DatabaseQuery | |
| protected ReadObjectQuery | |
| public Expression | |
| protected AbstractSession | |
| protected AbstractRecord | |
| protected WriteObjectQuery | |
| public abstract void | |
| public void | insertObject(boolean reprepare)
Insert an object and provide the opportunity to reprepare prior to the insert. |
| public void | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| protected void | |
| protected void | |
| protected void | performUserDefinedWrite(WriteObjectQuery userDefinedWriteQuery)
Write the object using the specified user-defined query. |
| public 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. |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| protected void | registerObjectInIdentityMap(Object object, ClassDescriptor descriptor, AbstractSession session)
Store the query object in the identity map. |
| public abstract Vector | |
| public abstract Vector | |
| public abstract AbstractRecord | |
| public abstract AbstractRecord | selectRowForDoesExist(DatabaseField field)
Read and return a row from the database for an existence check. |
| public void | |
| protected void | shallowInsertObjectForWrite(Object object, WriteObjectQuery writeQuery, CommitManager commitManager)
Shallow insert the specified object, if necessary. |
| public void | |
| public abstract Integer | |
| protected void | updateForeignKeyFieldAfterInsert()
Update the foreign key fields when resolving a bi-directonal reference in a UOW. |
| protected abstract void | updateForeignKeyFieldAfterInsert(WriteObjectQuery writeQuery)
Update the foreign key fields when resolving a bi-directonal reference in a UOW. |
| public void | updateForeignKeyFieldBeforeDelete()
Update the foreign key fields to null when resolving a deletion cycle. |
| public abstract Integer | |
| protected void | |
| protected void | updateObjectAndRowWithSequenceNumber()
Update the object's primary key by fetching a new sequence number from the accessor. |
| protected void | updateObjectAndRowWithSequenceNumber(DatabaseCall call)
Update the object's primary key by getting the generated keys from the call
If there are no generated keys or the value is NULL, then default back to the |
| public void | |
| public void |
| query | back to summary |
|---|---|
| protected DatabaseQuery query The database query that uses this mechanism. | |
| DatabaseQueryMechanism | back to summary |
|---|---|
| protected DatabaseQueryMechanism() Initialize the state of the query. | |
| DatabaseQueryMechanism | back to summary |
|---|---|
| protected DatabaseQueryMechanism(DatabaseQuery query) Initialize the state of the query
| |
| addWriteLockFieldForInsert | back to summary |
|---|---|
| protected void addWriteLockFieldForInsert() Add the initial write lock value to the row for insert. | |
| buildSelectionCriteria | back to summary |
|---|---|
| public void buildSelectionCriteria(AbstractSession session) Internal: In the case of EJBQL, an expression needs to be generated. Build the required expression. | |
| checkCacheForObject | back to summary |
|---|---|
| public Object checkCacheForObject(AbstractRecord translationRow, AbstractSession session) Perform a cache lookup for the query. If the translation row contains all the parameters (which are part of the primary key) from the prepared call, then a cache check will be performed. If the object is found in the cache, return it; otherwise return null. | |
| clone | back to summary |
|---|---|
| public Object clone() Overrides java. Clone the mechanism
| |
| clone | back to summary |
|---|---|
| public DatabaseQueryMechanism clone(DatabaseQuery queryClone) Clone the mechanism for the specified query clone. | |
| cursorSelectAllRows | back to summary |
|---|---|
| public abstract DatabaseCall cursorSelectAllRows() throws DatabaseException Read all rows from the database using a cursored stream.
| |
| deleteAll | back to summary |
|---|---|
| public abstract Integer deleteAll() throws DatabaseException | |
| deleteObject | back to summary |
|---|---|
| public abstract Integer deleteObject() throws DatabaseException Delete an object This should be overridden by subclasses.
| |
| execute | back to summary |
|---|---|
| public abstract Object execute() throws DatabaseException Execute a execute SQL call. This should be overridden by subclasses.
| |
| executeDeferredCall | back to summary |
|---|---|
| public void executeDeferredCall(DatasourceCall call) Execute the call that was deferred to the commit manager. This is used to allow multiple table batching and deadlock avoidance. | |
| executeNoSelect | back to summary |
|---|---|
| public abstract Object executeNoSelect() throws DatabaseException Execute a non selecting SQL call This should be overridden by subclasses.
| |
| executeSelect | back to summary |
|---|---|
| public abstract Vector Execute a select SQL call and return the rows. This should be overriden by subclasses. | |
| executeWrite | back to summary |
|---|---|
| public Object executeWrite() throws DatabaseException, OptimisticLockException Check whether the object already exists on the database; then perform an insert or update, as appropriate. This write is used for non-unit of work (old-commit) operations. Return the object being written. | |
| executeWriteWithChangeSet | back to summary |
|---|---|
| public Object executeWriteWithChangeSet() throws DatabaseException, OptimisticLockException Check whether the object already exists on the cadatabase; then perform an insert or update, as appropriate. This method was moved here, from WriteObjectQuery.execute(), so we can hide the source. Return the object being written. | |
| generateKeysExecuteNoSelect | back to summary |
|---|---|
| public abstract DatabaseCall generateKeysExecuteNoSelect() throws DatabaseException Execute a non selecting SQL call, that returns the generated keys This should be overridden by subclasses. | |
| getDescriptor | back to summary |
|---|---|
| protected ClassDescriptor getDescriptor() Convenience method | |
| getExecutionSession | back to summary |
|---|---|
| protected AbstractSession getExecutionSession() Convenience method | |
| getModifyRow | back to summary |
|---|---|
| public AbstractRecord getModifyRow() Convenience method | |
| getQuery | back to summary |
|---|---|
| public DatabaseQuery getQuery() Return the query that uses the mechanism. | |
| getReadObjectQuery | back to summary |
|---|---|
| protected ReadObjectQuery getReadObjectQuery() Convenience method | |
| getSelectionCriteria | back to summary |
|---|---|
| public Expression getSelectionCriteria() Return the selection criteria for the mechanism. By default this is null. This method exists because both statement and expression mechanisms use an expression and some code in the mappings depends on returning this. | |
| getSession | back to summary |
|---|---|
| protected AbstractSession getSession() Convenience method | |
| getTranslationRow | back to summary |
|---|---|
| protected AbstractRecord getTranslationRow() Convenience method | |
| getWriteObjectQuery | back to summary |
|---|---|
| protected WriteObjectQuery getWriteObjectQuery() Convenience method | |
| insertObject | back to summary |
|---|---|
| public abstract void insertObject() throws DatabaseException Insert an object. | |
| insertObject | back to summary |
|---|---|
| public void insertObject(boolean reprepare) Insert an object and provide the opportunity to reprepare prior to the insert. This will be overridden CR#3237 | |
| insertObjectForWrite | back to summary |
|---|---|
| public void insertObjectForWrite() Insert an object in the database. This is used for both uow and non-uow (old-commit and change-set) operations. | |
| isCallQueryMechanism | back to summary |
|---|---|
| public boolean isCallQueryMechanism() Return true if this is a call query mechanism | |
| isExpressionQueryMechanism | back to summary |
|---|---|
| public boolean isExpressionQueryMechanism() Return true if this is an expression query mechanism | |
| isJPQLCallQueryMechanism | back to summary |
|---|---|
| public boolean isJPQLCallQueryMechanism() Delete a collection of objects This should be overridden by subclasses.
| |
| isQueryByExampleMechanism | back to summary |
|---|---|
| public boolean isQueryByExampleMechanism() Return true if this is a query by example mechanism | |
| isStatementQueryMechanism | back to summary |
|---|---|
| public boolean isStatementQueryMechanism() Return true if this is a statement query mechanism | |
| performUserDefinedInsert | back to summary |
|---|---|
| protected void performUserDefinedInsert() Insert the object using the user defined query. This ensures that the query is cloned and prepared correctly. | |
| performUserDefinedUpdate | back to summary |
|---|---|
| protected void performUserDefinedUpdate() Update the object using the user defined query. This ensures that the query is cloned and prepared correctly. | |
| performUserDefinedWrite | back to summary |
|---|---|
| protected void performUserDefinedWrite(WriteObjectQuery userDefinedWriteQuery) Write the object using the specified user-defined query. This ensures that the query is cloned and prepared correctly. | |
| prepare | back to summary |
|---|---|
| public void prepare() throws QueryException 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. This query is copied for concurrency so this prepare can only setup things that will apply to any future execution of this query. | |
| prepareCursorSelectAllRows | back to summary |
|---|---|
| public abstract void prepareCursorSelectAllRows() throws QueryException Pre-pare for a cursored execute. This is sent to the original query before cloning. | |
| prepareDeleteAll | back to summary |
|---|---|
| public abstract void prepareDeleteAll() throws QueryException Prepare for a delete all. This is sent to the original query before cloning. | |
| prepareDeleteObject | back to summary |
|---|---|
| public abstract void prepareDeleteObject() throws QueryException Prepare for a delete. This is sent to the original query before cloning. | |
| prepareDoesExist | back to summary |
|---|---|
| public abstract void prepareDoesExist(DatabaseField field) throws QueryException Pre-pare for a select execute. This is sent to the original query before cloning. | |
| prepareExecute | back to summary |
|---|---|
| public abstract void prepareExecute() throws QueryException Prepare for a raw execute call. This is sent to the original query before cloning. | |
| prepareExecuteNoSelect | back to summary |
|---|---|
| public abstract void prepareExecuteNoSelect() throws QueryException Prepare for a raw (non-object), non-selecting call. This is sent to the original query before cloning. | |
| prepareExecuteSelect | back to summary |
|---|---|
| public abstract void prepareExecuteSelect() throws QueryException Prepare for a raw (non-object) select call. This is sent to the original query before cloning. | |
| prepareInsertObject | back to summary |
|---|---|
| public abstract void prepareInsertObject() throws QueryException Prepare for an insert. This is sent to the original query before cloning. | |
| prepareReportQuerySelectAllRows | back to summary |
|---|---|
| public abstract void prepareReportQuerySelectAllRows() throws QueryException Pre-pare for a select execute. This is sent to the original query before cloning. | |
| prepareReportQuerySubSelect | back to summary |
|---|---|
| public abstract void prepareReportQuerySubSelect() throws QueryException Pre-pare a report query for a sub-select. | |
| prepareSelectAllRows | back to summary |
|---|---|
| public abstract void prepareSelectAllRows() throws QueryException Prepare for a select returning (possibly) multiple rows. This is sent to the original query before cloning. | |
| prepareSelectOneRow | back to summary |
|---|---|
| public abstract void prepareSelectOneRow() throws QueryException Prepare for a select returning a single row. This is sent to the original query before cloning. | |
| prepareUpdateAll | back to summary |
|---|---|
| public abstract void prepareUpdateAll() throws QueryException Prepare for an update all. This is sent to the original query before cloning. | |
| prepareUpdateObject | back to summary |
|---|---|
| public abstract void prepareUpdateObject() throws QueryException Prepare for an update. This is sent to the original query before cloning. | |
| registerObjectInIdentityMap | back to summary |
|---|---|
| protected void registerObjectInIdentityMap(Object object, ClassDescriptor descriptor, AbstractSession session) Store the query object in the identity map. | |
| selectAllReportQueryRows | back to summary |
|---|---|
| public abstract Vector INTERNAL: Read all rows from the database. | |
| selectAllRows | back to summary |
|---|---|
| public abstract Vector Read and return rows from the database. | |
| selectOneRow | back to summary |
|---|---|
| public abstract AbstractRecord selectOneRow() throws DatabaseException Read and return a row from the database. | |
| selectRowForDoesExist | back to summary |
|---|---|
| public abstract AbstractRecord selectRowForDoesExist(DatabaseField field) throws DatabaseException Read and return a row from the database for an existence check. | |
| setQuery | back to summary |
|---|---|
| public void setQuery(DatabaseQuery query) Set the query that uses this mechanism. | |
| shallowInsertObjectForWrite | back to summary |
|---|---|
| protected void shallowInsertObjectForWrite(Object object, WriteObjectQuery writeQuery, CommitManager commitManager) throws DatabaseException, OptimisticLockException Shallow insert the specified object, if necessary. | |
| unprepare | back to summary |
|---|---|
| public void unprepare() Unprepare the call if required. | |
| updateAll | back to summary |
|---|---|
| public abstract Integer updateAll() throws DatabaseException Issue update SQL statement | |
| updateForeignKeyFieldAfterInsert | back to summary |
|---|---|
| protected void updateForeignKeyFieldAfterInsert() Update the foreign key fields when resolving a bi-directonal reference in a UOW. This must always be dynamic as it is called within an insert query and is really part of the insert and does not fire update events or worry about locking. | |
| updateForeignKeyFieldAfterInsert | back to summary |
|---|---|
| protected abstract void updateForeignKeyFieldAfterInsert(WriteObjectQuery writeQuery) Update the foreign key fields when resolving a bi-directonal reference in a UOW. This must always be dynamic as it is called within an insert query and is really part of the insert and does not fire update events or worry about locking. | |
| updateForeignKeyFieldBeforeDelete | back to summary |
|---|---|
| public void updateForeignKeyFieldBeforeDelete() Update the foreign key fields to null when resolving a deletion cycle. This must always be dynamic as it is called within an delete query and is really part of the delete and does not fire update events or worry about locking. | |
| updateObject | back to summary |
|---|---|
| public abstract Integer updateObject() throws DatabaseException Update an object. Return the row count. | |
| updateObjectAndRowWithReturnRow | back to summary |
|---|---|
| protected void updateObjectAndRowWithReturnRow(Collection<E> returnFields, boolean isFirstCallForInsert) | |
| updateObjectAndRowWithSequenceNumber | back to summary |
|---|---|
| protected void updateObjectAndRowWithSequenceNumber() throws DatabaseException Update the object's primary key by fetching a new sequence number from the accessor. | |
| updateObjectAndRowWithSequenceNumber | back to summary |
|---|---|
| protected void updateObjectAndRowWithSequenceNumber(DatabaseCall call) throws DatabaseException Update the object's primary key by getting the generated keys from the call
If there are no generated keys or the value is NULL, then default back to the | |
| updateObjectForWrite | back to summary |
|---|---|
| public void updateObjectForWrite() Update the object. This is only used for non-unit-of-work updates. | |
| updateObjectForWriteWithChangeSet | back to summary |
|---|---|
| public void updateObjectForWriteWithChangeSet() Update the object. This is used by the unit-of-work update. | |