public class DoesExistQuery extends DatabaseQuery
Purpose: This should only be used by the descriptor, this should not be executed directly. Used to determine if an object resides on the database. DoesExistQuery is normally used to determine whether to make an update or insert statement when writing an object.
Responsibilities: Verify the existence of an object. Used only by a write object query.
DatabaseQuery.ParameterType
Modifier and Type | Field and Description |
---|---|
static int |
AssumeExistence |
static int |
AssumeNonExistence |
static int |
CheckCache |
boolean |
checkCacheFirst
Flag to determine if the cache should be check first in addition to another option.
|
static int |
CheckDatabase |
protected boolean |
checkDatabaseIfInvalid
Flag to determine cache invalidation policy support.
|
protected int |
existencePolicy
Flag to determine existence check policy.
|
protected java.lang.Object |
object |
protected java.lang.Object |
primaryKey
Query that is performing the does exist check.
|
accessors, allowNativeSQLQuery, argumentFields, argumentParameterTypes, arguments, argumentTypeNames, argumentTypes, argumentValues, BATCH_FETCH_PROPERTY, CascadeAggregateDelete, CascadeAllParts, CascadeByMapping, CascadeDependentParts, cascadePolicy, CascadePrivateParts, descriptor, descriptors, doNotRedirect, executionSession, flushOnExecute, hintString, isCustomQueryUsed, isExecutionClone, isNativeConnectionRequired, isPrepared, isUserDefined, isUserDefinedSQLCall, monitorName, name, NoCascading, nullableArguments, parameterDelimiter, partitioningPolicy, properties, queryMechanism, queryTimeout, queryTimeoutUnit, redirector, session, sessionName, shouldBindAllParameters, shouldCacheStatement, shouldCloneCall, shouldMaintainCache, shouldPrepare, shouldRetrieveBypassCache, shouldStoreBypassCache, shouldUseWrapperPolicy, shouldValidateUpdateCallCacheUse, sourceMapping, translationRow
Constructor and Description |
---|
DoesExistQuery()
PUBLIC:
Initialize the state of the query .
|
DoesExistQuery(Call call)
PUBLIC:
Create a query to check if the object exists.
|
DoesExistQuery(java.lang.Object object)
PUBLIC:
Create a query to check if the object exists.
|
Modifier and Type | Method and Description |
---|---|
void |
assumeExistenceForDoesExist()
PUBLIC:
Assume that if the objects primary key does not include null then it must exist.
|
void |
assumeNonExistenceForDoesExist()
PUBLIC:
Assume that the object does not exist.
|
void |
checkCacheForDoesExist()
PUBLIC:
Assume that if the objects primary key does not include null
and it is in the cache, then is must exist.
|
void |
checkDatabaseForDoesExist()
PUBLIC:
Perform does exist check on the database through selecting the primary key.
|
void |
checkDescriptor(java.lang.Object object,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Ensure that the descriptor has been set.
|
java.lang.Object |
checkEarlyReturn(org.eclipse.persistence.internal.sessions.AbstractSession session,
org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
INTERNAL:
Check if existence can be determined without going to the database.
|
java.lang.Object |
checkEarlyReturn(java.lang.Object object,
java.lang.Object primaryKey,
org.eclipse.persistence.internal.sessions.AbstractSession session,
org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
INTERNAL:
Check if existence can be determined without going to the database.
|
java.lang.Object |
executeDatabaseQuery()
INTERNAL:
Return if the object exists on the database.
|
boolean |
getCheckCacheFirst()
INTERNAL:
|
boolean |
getCheckDatabaseIfInvalid()
INTERNAL:
|
protected org.eclipse.persistence.internal.helper.DatabaseField |
getDoesExistField()
INTERNAL:
Return the write lock field or the first primary key field if not using locking.
|
int |
getExistencePolicy()
INTERNAL:
Return the existence policy for this existence Query
|
java.lang.Object |
getObject()
PUBLIC:
Return the object.
|
java.lang.Object |
getPrimaryKey()
INTERNAL:
Return the primaryKey.
|
java.lang.Class |
getReferenceClass()
Return the domain class associated with this query.
|
java.lang.String |
getReferenceClassName()
INTERNAL:
Return the name of the reference class for this query
Note: Although the API is designed to avoid requirement of classes being on the classpath,
this is not a user defined query type, so it is ok to access the class.
|
protected void |
prepare()
INTERNAL:
Prepare the receiver for execution in a session.
|
void |
prepareForExecution()
INTERNAL:
Prepare the receiver for execution in a session.
|
void |
setCheckCacheFirst(boolean checkCacheFirst)
INTERNAL:
Sets checkCacheFirst flag.
|
void |
setCheckDatabaseIfInvalid(boolean checkCacheFirst)
INTERNAL:
Sets checkDatabaseIfInvalid flag.
|
void |
setExistencePolicy(int existencePolicy)
INTERNAL:
Set if the existence policy, this must be set to one of the constants.
|
void |
setObject(java.lang.Object object)
PUBLIC:
Set the object.
|
void |
setPrimaryKey(java.lang.Object primaryKey)
INTERNAL:
Set the primaryKey.
|
boolean |
shouldAssumeExistenceForDoesExist()
PUBLIC:
Returns true if the does exist check should be based only
on whether the primary key of the object is set
|
boolean |
shouldAssumeNonExistenceForDoesExist()
PUBLIC:
Returns true if the does exist check should assume non existence.
|
boolean |
shouldCheckCacheForDoesExist()
PUBLIC:
Returns true if the does exist check should be based only
on a cache check.
|
boolean |
shouldCheckDatabaseForDoesExist()
PUBLIC:
Returns true if the does exist check should query the database.
|
addArgument, addArgument, addArgument, addArgument, addArgument, addArgument, addArgumentByTypeName, addArgumentValue, addArgumentValues, addCall, addStatement, bindAllParameters, buildArgumentFields, buildSelectionCriteria, cacheStatement, cascadeAllParts, cascadeByMapping, cascadeOnlyDependentParts, cascadePrivateParts, checkDescriptor, checkForCustomQuery, checkPrepare, checkPrepare, clone, clonedQueryExecutionComplete, convertClassNamesToClasses, copyFromQuery, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, execute, executeInUnitOfWork, extractRemoteResult, getAccessor, getAccessors, getArgumentParameterTypes, getArguments, getArgumentTypeNames, getArgumentTypes, getArgumentValues, getBatchObjects, getCall, getCascadePolicy, getDatasourceCall, getDatasourceCalls, getDefaultRedirector, getDescriptor, getDescriptors, getDomainClassNounName, getDoNotRedirect, getEJBQLString, getExecutionSession, getFlushOnExecute, getHintString, getJPQLString, getMonitorName, getName, getNullableArguments, getParameterDelimiter, getParameterDelimiterChar, getPartitioningPolicy, getProperties, getProperty, getQueryMechanism, getQueryNounName, getQueryTimeout, getQueryTimeoutUnit, getRedirector, getRedirectorForQuery, getSelectionCriteria, getSensorName, getSession, getSessionName, getShouldBindAllParameters, getSourceMapping, getSQLStatement, getSQLString, getSQLStrings, getTranslatedSQLString, getTranslatedSQLStrings, getTranslationRow, hasAccessor, hasArguments, hasNullableArguments, hasProperties, hasQueryMechanism, hasSessionName, ignoreBindAllParameters, ignoreCacheStatement, isCallQuery, isCascadeOfAggregateDelete, isCustomQueryUsed, isCustomSelectionQuery, isDataModifyQuery, isDataReadQuery, isDefaultPropertiesQuery, isDeleteAllQuery, isDeleteObjectQuery, isDirectReadQuery, isExecutionClone, isExpressionQuery, isInsertObjectQuery, isJPQLCallQuery, isModifyAllQuery, isModifyQuery, isNativeConnectionRequired, isObjectBuildingQuery, isObjectLevelModifyQuery, isObjectLevelReadQuery, isPrepared, isReadAllQuery, isReadObjectQuery, isReadQuery, isReportQuery, isResultSetMappingQuery, isSQLCallQuery, isUpdateAllQuery, isUpdateObjectQuery, isUserDefined, isUserDefinedSQLCall, isValueReadQuery, isWriteObjectQuery, maintainCache, prepareCall, prepareCustomQuery, prepareForRemoteExecution, prepareFromQuery, prepareInternal, redirectQuery, remoteExecute, remoteExecute, removeProperty, replaceValueHoldersIn, resetMonitorName, retrieveBypassCache, rowFromArguments, setAccessor, setAccessors, setAllowNativeSQLQuery, setArguments, setArgumentTypeNames, setArgumentTypes, setArgumentValues, setBatchObjects, setCall, setCascadePolicy, setDatasourceCall, setDescriptor, setDoNotRedirect, setEJBQLString, setExecutionSession, setFlushOnExecute, setHintString, setIsCustomQueryUsed, setIsExecutionClone, setIsNativeConnectionRequired, setIsPrepared, setIsUserDefined, setIsUserDefinedSQLCall, setJPQLString, setName, setNullableArguments, setParameterDelimiter, setPartitioningPolicy, setProperties, setProperty, setQueryMechanism, setQueryTimeout, setQueryTimeoutUnit, setRedirector, setSelectionCriteria, setSession, setSessionName, setShouldBindAllParameters, setShouldBindAllParameters, setShouldCacheStatement, setShouldMaintainCache, setShouldPrepare, setShouldRetrieveBypassCache, setShouldStoreBypassCache, setShouldUseWrapperPolicy, setShouldValidateUpdateCallCacheUse, setSourceMapping, setSQLStatement, setSQLString, setTranslationRow, shouldAllowNativeSQLQuery, shouldBindAllParameters, shouldCacheStatement, shouldCascadeAllParts, shouldCascadeByMapping, shouldCascadeOnlyDependentParts, shouldCascadeParts, shouldCascadePrivateParts, shouldCloneCall, shouldIgnoreBindAllParameters, shouldIgnoreCacheStatement, shouldMaintainCache, shouldPrepare, shouldPrepare, shouldRetrieveBypassCache, shouldStoreBypassCache, shouldUseWrapperPolicy, shouldValidateUpdateCallCacheUse, storeBypassCache, toString
public static final int AssumeNonExistence
public static final int AssumeExistence
public static final int CheckCache
public static final int CheckDatabase
protected java.lang.Object primaryKey
protected java.lang.Object object
protected int existencePolicy
protected boolean checkDatabaseIfInvalid
public boolean checkCacheFirst
public DoesExistQuery()
public DoesExistQuery(java.lang.Object object)
public DoesExistQuery(Call call)
public void assumeExistenceForDoesExist()
public void assumeNonExistenceForDoesExist()
public void checkCacheForDoesExist()
public void checkDatabaseForDoesExist()
public java.lang.Object checkEarlyReturn(java.lang.Object object, java.lang.Object primaryKey, org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
public java.lang.Object checkEarlyReturn(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
checkEarlyReturn
in class DatabaseQuery
public java.lang.Object executeDatabaseQuery() throws DatabaseException
executeDatabaseQuery
in class DatabaseQuery
DatabaseException
- - an error has occurred on the database.protected org.eclipse.persistence.internal.helper.DatabaseField getDoesExistField()
public int getExistencePolicy()
public java.lang.Object getObject()
public java.lang.Object getPrimaryKey()
public java.lang.Class getReferenceClass()
getReferenceClass
in class DatabaseQuery
public java.lang.String getReferenceClassName()
getReferenceClassName
in class DatabaseQuery
protected void prepare() throws QueryException
prepare
in class DatabaseQuery
QueryException
public void checkDescriptor(java.lang.Object object, org.eclipse.persistence.internal.sessions.AbstractSession session) throws QueryException
QueryException
public void prepareForExecution() throws QueryException
prepareForExecution
in class DatabaseQuery
QueryException
public void setExistencePolicy(int existencePolicy)
public void setObject(java.lang.Object object)
public void setPrimaryKey(java.lang.Object primaryKey)
public boolean shouldAssumeExistenceForDoesExist()
public boolean shouldAssumeNonExistenceForDoesExist()
public boolean shouldCheckCacheForDoesExist()
public boolean shouldCheckDatabaseForDoesExist()
public void setCheckCacheFirst(boolean checkCacheFirst)
checkCacheFirst
- public boolean getCheckCacheFirst()
public void setCheckDatabaseIfInvalid(boolean checkCacheFirst)
checkCacheFirst
- public boolean getCheckDatabaseIfInvalid()