public abstract class ObjectBuildingQuery extends ReadQuery
Purpose: Abstract class for all read queries that build objects and potentially manipulate the TopLink cache.
Description: Contains common behavior for all read queries building objects.
Modifier and Type | Field and Description |
---|---|
static short |
DEFAULT_LOCK_MODE |
protected long |
executionTime
Used to set the read time on objects that use this query.
|
protected boolean |
isPrePrepared |
static short |
LOCK |
static short |
LOCK_NOWAIT |
static String |
LOCK_RESULT_PROPERTY
INTERNAL: This is the key for accessing unregistered and locked result in the query's properties.
|
protected ForUpdateClause |
lockingClause
Used for pessimistic locking.
|
static short |
NO_LOCK |
protected Class |
referenceClass
The class of the target objects to be read from the database.
|
protected String |
referenceClassName |
protected boolean |
shouldProcessResultsInUnitOfWork
CMP only.
|
protected boolean |
shouldRefreshIdentityMapResult
Allows for the resulting objects to be refresh with the data from the database.
|
protected boolean |
shouldRefreshRemoteIdentityMapResult |
protected boolean |
shouldRegisterResultsInUnitOfWork
INTERNAL: for bug 2612601 allow ability not to register results in UOW.
|
protected boolean |
shouldUseExclusiveConnection
Added for Exclusive Connection (VPD) support see accessor for information
|
protected boolean |
wasDefaultLockMode
PERF: Store if the query originally used the default lock mode.
|
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 |
---|
ObjectBuildingQuery()
INTERNAL:
Initialize the state of the query
|
Modifier and Type | Method and Description |
---|---|
void |
convertClassNamesToClasses(ClassLoader classLoader)
INTERNAL:
Convert all the class-name-based settings in this query to actual class-based
settings.
|
void |
dontRefreshIdentityMapResult()
PUBLIC:
When unset means perform read normally and dont do refresh.
|
void |
dontRefreshRemoteIdentityMapResult()
PUBLIC:
When unset means perform read normally and dont do refresh.
|
List |
getDataResults()
INTERNAL:
Return all of the rows fetched by the query, used for 1-m joining.
|
long |
getExecutionTime()
INTERNAL:
Return the time this query actually went to the database
|
FetchGroup |
getFetchGroup()
Return the fetch group set in the query.
|
short |
getLockMode()
PUBLIC:
Return the current locking mode.
|
Class |
getReferenceClass()
PUBLIC:
Return the reference class of the query.
|
String |
getReferenceClassName()
INTERNAL:
Return the reference class of the query.
|
boolean |
hasPartialAttributeExpressions()
INTERNAL:
Return if partial attributes.
|
boolean |
isAttributeJoined(ClassDescriptor mappingDescriptor,
String attributeName)
INTERNAL:
Return if the attribute is specified for joining.
|
boolean |
isClonePessimisticLocked(Object clone,
UnitOfWorkImpl uow)
INTERNAL:
Helper method that checks if clone has been locked with uow.
|
boolean |
isDefaultLock()
INTERNAL: Helper method to determine the default mode.
|
boolean |
isLockQuery()
PUBLIC:
Answers if the query lock mode is known to be LOCK or LOCK_NOWAIT.
|
boolean |
isObjectBuildingQuery()
PUBLIC:
Return if this is an object building query.
|
protected boolean |
isRegisteringResults()
INTERNAL:
Answers if we are executing through a UnitOfWork and registering results.
|
void |
recordCloneForPessimisticLocking(Object clone,
UnitOfWorkImpl uow)
INTERNAL:
Helper method that records clone with uow if query is pessimistic locking.
|
void |
refreshIdentityMapResult()
PUBLIC:
Refresh the attributes of the object(s) resulting from the query.
|
void |
refreshRemoteIdentityMapResult()
PUBLIC:
Refresh the attributes of the object(s) resulting from the query.
|
Object |
registerIndividualResult(Object result,
UnitOfWorkImpl unitOfWork,
boolean buildDirectlyFromRows,
JoinedAttributeManager joinManager)
INTERNAL:
Constructs the final (registered) object for every individual object
queried via a UnitOfWork.
|
void |
setExecutionTime(long executionTime)
INTERNAL:
Set the the time this query went to the database.
|
void |
setLockMode(short lockMode)
PUBLIC:
Sets whether this is a pessimistically locking query.
|
void |
setReferenceClass(Class aClass)
REQUIRED:
Set the reference class for the query.
|
void |
setReferenceClassName(String aClass)
INTERNAL:
Set the reference class for the query.
|
void |
setShouldProcessResultsInUnitOfWork(boolean processResultsInUnitOfWork)
ADVANCED:
Used for CMP only.
|
void |
setShouldRefreshIdentityMapResult(boolean shouldRefreshIdentityMapResult)
PUBLIC:
Set if the attributes of the object(s) resulting from the query should be refreshed.
|
void |
setShouldRefreshRemoteIdentityMapResult(boolean shouldRefreshIdentityMapResult)
PUBLIC:
Set if the attributes of the object(s) resulting from the query should be refreshed.
|
void |
setShouldRegisterResultsInUnitOfWork(boolean shouldRegisterResultsInUnitOfWork)
INTERNAL:
Set to false to have queries conform to a UnitOfWork without registering
any additional objects not already in that UnitOfWork.
|
protected void |
setWasDefaultLockMode(boolean wasDefaultLockMode)
INTERNAL:
Set if this query originally used the default lock mode.
|
boolean |
shouldProcessResultsInUnitOfWork()
ADVANCED:
Used for CMP only.
|
boolean |
shouldReadAllMappings()
INTERNAL:
Return if this is a full object query, not partial nor fetch group.
|
boolean |
shouldReadMapping(DatabaseMapping mapping)
INTERNAL:
Check if the mapping is part of the partial attributes.
|
boolean |
shouldRefreshIdentityMapResult()
PUBLIC:
Set to a boolean.
|
boolean |
shouldRefreshRemoteIdentityMapResult()
PUBLIC:
Set to a boolean.
|
boolean |
shouldRegisterResultsInUnitOfWork()
INTERNAL:
Allows one to do conforming in a UnitOfWork without registering.
|
String |
toString() |
protected boolean |
wasDefaultLockMode()
INTERNAL:
Return if this query originally used the default lock mode.
|
buildObject, clonedQueryExecutionComplete, getFirstResult, getMaxRows, getQueryId, isReadQuery, setFirstResult, setMaxRows, setQueryId
addArgument, addArgument, addArgument, addArgumentByTypeName, addArgumentValue, addArgumentValues, addCall, addStatement, bindAllParameters, buildSelectionCriteria, cacheStatement, cascadeAllParts, cascadeByMapping, cascadeOnlyDependentParts, cascadePrivateParts, checkDescriptor, checkEarlyReturn, checkForCustomQuery, checkPrepare, clone, deploymentSetShouldMaintainCache, deploymentShouldMaintainCache, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, execute, executeDatabaseQuery, executeInUnitOfWork, 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, isObjectLevelReadQuery, isPrepared, isReadAllQuery, isReadObjectQuery, isReportQuery, isSQLCallQuery, isUpdateAllQuery, isUpdateObjectQuery, isUserDefined, isWriteObjectQuery, maintainCache, prepare, prepareCall, prepareCustomQuery, prepareForExecution, prepareForRemoteExecution, removeProperty, rowFromArguments, setAccessor, setArguments, setArgumentTypeNames, setArgumentTypes, setArgumentValues, setCall, setCascadePolicy, setDatasourceCall, setDescriptor, setEJBQLString, setFlushOnExecute, setIsPrepared, setIsUserDefined, setName, setProperties, setProperty, setQueryMechanism, setSelectionCriteria, 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 Class referenceClass
protected String referenceClassName
protected boolean shouldRefreshIdentityMapResult
protected boolean shouldRefreshRemoteIdentityMapResult
protected boolean shouldRegisterResultsInUnitOfWork
protected boolean shouldProcessResultsInUnitOfWork
protected ForUpdateClause lockingClause
public static final short NO_LOCK
public static final short LOCK
public static final short LOCK_NOWAIT
public static final short DEFAULT_LOCK_MODE
protected boolean isPrePrepared
protected long executionTime
protected boolean shouldUseExclusiveConnection
public static final String LOCK_RESULT_PROPERTY
protected boolean wasDefaultLockMode
public ObjectBuildingQuery()
public void convertClassNamesToClasses(ClassLoader classLoader)
convertClassNamesToClasses
in class DatabaseQuery
classLoader
- protected boolean wasDefaultLockMode()
protected void setWasDefaultLockMode(boolean wasDefaultLockMode)
public void dontRefreshIdentityMapResult()
public void dontRefreshRemoteIdentityMapResult()
public FetchGroup getFetchGroup()
public short getLockMode()
public List getDataResults()
public long getExecutionTime()
public Class getReferenceClass()
getReferenceClass
in class DatabaseQuery
public String getReferenceClassName()
getReferenceClassName
in class DatabaseQuery
public boolean hasPartialAttributeExpressions()
public boolean isLockQuery()
If a single joined attribute was configured for pessimistic locking then this will return true (after first execution) as the SQL contained a FOR UPDATE OF clause.
public boolean isObjectBuildingQuery()
isObjectBuildingQuery
in class DatabaseQuery
protected boolean isRegisteringResults()
public void refreshIdentityMapResult()
public void refreshRemoteIdentityMapResult()
public Object registerIndividualResult(Object result, UnitOfWorkImpl unitOfWork, boolean buildDirectlyFromRows, JoinedAttributeManager joinManager)
Called for every object in a read all, the object in a read object, and every time the next or previous row is retrieved from a cursor.
The (conform) without registering feature is implemented here, and may return an original non UnitOfWork registered result.
Pessimistically locked objects are tracked here.
result
- may be an object (in the identity map of the parent session),
which becomes the original, or a raw database row if in transaction.buildDirectlyFromRows
- true if must construct
a registered result from raw database rows.public void setExecutionTime(long executionTime)
public void setLockMode(short lockMode)
Fine Grained Locking: On execution the reference class and those of all joined attributes will be checked. If any of these have a PessimisticLockingPolicy set on their descriptor, they will be locked in a SELECT ... FOR UPDATE OF ... {NO WAIT}. Issues fewer locks and avoids setting the lock mode on each query.
Example:readAllQuery.setSelectionCriteria(employee.get("address").equal("Ottawa"));
oracle.toplink.essentials.descriptors.PessimisticLockingPolicy
public void setReferenceClass(Class aClass)
public void setReferenceClassName(String aClass)
public void setShouldRefreshIdentityMapResult(boolean shouldRefreshIdentityMapResult)
public void setShouldRefreshRemoteIdentityMapResult(boolean shouldRefreshIdentityMapResult)
public void setShouldRegisterResultsInUnitOfWork(boolean shouldRegisterResultsInUnitOfWork)
shouldRegisterResultsInUnitOfWork
public boolean shouldRegisterResultsInUnitOfWork()
Extreme care should be taken in using this feature, for a user will get back a mix of registered and original (unregistered) objects.
Best used with a WrapperPolicy where invoking on an object will trigger
its registration (CMP). Without a WrapperPolicy registerExistingObject
should be called on any object that you intend to change.
setShouldRegisterResultsInUnitOfWork(boolean)
,
oracle.toplink.essentials.publicinterface.Descriptor#shouldRegisterResulstInUnitOfWork
public boolean shouldReadAllMappings()
public boolean shouldReadMapping(DatabaseMapping mapping)
public boolean shouldRefreshIdentityMapResult()
public boolean shouldRefreshRemoteIdentityMapResult()
public String toString()
toString
in class DatabaseQuery
public void setShouldProcessResultsInUnitOfWork(boolean processResultsInUnitOfWork)
If set to false, then UnitOfWork allocation will be deferred until a business method (including creates/removes) or finder with shouldProcessResultsInUnitOfWork == true is invoked. Any finder executed before such a time, will do so against the underlying ServerSession. Forcing finder execution to always go through a UnitOfWork means the results will be cloned and cached in the UnitOfWork up front. This is desired when the results will be accessed in the same transaction.
Note that finders executed with an unspecified transaction context will never be executed against a UnitOfWork, even if this setting is true. This case may happen with the NotSupported, Never, and Supports attributes.
public boolean shouldProcessResultsInUnitOfWork()
If set to false, then UnitOfWork allocation will be deferred until a business method (including creates/removes) or finder with shouldProcessResultsInUnitOfWork == true is invoked. Any finder executed before such a time, will do so against the underlying ServerSession. Forcing finder execution to always go through a UnitOfWork means the results will be cloned and cached in the UnitOfWork up front. This is desired when the results will be accessed in the same transaction.
Note that finders executed with an unspecified transaction context will never be executed against a UnitOfWork, even if this setting is true. This case may happen with the NotSupported, Never, and Supports attributes.
public boolean isAttributeJoined(ClassDescriptor mappingDescriptor, String attributeName)
public boolean isClonePessimisticLocked(Object clone, UnitOfWorkImpl uow)
public void recordCloneForPessimisticLocking(Object clone, UnitOfWorkImpl uow)
public boolean isDefaultLock()
Copyright © 2021. All rights reserved.