public class ReadObjectQuery extends ObjectLevelReadQuery
Purpose: Concrete class for all read queries involving a single object.
Responsibilities: Return a single object for the query. Implements the inheritance feature when dealing with abstract descriptors.
Modifier and Type | Field and Description |
---|---|
protected Vector |
selectionKey
Key that can be used in place of a selection criteria.
|
protected Object |
selectionObject
Object that can be used in place of a selection criteria.
|
protected boolean |
shouldLoadResultIntoSelectionObject
Can be used to refresh a specific non-cached instance from the database.
|
additionalFields, cacheUsage, CheckCacheByExactPrimaryKey, CheckCacheByPrimaryKey, CheckCacheOnly, CheckCacheThenDatabase, ConformResultsInUnitOfWork, defaultBuilder, distinctState, DoNotCheckCache, DONT_USE_DISTINCT, executionTime, fetchGroup, fetchGroupName, inMemoryQueryIndirectionPolicy, joinedAttributeManager, LOCK_RESULT_PROPERTY, nonFetchJoinAttributeExpressions, shouldIncludeData, shouldProcessResultsInUnitOfWork, shouldRefreshIdentityMapResult, shouldRegisterResultsInUnitOfWork, shouldUseDefaultFetchGroup, UNCOMPUTED_DISTINCT, USE_DISTINCT, UseDescriptorSetting, wasDefaultLockMode
DEFAULT_LOCK_MODE, isPrePrepared, LOCK, LOCK_NOWAIT, lockingClause, NO_LOCK, referenceClass, referenceClassName, shouldRefreshRemoteIdentityMapResult, shouldUseExclusiveConnection
firstResult, maxRows, queryId
accessor, arguments, argumentTypeNames, argumentTypes, argumentValues, CascadeAggregateDelete, CascadeAllParts, CascadeByMapping, CascadeDependentParts, cascadePolicy, CascadePrivateParts, descriptor, flushOnExecute, isPrepared, isUserDefined, name, NoCascading, properties, queryMechanism, session, sessionName, shouldBindAllParameters, shouldCacheStatement, shouldCloneCall, shouldMaintainCache, shouldPrepare, shouldUseWrapperPolicy, translationRow
False, True, Undefined
Constructor and Description |
---|
ReadObjectQuery()
PUBLIC:
Return a new read object query.
|
ReadObjectQuery(Call call)
PUBLIC:
Return a new read object query.
|
ReadObjectQuery(Class classToRead)
PUBLIC:
Return a new read object query.
|
ReadObjectQuery(Class classToRead,
Call call)
PUBLIC:
Return a new read object query.
|
ReadObjectQuery(Class classToRead,
Expression selectionCriteria)
PUBLIC:
Return a new read object query for the class and the selection criteria.
|
ReadObjectQuery(Class classToRead,
ExpressionBuilder builder)
PUBLIC:
Return a new read object query for the class.
|
ReadObjectQuery(ExpressionBuilder builder)
PUBLIC:
The expression builder should be provide on creation to ensure only one is used.
|
ReadObjectQuery(Object objectToRead)
PUBLIC:
Return a query to read the object with the same primary key as the provided object.
|
Modifier and Type | Method and Description |
---|---|
void |
checkCacheByExactPrimaryKey()
PUBLIC:
The cache will be checked only if the query contains exactly the primary key.
|
void |
checkCacheByPrimaryKey()
PUBLIC:
This is the default, the cache will be checked only if the query contains the primary key.
|
void |
checkCacheThenDatabase()
PUBLIC:
The cache will be checked completely, then if the object is not found or the query too complex the database will be queried.
|
void |
checkDescriptor(AbstractSession session)
INTERNAL:
Ensure that the descriptor has been set.
|
protected Object |
checkEarlyReturnImpl(AbstractSession session,
AbstractRecord translationRow)
INTERNAL:
The cache check is done before the prepare as a hit will not require the work to be done.
|
protected DatabaseQuery |
checkForCustomQuery(AbstractSession session,
AbstractRecord translationRow)
INTERNAL:
Check to see if a custom query should be used for this query.
|
protected Object |
conformResult(Object result,
UnitOfWorkImpl unitOfWork,
AbstractRecord databaseRow,
boolean buildDirectlyFromRows)
INTERNAL:
Conform the result in the UnitOfWork.
|
void |
dontLoadResultIntoSelectionObject()
PUBLIC:
Do not refesh/load into the selection object, this is the default.
|
protected Object |
executeObjectLevelReadQuery()
INTERNAL:
Execute the query.
|
Vector |
getSelectionKey()
PUBLIC:
The primary key can be specified if used instead of an expression or selection object.
|
Object |
getSelectionObject()
PUBLIC:
Return the selection object of the query.
|
protected boolean |
hasNonDefaultFetchGroup()
INTERNAL:
Return if the query has an non-default fetch group defined for itself.
|
boolean |
isReadObjectQuery()
PUBLIC:
Return if this is a read object query.
|
void |
loadResultIntoSelectionObject()
PUBLIC:
Allow for the selection object of the query to be refreshed or put into the TopLink cache.
|
protected void |
prepare()
INTERNAL:
Prepare the receiver for execution in a session.
|
protected void |
prepareCustomQuery(DatabaseQuery customQuery)
INTERNAL:
Set the properties needed to be cascaded into the custom query inlucding the translation row.
|
void |
prepareForExecution()
INTERNAL:
Prepare the receiver for execution in a session.
|
Object |
registerResultInUnitOfWork(Object result,
UnitOfWorkImpl unitOfWork,
AbstractRecord arguments,
boolean buildDirectlyFromRows)
INTERNAL:
All objects queried via a UnitOfWork get registered here.
|
void |
setSelectionKey(Vector selectionKey)
PUBLIC:
The primary key can be specified if used instead of an expression or selection object.
|
void |
setSelectionObject(Object selectionObject)
PUBLIC:
Used to set the where clause of the query.
|
void |
setShouldLoadResultIntoSelectionObject(boolean shouldLoadResultIntoSelectionObject)
PUBLIC:
Allow for the selection object of the query to be refreshed or put into the TopLink cache.
|
void |
setSingletonSelectionKey(Object selectionKey)
PUBLIC:
The primary key can be specified if used instead of an expression or selection object.
|
boolean |
shouldCheckCache()
PUBLIC:
Return if the cache should be checked.
|
boolean |
shouldCheckCacheByExactPrimaryKey()
PUBLIC:
Return if cache should be checked.
|
boolean |
shouldCheckCacheByPrimaryKey()
PUBLIC:
Return if cache should be checked.
|
boolean |
shouldCheckCacheThenDatabase()
PUBLIC:
Return if cache should be checked.
|
boolean |
shouldLoadResultIntoSelectionObject()
PUBLIC:
return true if the result should be loaded into the passed in selection Object
|
acquireLocks, acquireLocksWithoutWaiting, addAdditionalField, addAdditionalField, addJoinedAttribute, addJoinedAttribute, addNonFetchJoinedAttribute, addNonFetchJoinedAttribute, addSelectionFieldsForJoinedExpressions, buildObject, changeDescriptor, checkCacheOnly, checkEarlyReturn, checkPrepare, checkPrePrepare, clone, conformIndividualResult, conformResultsInUnitOfWork, deepClone, dontAcquireLocks, dontCheckCache, dontRefreshIdentityMapResult, dontUseDistinct, execute, executeDatabaseQuery, executeInUnitOfWork, getAdditionalFields, getCacheUsage, getDistinctState, getExecutionTime, getExpressionBuilder, getFetchGroup, getFetchGroupName, getInMemoryQueryIndirectionPolicy, getJoinedAttributeManager, getLeafDescriptorFor, getLeafMappingFor, getLockingClause, getLockMode, getNonFetchJoinAttributeExpressions, getReferenceClass, getReferenceClassName, getSelectionFields, hasAsOfClause, hasFetchGroupAttributeExpressions, hasNonFetchJoinedAttributeExpressions, hasPartialAttributeExpressions, initializeDefaultBuilder, initializeFetchGroup, isClonePessimisticLocked, isDefaultLock, isDistinctComputed, isFetchGroupAttribute, isLockQuery, isLockQuery, isObjectLevelReadQuery, isPrePrepared, isRegisteringResults, prepareOutsideUnitOfWork, prepareQuery, prePrepare, recordCloneForPessimisticLocking, refreshIdentityMapResult, resetDistinct, setAdditionalFields, setCacheUsage, setDescriptor, setDistinctState, setEJBQLString, setExecutionTime, setExpressionBuilder, setFetchGroup, setFetchGroupName, setInMemoryQueryIndirectionPolicy, setIsPrePrepared, setLockingClause, setLockMode, setNonFetchJoinAttributeExpressions, setReferenceClass, setReferenceClassName, setSelectionCriteria, setShouldIncludeData, setShouldProcessResultsInUnitOfWork, setShouldRefreshIdentityMapResult, setShouldRegisterResultsInUnitOfWork, setShouldUseDefaultFetchGroup, setWasDefaultLockMode, shouldCheckCacheOnly, shouldCheckDescriptorForCacheUsage, shouldConformResultsInUnitOfWork, shouldDistinctBeUsed, shouldIncludeData, shouldProcessResultsInUnitOfWork, shouldReadAllMappings, shouldReadMapping, shouldRefreshIdentityMapResult, shouldRegisterResultsInUnitOfWork, shouldUseDefaultFetchGroup, toString, useDistinct, wasDefaultLockMode
convertClassNamesToClasses, dontRefreshRemoteIdentityMapResult, getDataResults, isAttributeJoined, isObjectBuildingQuery, refreshRemoteIdentityMapResult, registerIndividualResult, setShouldRefreshRemoteIdentityMapResult, shouldRefreshRemoteIdentityMapResult
clonedQueryExecutionComplete, getFirstResult, getMaxRows, getQueryId, isReadQuery, setFirstResult, setMaxRows, setQueryId
addArgument, addArgument, addArgument, addArgumentByTypeName, addArgumentValue, addArgumentValues, addCall, addStatement, bindAllParameters, buildSelectionCriteria, cacheStatement, cascadeAllParts, cascadeByMapping, cascadeOnlyDependentParts, cascadePrivateParts, deploymentSetShouldMaintainCache, deploymentShouldMaintainCache, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, getAccessor, getArguments, getArgumentTypeNames, getArgumentTypes, getArgumentValues, getCall, getCascadePolicy, getDatasourceCall, getDatasourceCalls, getDescriptor, getEJBQLString, getFlushOnExecute, getName, getProperties, getProperty, getQueryMechanism, getSelectionCriteria, getSession, getSessionName, getShouldBindAllParameters, getSQLStatement, getSQLString, getSQLStrings, getTranslatedSQLString, getTranslatedSQLStrings, getTranslationRow, hasAccessor, hasProperties, hasQueryMechanism, hasSessionName, ignoreBindAllParameters, ignoreCacheStatement, isCallQuery, isCascadeOfAggregateDelete, isDataModifyQuery, isDataReadQuery, isDeleteAllQuery, isDeleteObjectQuery, isExpressionQuery, isInsertObjectQuery, isModifyAllQuery, isModifyQuery, isObjectLevelModifyQuery, isPrepared, isReadAllQuery, isReportQuery, isSQLCallQuery, isUpdateAllQuery, isUpdateObjectQuery, isUserDefined, isWriteObjectQuery, maintainCache, prepareCall, prepareForRemoteExecution, removeProperty, rowFromArguments, setAccessor, setArguments, setArgumentTypeNames, setArgumentTypes, setArgumentValues, setCall, setCascadePolicy, setDatasourceCall, setFlushOnExecute, setIsPrepared, setIsUserDefined, setName, setProperties, setProperty, setQueryMechanism, setSession, setSessionName, setShouldBindAllParameters, setShouldBindAllParameters, setShouldCacheStatement, setShouldMaintainCache, setShouldPrepare, setShouldUseWrapperPolicy, setSQLStatement, setSQLString, setTranslationRow, shouldBindAllParameters, shouldCacheStatement, shouldCascadeAllParts, shouldCascadeByMapping, shouldCascadeOnlyDependentParts, shouldCascadeParts, shouldCascadePrivateParts, shouldCloneCall, shouldIgnoreBindAllParameters, shouldIgnoreCacheStatement, shouldMaintainCache, shouldPrepare, shouldUseWrapperPolicy
protected transient Object selectionObject
protected Vector selectionKey
protected boolean shouldLoadResultIntoSelectionObject
public ReadObjectQuery()
public ReadObjectQuery(Class classToRead)
ReadObjectQuery(Class, Call)
, ReadObjectQuery(Class, Expression)
, ReadObjectQuery(Class, ExpressionBuilder)
, ReadObjectQuery(ExpressionBuilder)
, ReadObjectQuery(Object)
, or #ReadObjectQuery(Object, QueryByExamplePolicy)
.public ReadObjectQuery(Class classToRead, Expression selectionCriteria)
public ReadObjectQuery(Class classToRead, ExpressionBuilder builder)
public ReadObjectQuery(Class classToRead, Call call)
public ReadObjectQuery(Call call)
public ReadObjectQuery(Object objectToRead)
public ReadObjectQuery(ExpressionBuilder builder)
public void checkCacheByExactPrimaryKey()
ObjectLevelReadQuery.setCacheUsage(int)
public void checkCacheByPrimaryKey()
ObjectLevelReadQuery.setCacheUsage(int)
public void checkCacheThenDatabase()
ObjectLevelReadQuery.setCacheUsage(int)
public void checkDescriptor(AbstractSession session) throws QueryException
checkDescriptor
in class ObjectLevelReadQuery
QueryException
protected Object checkEarlyReturnImpl(AbstractSession session, AbstractRecord translationRow)
checkEarlyReturnImpl
in class ObjectLevelReadQuery
protected DatabaseQuery checkForCustomQuery(AbstractSession session, AbstractRecord translationRow)
checkForCustomQuery
in class DatabaseQuery
protected Object conformResult(Object result, UnitOfWorkImpl unitOfWork, AbstractRecord databaseRow, boolean buildDirectlyFromRows)
public void dontLoadResultIntoSelectionObject()
Note: This forces the selection object into the cache a replaces any existing object that may already be there, this is a strict violation of object identity and other objects can still be refering to the old object.
protected Object executeObjectLevelReadQuery() throws DatabaseException
executeObjectLevelReadQuery
in class ObjectLevelReadQuery
DatabaseException
- - an error has occurred on the databasepublic Vector getSelectionKey()
public Object getSelectionObject()
public boolean isReadObjectQuery()
isReadObjectQuery
in class DatabaseQuery
public void loadResultIntoSelectionObject()
Note: This forces the selection object into the cache a replaces any existing object that may already be there, this is a strict violation of object identity and other objects can still be refering to the old object.
protected void prepare() throws QueryException
prepare
in class ObjectLevelReadQuery
QueryException
protected void prepareCustomQuery(DatabaseQuery customQuery)
prepareCustomQuery
in class DatabaseQuery
public void prepareForExecution() throws QueryException
prepareForExecution
in class DatabaseQuery
QueryException
public Object registerResultInUnitOfWork(Object result, UnitOfWorkImpl unitOfWork, AbstractRecord arguments, boolean buildDirectlyFromRows)
Involves registering the query result individually and in totality, and hence refreshing / conforming is done here.
registerResultInUnitOfWork
in class ObjectLevelReadQuery
result
- may be collection (read all) or an object (read one),
or even a cursor. If in transaction the shared cache will
be bypassed, meaning the result may not be originals from the parent
but raw database rows.unitOfWork
- the unitOfWork the result is being registered in.arguments
- the original arguments/parameters passed to the query
execution. Used by conformingbuildDirectlyFromRows
- If in transaction must construct
a registered result from raw database rows.public void setSelectionKey(Vector selectionKey)
public void setSelectionObject(Object selectionObject)
public void setShouldLoadResultIntoSelectionObject(boolean shouldLoadResultIntoSelectionObject)
Note: This forces the selection object into the cache a replaces any existing object that may already be there, this is a strict violation of object identity and other objects can still be refering to the old object.
public void setSingletonSelectionKey(Object selectionKey)
public boolean shouldCheckCache()
public boolean shouldCheckCacheByExactPrimaryKey()
public boolean shouldCheckCacheByPrimaryKey()
public boolean shouldCheckCacheThenDatabase()
public boolean shouldLoadResultIntoSelectionObject()
protected boolean hasNonDefaultFetchGroup()
Copyright © 2023. All rights reserved.