org.eclipse.persistence.queries
Class ObjectLevelReadQuery

java.lang.Object
  extended by org.eclipse.persistence.queries.DatabaseQuery
      extended by org.eclipse.persistence.queries.ReadQuery
          extended by org.eclipse.persistence.queries.ObjectBuildingQuery
              extended by org.eclipse.persistence.queries.ObjectLevelReadQuery
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
ReadAllQuery, ReadObjectQuery

public abstract class ObjectLevelReadQuery
extends ObjectBuildingQuery

Purpose: Abstract class for all read queries using objects.

Description: Contains common behavior for all read queries using objects.

Since:
TOPLink/Java 1.0
Author:
Yvon Lavoie
See Also:
Serialized Form

Field Summary
static int CheckCacheByExactPrimaryKey
           
static int CheckCacheByPrimaryKey
           
static int CheckCacheOnly
           
static int CheckCacheThenDatabase
           
static int ConformResultsInUnitOfWork
           
static int DoNotCheckCache
           
static short DONT_USE_DISTINCT
           
static String NONE
          Names of the possible lock mode types, JPA 2.0 only
static String OPTIMISTIC
           
static String OPTIMISTIC_FORCE_INCREMENT
           
static String PESSIMISTIC_
           
static String PESSIMISTIC_FORCE_INCREMENT
           
static String PESSIMISTIC_READ
           
static String PESSIMISTIC_WRITE
           
static String READ
          Names of the possible lock mode types, JPA 1.0 and 2.0
static short UNCOMPUTED_DISTINCT
           
static short USE_DISTINCT
           
static int UseDescriptorSetting
           
static String WRITE
           
 
Fields inherited from class org.eclipse.persistence.queries.ObjectBuildingQuery
DEFAULT_LOCK_MODE, LOCK, LOCK_NOWAIT, LOCK_RESULT_PROPERTY, NO_LOCK
 
Fields inherited from class org.eclipse.persistence.queries.DatabaseQuery
BATCH_FETCH_PROPERTY, CascadeAggregateDelete, CascadeAllParts, CascadeByMapping, CascadeDependentParts, CascadePrivateParts, NoCascading
 
Constructor Summary
ObjectLevelReadQuery()
          INTERNAL: Initialize the state of the query
 
Method Summary
 void acquireLocks()
          PUBLIC: Set the query to lock, this will also turn refreshCache on.
 void acquireLocksWithoutWaiting()
          PUBLIC: Set the query to lock without waiting (blocking), this will also turn refreshCache on.
 void addAdditionalField(org.eclipse.persistence.internal.helper.DatabaseField field)
          INTERNAL: Additional fields can be added to a query.
 void addAdditionalField(Expression fieldExpression)
          INTERNAL: Additional fields can be added to a query.
 void addBatchReadAttribute(Expression attributeExpression)
          PUBLIC: Specify the foreign-reference mapped attribute to be optimized in this query.
 void addBatchReadAttribute(String attributeName)
          PUBLIC: Specify the foreign-reference mapped attribute to be optimized in this query.
 void addDescendingOrdering(String queryKeyName)
          PUBLIC: Order the query results by the object's attribute or query key name.
 void addJoinedAttribute(Expression attributeExpression)
          PUBLIC: Specify the attribute to be join fetched in this query.
 void addJoinedAttribute(String attributeName)
          PUBLIC: Specify the one-to-one mapped attribute to be join fetched in this query.
 void addJoinSelectionFields(Vector fields, boolean isCustomSQL)
          INTERNAL: The method adds to the passed input vector the fields or expressions corresponding to the joins.
 void addNonFetchJoinedAttribute(Expression attributeExpression)
          PUBLIC: Specify the one-to-one mapped attribute to be optimized in this query.
 void addNonFetchJoinedAttribute(String attributeName)
          PUBLIC: Specify the one-to-one mapped attribute to be optimized in this query.
 void addOrdering(Expression orderingExpression)
          PUBLIC: Add the ordering expression.
 void addPartialAttribute(Expression attributeExpression)
          Deprecated. since EclipseLink 2.1, partial attributes replaced by fetch groups.
 void addPartialAttribute(String attributeName)
          Deprecated. since EclipseLink 2.1, partial attributes replaced by fetch groups.
 Object buildObject(org.eclipse.persistence.internal.sessions.AbstractRecord row)
          INTERNAL: Used to build the object, and register it if in the context of a unit of work.
 void changeDescriptor(org.eclipse.persistence.internal.sessions.AbstractSession theSession)
          INTERNAL: The reference class has been changed, need to reset the descriptor.
 void checkCacheOnly()
          PUBLIC: The cache will checked completely, if the object is not found null will be returned or an error if the query is too complex.
 void checkDescriptor(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Ensure that the descriptor has been set.
 Object checkEarlyReturn(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
          INTERNAL: Check to see if this query already knows the return value without performing any further work.
 void checkPrepare(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow, boolean force)
          INTERNAL: Check to see if this query needs to be prepare and prepare it.
 Object clone()
          INTERNAL: Clone the query
 void computeBatchReadMappingQueries()
          INTERNAL: Used to optimize joining by pre-computing the nested join queries for the mappings.
 void conformResultsInUnitOfWork()
          PUBLIC: The cache will checked completely, if the object is not found the database will be queried, and the database result will be verified with what is in the cache and/or unit of work including new objects.
 void copyFromQuery(DatabaseQuery query)
          INTERNAL: Copy all setting from the query.
 Object deepClone()
          INTERNAL: Clone the query, including its selection criteria.
 void dontAcquireLocks()
          PUBLIC: Set the query not to lock.
 void dontCheckCache()
          PUBLIC: This can be used to explicitly disable the cache hit.
 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.
 void dontUseDistinct()
          ADVANCED: If a distinct has been set the DISTINCT clause will be printed.
 boolean equals(Object object)
          INTERNAL: Return if the query is equal to the other.
 Object execute(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
          INTERNAL: Execute the query.
 Object executeDatabaseQuery()
          INTERNAL: Executes the prepared query on the datastore.
 Object executeInUnitOfWork(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
          INTERNAL: Execute the query in the unit of work.
 void extendPessimisticLockScope()
          INTERNAL: Extends pessimistic lock scope.
 List<Object> getAdditionalFields()
          INTERNAL: Additional fields can be added to a query.
 AsOfClause getAsOfClause()
          ADVANCED: Answers the past time this query is as of.
 BatchFetchPolicy getBatchFetchPolicy()
          Return the batch fetch policy for configuring batch fetching.
 Map<Object,Object> getBatchObjects()
          INTERNAL: Return temporary map of batched objects.
 List<Expression> getBatchReadAttributeExpressions()
          INTERNAL: Return all attributes specified for batch reading.
 int getCacheUsage()
          PUBLIC: Return the cache usage.
 Map<Class,org.eclipse.persistence.internal.databaseaccess.DatabaseCall> getConcreteSubclassCalls()
          INTERNAL: Return the cache of concrete subclass calls.
 short getDistinctState()
          ADVANCED: If a distinct has been set the DISTINCT clause will be printed.
 org.eclipse.persistence.internal.queries.EntityFetchGroup getEntityFetchGroup()
          INTERNAL: Returns EntityFetchGroup that will be applied to objects returned by the query.
 Object getExampleObject()
          PUBLIC: This method returns the current example object.
 FetchGroup getExecutionFetchGroup()
          INTERNAL: Returns FetchGroup that will be applied to the query.
 ExpressionBuilder getExpressionBuilder()
          REQUIRED: Get the expression builder which should be used for this query.
 FetchGroup getFetchGroup()
          Return the fetch group set in the query.
 String getFetchGroupName()
          Return the fetch group name set in the query.
 Set<org.eclipse.persistence.internal.helper.DatabaseField> getFetchGroupNonNestedFieldsSet()
          INTERNAL: Return the set of fields required in the select clause, for fetch group reading.
 Set<org.eclipse.persistence.internal.helper.DatabaseField> getFetchGroupNonNestedFieldsSet(DatabaseMapping nestedMapping)
           
 List<org.eclipse.persistence.internal.helper.DatabaseField> getFetchGroupSelectionFields()
          INTERNAL: Return the fields required in the select clause, for fetch group reading.
 InMemoryQueryIndirectionPolicy getInMemoryQueryIndirectionPolicy()
          PUBLIC: Returns the InMemoryQueryIndirectionPolicy for this query
 int getInMemoryQueryIndirectionPolicyState()
          PUBLIC: Returns the InMemoryQueryIndirectionPolicy for this query
 List getJoinedAttributeExpressions()
          INTERNAL: Convenience method for project mapping.
 org.eclipse.persistence.internal.queries.JoinedAttributeManager getJoinedAttributeManager()
          INTERNAL: Return join manager responsible for managing all aspects of joining for the query.
 ClassDescriptor getLeafDescriptorFor(Expression expression, ClassDescriptor rootDescriptor)
          INTERNAL: Lookup the descriptor for this item by traversing its expression recursively.
 DatabaseMapping getLeafMappingFor(Expression expression, ClassDescriptor rootDescriptor)
          INTERNAL: Lookup the mapping for this item by traversing its expression recursively.
 LoadGroup getLoadGroup()
          Return the load group set in the query.
 org.eclipse.persistence.internal.expressions.ForUpdateClause getLockingClause()
          INTERNAL: It is not exactly as simple as a query being either locking or not.
 short getLockMode()
          PUBLIC: Return the current locking mode.
 List<Expression> getNonFetchJoinAttributeExpressions()
          INTERNAL: Return the attributes that must be joined, but not fetched, that is, do not trigger the value holder.
 List<Expression> getOrderByExpressions()
          INTERNAL: Return the order expressions for the query.
 List<Expression> getPartialAttributeExpressions()
          INTERNAL: Return the partial attributes to select.
 Vector getPartialAttributeSelectionFields(boolean isCustomSQL)
          INTERNAL: Return the fields required in the select clause, for patial attribute reading.
 QueryByExamplePolicy getQueryByExamplePolicy()
          PUBLIC: When using Query By Example, an instance of QueryByExamplePolicy is used to customize the query.
 Class getReferenceClass()
          PUBLIC: Return the reference class of the query.
 String getReferenceClassName()
          INTERNAL: Return the reference class of the query.
 Vector getSelectionFields()
          INTERNAL: Return the fields selected by the query.
 Integer getWaitTimeout()
          PUBLIC: Return the WAIT timeout value of pessimistic locking query.
 boolean hasAdditionalFields()
          INTERNAL: Return if additional field.
 boolean hasAsOfClause()
          PUBLIC: Answers if the domain objects are to be read as of a past time.
 boolean hasBatchReadAttributes()
          INTERNAL: Return true is this query has batching
 boolean hasDefaultBuilder()
          INTERNAL: Checks to see if a builder has been set on the query.
 boolean hasExecutionFetchGroup()
          INTERNAL: Indicates whether a FetchGroup will be applied to the query.
 boolean hasFetchGroup()
          Return if a fetch group is set in the query.
 int hashCode()
          INTERNAL: Compute a consistent hash-code for the expression.
 boolean hasJoining()
          INTERNAL: Return if any attributes are joined.
 boolean hasNonFetchJoinedAttributeExpressions()
          INTERNAL: Return the attributes that must be joined.
 boolean hasOrderByExpressions()
          INTERNAL: The order bys are lazy initialized to conserve space.
 boolean hasPartialAttributeExpressions()
          INTERNAL: Return if partial attributes.
 boolean isAttributeBatchRead(ClassDescriptor mappingDescriptor, String attributeName)
          INTERNAL: Return if the attribute is specified for batch reading.
 boolean isClonePessimisticLocked(Object clone, org.eclipse.persistence.internal.sessions.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 isDefaultPropertiesQuery()
          INTERNAL: Return true if the query uses default properties.
 boolean isDistinctComputed()
          INTERNAL: return true if this query has computed its distinct value already
 boolean isLockQuery()
          PUBLIC: Answers if the query lock mode is known to be LOCK or LOCK_NOWAIT.
 boolean isLockQuery(Session session)
          ADVANCED: Answers if this query will issue any pessimistic locks.
 boolean isObjectLevelReadQuery()
          PUBLIC: Return if this is an object level read query.
 boolean isPartialAttribute(String attributeName)
          INTERNAL: Return if partial attribute.
 boolean isPrimaryKeyQuery()
          INTERNAL: Return if the query is known to be by primary key.
 boolean isReadOnly()
          PUBLIC: Return if the query is read-only.
 boolean isResultSetOptimizedQuery()
          ADVANCED: Return if the query should be optimized to build directly from the result set.
 void prepareFetchGroup()
          INTERNAL: Add mandatory attributes to fetch group, create entityFetchGroup.
 void prepareFromQuery(DatabaseQuery query)
          INTERNAL: Prepare the query from the prepared query.
 DatabaseQuery prepareOutsideUnitOfWork(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: There is a very special case where a query may be a bean-level pessimistic locking query.
 void recordCloneForPessimisticLocking(Object clone, org.eclipse.persistence.internal.sessions.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.
abstract  Object registerResultInUnitOfWork(Object result, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, org.eclipse.persistence.internal.sessions.AbstractRecord arguments, boolean buildDirectlyFromRows)
          INTERNAL: All objects queried via a UnitOfWork get registered here.
 void resetDistinct()
          ADVANCED: If a distinct has been set the DISTINCT clause will be printed.
 void setAdditionalFields(List<Object> additionalFields)
          INTERNAL: Additional fields can be added to a query.
 void setAsOfClause(AsOfClause pastTime)
          ADVANCED: Sets the query to execute as of the past time.
 void setBatchFetchPolicy(BatchFetchPolicy batchFetchPolicy)
          Set the batch fetch policy for configuring batch fetching.
 void setBatchFetchSize(int size)
          PUBLIC: Set the batch fetch size for the query.
 void setBatchFetchType(BatchFetchType type)
          PUBLIC: Set the batch fetch type for the query.
 void setBatchObjects(Map<Object,Object> batchObjects)
          INTERNAL: Set temporary map of batched objects.
 void setBatchReadAttributeExpressions(List<Expression> attributeExpressions)
          INTERNAL: Set all attributes specified for batch reading.
 void setCacheUsage(int cacheUsage)
          PUBLIC: Set the cache usage.
 void setDescriptor(ClassDescriptor descriptor)
          INTERNAL: Set the descriptor for the query.
 void setDistinctState(short distinctState)
          ADVANCED: If a distinct has been set the DISTINCT clause will be printed.
 void setEJBQLString(String ejbqlString)
          PUBLIC: Set the EJBQL string of the query.
 void setExampleObject(Object newExampleObject)
          PUBLIC: Set the example object of the query to be the newExampleObject.
 void setExpressionBuilder(ExpressionBuilder builder)
          INTERNAL Sets the default expression builder for this query.
 void setFetchGroup(FetchGroup newFetchGroup)
          Set a dynamic (use case) fetch group to the query.
 void setFetchGroupName(String groupName)
          Set a descriptor-level pre-defined named fetch group to the query.
 void setInMemoryQueryIndirectionPolicy(InMemoryQueryIndirectionPolicy inMemoryQueryIndirectionPolicy)
          PUBLIC: Set the InMemoryQueryIndirectionPolicy for this query.
 void setInMemoryQueryIndirectionPolicyState(int inMemoryQueryIndirectionPolicy)
          PUBLIC: Set the InMemoryQueryIndirectionPolicy for this query.
 void setIsPrepared(boolean isPrepared)
          INTERNAL: Clear cached flags when un-preparing.
 void setIsReadOnly(boolean isReadOnly)
          PUBLIC: Set the query to be read-only.
 void setIsResultSetOptimizedQuery(boolean isResultSetOptimizedQuery)
          ADVANCED: Set if the query should be optimized to build directly from the result set.
 void setJoinedAttributeExpressions(List expressions)
          INTERNAL: Convenience method for project mapping.
 void setJoinedAttributeManager(org.eclipse.persistence.internal.queries.JoinedAttributeManager joinedAttributeManager)
          INTERNAL: Set join manager responsible for managing all aspects of joining for the query.
 void setLoadGroup(LoadGroup loadGroup)
          Set a load group to the query.
 void setLockingClause(org.eclipse.persistence.internal.expressions.ForUpdateClause clause)
          INTERNAL: The locking clause contains a list of expressions representing which objects are to be locked by the query.
 void setLockMode(short lockMode)
          PUBLIC: Sets whether this is a pessimistically locking query.
 boolean setLockModeType(String lockModeType, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Sets a javax.persistence.LockModeType to used with this queries execution.
 void setOrderByExpressions(List<Expression> orderByExpressions)
          INTERNAL: Set the order expressions for the query.
 void setPartialAttributeExpressions(List<Expression> partialAttributeExpressions)
          INTERNAL: Set the partial attributes to select.
 void setQueryByExamplePolicy(QueryByExamplePolicy queryByExamplePolicy)
          PUBLIC: The QueryByExamplePolicy, is a useful to customize the query when Query By Example is used.
 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 setSelectionCriteria(Expression expression)
          PUBLIC: To any user of this object.
 void setShouldExtendPessimisticLockScope(boolean isExtended)
          INTERNAL: Indicates whether pessimistic lock should also be applied to relation tables (ManyToMany and OneToOne mappings), reference tables (DirectCollection and AggregateCollection mapping).
 void setShouldFilterDuplicates(boolean shouldFilterDuplicates)
          PUBLIC: Set if duplicate rows should be filter when using 1-m joining.
 void setShouldIncludeData(boolean shouldIncludeData)
          INTERNAL: Set if the rows for the result of the query should also be returned using a complex query result.
 void setShouldOuterJoinSubclasses(boolean shouldOuterJoinSubclasses)
          PUBLIC: Set if an outer join should be used to read subclasses.
 void setShouldUseDefaultFetchGroup(boolean shouldUseDefaultFetchGroup)
          Set false if the user does not want to use the default fetch group defined in the descriptor level.
 void setWaitTimeout(Integer waitTimeout)
          PUBLIC: Sets that this a pessimistic wait locking query.
 boolean shouldCheckCache()
          PUBLIC: Return if the cache should be checked.
 boolean shouldCheckCacheOnly()
          PUBLIC: Return if cache should be checked.
 boolean shouldCheckDescriptorForCacheUsage()
          PUBLIC: Return whether the descriptor's disableCacheHits setting should be checked prior to querying the cache.
 boolean shouldConformResultsInUnitOfWork()
          PUBLIC: Should the results will be checked against the changes within the unit of work and object no longer matching or deleted will be remove, matching new objects will also be added..
 boolean shouldDistinctBeUsed()
          INTERNAL: return true if this query should use a distinct
 boolean shouldExtendPessimisticLockScope()
          INTERNAL: Indicates whether pessimistic lock should also be applied to relation tables (ManyToMany and OneToOne mappings), reference tables (DirectCollection and AggregateCollection mapping).
 boolean shouldFilterDuplicates()
          PUBLIC: Return if duplicate rows should be filter when using 1-m joining.
 boolean shouldIncludeData()
          INTERNAL: Return if the rows for the result of the query should also be returned using a complex query result.
 boolean shouldOuterJoinSubclasses()
          PUBLIC: Return if an outer join should be used to read subclasses.
 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 shouldUseDefaultFetchGroup()
          Return false if the query does not use the default fetch group defined in the descriptor level.
 String toString()
           
 void useDistinct()
          ADVANCED: If a distinct has been set the DISTINCT clause will be printed.
 
Methods inherited from class org.eclipse.persistence.queries.ObjectBuildingQuery
convertClassNamesToClasses, getDataResults, getExecutionTime, isAttributeJoined, isObjectBuildingQuery, isRegisteringResults, postRegisterIndividualResult, registerIndividualResult, setExecutionTime, setShouldBuildNullForNullPk, setShouldRefreshIdentityMapResult, setShouldRefreshRemoteIdentityMapResult, setShouldRegisterResultsInUnitOfWork, setShouldUseExclusiveConnection, shouldBuildNullForNullPk, shouldRefreshIdentityMapResult, shouldRefreshRemoteIdentityMapResult, shouldRegisterResultsInUnitOfWork, shouldUseExclusiveConnection
 
Methods inherited from class org.eclipse.persistence.queries.ReadQuery
cacheQueryResults, cacheResult, clearQueryResults, doNotCacheQueryResults, getFetchSize, getFirstResult, getMaxRows, getQueryId, getQueryResultsCachePolicy, getTemporaryCachedQueryResults, isReadQuery, prepareForExecution, remoteExecute, setFetchSize, setFirstResult, setMaxRows, setQueryId, setQueryResultsCachePolicy, setTemporaryCachedQueryResults, shouldCacheQueryResults
 
Methods inherited from class org.eclipse.persistence.queries.DatabaseQuery
addArgument, addArgument, addArgument, addArgumentByTypeName, addArgumentValue, addArgumentValues, addCall, addStatement, bindAllParameters, buildArgumentFields, cacheStatement, cascadeAllParts, cascadeByMapping, cascadeOnlyDependentParts, cascadePrivateParts, checkPrepare, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, extractRemoteResult, getAccessor, getArguments, getArgumentTypeNames, getArgumentTypes, getArgumentValues, getCall, getCascadePolicy, getDatasourceCall, getDatasourceCalls, getDescriptor, getDomainClassNounName, getDoNotRedirect, getEJBQLString, getExecutionSession, getFlushOnExecute, getHintString, getJPQLString, getName, getProperties, getProperty, getQueryMechanism, getQueryNounName, getQueryTimeout, getRedirector, getSelectionCriteria, getSensorName, getSession, getSessionName, getShouldBindAllParameters, getSourceMapping, getSQLStatement, getSQLString, getSQLStrings, getTranslatedSQLString, getTranslatedSQLStrings, getTranslationRow, hasAccessor, hasArguments, hasProperties, hasQueryMechanism, hasSessionName, ignoreBindAllParameters, ignoreCacheStatement, isCallQuery, isCascadeOfAggregateDelete, isCustomQueryUsed, isDataModifyQuery, isDataReadQuery, isDeleteAllQuery, isDeleteObjectQuery, isDirectReadQuery, isExecutionClone, isExpressionQuery, isInsertObjectQuery, isJPQLCallQuery, isModifyAllQuery, isModifyQuery, isNativeConnectionRequired, isObjectLevelModifyQuery, isPrepared, isReadAllQuery, isReadObjectQuery, isReportQuery, isSQLCallQuery, isUpdateAllQuery, isUpdateObjectQuery, isUserDefined, isValueReadQuery, isWriteObjectQuery, maintainCache, prepareCall, redirectQuery, removeProperty, replaceValueHoldersIn, retrieveBypassCache, rowFromArguments, setAccessor, setArguments, setArgumentTypeNames, setArgumentTypes, setArgumentValues, setCall, setCascadePolicy, setDatasourceCall, setDoNotRedirect, setFlushOnExecute, setHintString, setIsExecutionClone, setIsNativeConnectionRequired, setIsUserDefined, setJPQLString, setName, setProperties, setProperty, setQueryTimeout, setRedirector, setSession, setSessionName, setShouldBindAllParameters, setShouldBindAllParameters, setShouldCacheStatement, setShouldMaintainCache, setShouldPrepare, setShouldRetrieveBypassCache, setShouldStoreBypassCache, setShouldUseWrapperPolicy, setSourceMapping, setSQLStatement, setSQLString, setTranslationRow, shouldBindAllParameters, shouldCacheStatement, shouldCascadeAllParts, shouldCascadeByMapping, shouldCascadeOnlyDependentParts, shouldCascadeParts, shouldCascadePrivateParts, shouldCloneCall, shouldIgnoreBindAllParameters, shouldIgnoreCacheStatement, shouldMaintainCache, shouldPrepare, shouldRetrieveBypassCache, shouldStoreBypassCache, shouldUseWrapperPolicy, storeBypassCache
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

READ

public static final String READ
Names of the possible lock mode types, JPA 1.0 and 2.0

See Also:
Constant Field Values

WRITE

public static final String WRITE
See Also:
Constant Field Values

NONE

public static final String NONE
Names of the possible lock mode types, JPA 2.0 only

See Also:
Constant Field Values

PESSIMISTIC_

public static final String PESSIMISTIC_
See Also:
Constant Field Values

PESSIMISTIC_READ

public static final String PESSIMISTIC_READ
See Also:
Constant Field Values

PESSIMISTIC_WRITE

public static final String PESSIMISTIC_WRITE
See Also:
Constant Field Values

PESSIMISTIC_FORCE_INCREMENT

public static final String PESSIMISTIC_FORCE_INCREMENT
See Also:
Constant Field Values

OPTIMISTIC

public static final String OPTIMISTIC
See Also:
Constant Field Values

OPTIMISTIC_FORCE_INCREMENT

public static final String OPTIMISTIC_FORCE_INCREMENT
See Also:
Constant Field Values

UseDescriptorSetting

public static final int UseDescriptorSetting
See Also:
Constant Field Values

DoNotCheckCache

public static final int DoNotCheckCache
See Also:
Constant Field Values

CheckCacheByExactPrimaryKey

public static final int CheckCacheByExactPrimaryKey
See Also:
Constant Field Values

CheckCacheByPrimaryKey

public static final int CheckCacheByPrimaryKey
See Also:
Constant Field Values

CheckCacheThenDatabase

public static final int CheckCacheThenDatabase
See Also:
Constant Field Values

CheckCacheOnly

public static final int CheckCacheOnly
See Also:
Constant Field Values

ConformResultsInUnitOfWork

public static final int ConformResultsInUnitOfWork
See Also:
Constant Field Values

UNCOMPUTED_DISTINCT

public static final short UNCOMPUTED_DISTINCT
See Also:
Constant Field Values

USE_DISTINCT

public static final short USE_DISTINCT
See Also:
Constant Field Values

DONT_USE_DISTINCT

public static final short DONT_USE_DISTINCT
See Also:
Constant Field Values
Constructor Detail

ObjectLevelReadQuery

public ObjectLevelReadQuery()
INTERNAL: Initialize the state of the query

Method Detail

addDescendingOrdering

public void addDescendingOrdering(String queryKeyName)
PUBLIC: Order the query results by the object's attribute or query key name.


addOrdering

public void addOrdering(Expression orderingExpression)
PUBLIC: Add the ordering expression. This allows for ordering across relationships or functions. Example: readAllQuery.addOrdering(expBuilder.get("address").get("city").toUpperCase().descending())


equals

public boolean equals(Object object)
INTERNAL: Return if the query is equal to the other. This is used to allow dynamic expression query SQL to be cached.

Overrides:
equals in class Object

hashCode

public int hashCode()
INTERNAL: Compute a consistent hash-code for the expression. This is used to allow dynamic expression's SQL to be cached.

Overrides:
hashCode in class Object

isReadOnly

public boolean isReadOnly()
PUBLIC: Return if the query is read-only. This allows queries executed against a UnitOfWork to be read-only. This means the query will be executed against the Session, and the resulting objects will not be tracked for changes. The resulting objects are from the Session shared cache, and must not be modified.


setIsReadOnly

public void setIsReadOnly(boolean isReadOnly)
PUBLIC: Set the query to be read-only. This allows queries executed against a UnitOfWork to be read-only. This means the query will be executed against the Session, and the resulting objects will not be tracked for changes. The resulting objects are from the Session shared cache, and must not be modified.


setWaitTimeout

public void setWaitTimeout(Integer waitTimeout)
PUBLIC: Sets that this a pessimistic wait locking query.

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"));

See Also:
PessimisticLockingPolicy

clone

public Object clone()
INTERNAL: Clone the query

Overrides:
clone in class DatabaseQuery

deepClone

public Object deepClone()
INTERNAL: Clone the query, including its selection criteria.

Normally selection criteria are not cloned here as they are cloned later on during prepare.

Overrides:
deepClone in class ObjectBuildingQuery

acquireLocks

public void acquireLocks()
PUBLIC: Set the query to lock, this will also turn refreshCache on.


acquireLocksWithoutWaiting

public void acquireLocksWithoutWaiting()
PUBLIC: Set the query to lock without waiting (blocking), this will also turn refreshCache on.


addAdditionalField

public void addAdditionalField(org.eclipse.persistence.internal.helper.DatabaseField field)
INTERNAL: Additional fields can be added to a query. This is used in m-m batch reading to bring back the key from the join table.


addAdditionalField

public void addAdditionalField(Expression fieldExpression)
INTERNAL: Additional fields can be added to a query. This is used in m-m batch reading to bring back the key from the join table.


addJoinedAttribute

public void addJoinedAttribute(String attributeName)
PUBLIC: Specify the one-to-one mapped attribute to be join fetched in this query. The query will join the object(s) being read with the one-to-one attribute, this allows all of the data required for the object(s) to be read in a single query instead of (n) queries. This should be used when the application knows that it requires the part for all of the objects being read.

Note: This cannot be used for objects where it is possible not to have a part, as these objects will be omitted from the result set, unless an outer join is used through passing and expression using "getAllowingNull". To join fetch collection relationships use the addJoinedAttribute(Expression) using "anyOf" ot "anyOfAllowingNone".

Example: query.addJoinedAttribute("address")

See Also:
addJoinedAttribute(Expression), addBatchReadAttribute(Expression)

addJoinedAttribute

public void addJoinedAttribute(Expression attributeExpression)
PUBLIC: Specify the attribute to be join fetched in this query. The query will join the object(s) being read with the specified attribute, this allows all of the data required for the object(s) to be read in a single query instead of (n) queries. This should be used when the application knows that it requires the part for all of the objects being read.

Note: This cannot be used for objects where it is possible not to have a part, as these objects will be omitted from the result set, unless an outer join is used through passing and expression using "getAllowingNull".

Example: The following will fetch along with Employee(s) "Jones" all projects they participate in along with teamLeaders and their addresses, teamMembers and their phones. query.setSelectionCriteria(query.getExpressionBuilder().get("lastName").equal("Jones")); Expression projects = query.getExpressionBuilder().anyOf("projects"); query.addJoinedAttribute(projects); Expression teamLeader = projects.get("teamLeader"); query.addJoinedAttribute(teamLeader); Expression teamLeaderAddress = teamLeader.getAllowingNull("address"); query.addJoinedAttribute(teamLeaderAddress); Expression teamMembers = projects.anyOf("teamMembers"); query.addJoinedAttribute(teamMembers); Expression teamMembersPhones = teamMembers.anyOfAllowingNone("phoneNumbers"); query.addJoinedAttribute(teamMembersPhones); Note that: the order is essential: an expression should be added before any expression derived from it; the object is built once - it won't be rebuilt if it to be read again as a joined attribute: in the example the query won't get phones for "Jones" - even though they are among teamMembers (for whom phones are read).


addNonFetchJoinedAttribute

public void addNonFetchJoinedAttribute(String attributeName)
PUBLIC: Specify the one-to-one mapped attribute to be optimized in this query. The query will join the object(s) being read with the one-to-one attribute. The difference between this and a joined attribute is that it allows data to be retrieved based on a join, but will not populate the joined attribute. It also allows all of the data required for the object(s) to be read in a single query instead of (n) queries. This should be used when the application knows that it requires the part for all of the objects being read. This can be used only for one-to-one mappings where the target is not the same class as the source, either directly or through inheritance. Also two joins cannot be done to the same class.

Note: This cannot be used for objects where it is possible not to have a part, as these objects will be omitted from the result set, unless an outer join is used through passing and expression using "getAllowingNull".

Example: query.addNonFetchJoinedAttribute("address")

See Also:
addNonFetchJoinedAttribute(Expression)

addNonFetchJoinedAttribute

public void addNonFetchJoinedAttribute(Expression attributeExpression)
PUBLIC: Specify the one-to-one mapped attribute to be optimized in this query. The query will join the object(s) being read with the one-to-one attribute. The difference between this and a joined attribute is that it allows data to be retrieved based on a join, but will not populate the joined attribute. It also allows all of the data required for the object(s) to be read in a single query instead of (n) queries. This should be used when the application knows that it requires the part for all of the objects being read. This can be used only for one-to-one mappings where the target is not the same class as the source, either directly or through inheritance. Also two joins cannot be done to the same class.

Note: This cannot be used for objects where it is possible not to have a part, as these objects will be omitted from the result set, unless an outer join is used through passing and expression using "getAllowingNull".

Example: query.addNonFetchJoinedAttribute(query.getExpressionBuilder().get("teamLeader").get("address"))

See Also:
addNonFetchJoinedAttribute(Expression)

addPartialAttribute

public void addPartialAttribute(String attributeName)
Deprecated. since EclipseLink 2.1, partial attributes replaced by fetch groups.

PUBLIC: Specify that only a subset of the class' attributes be selected in this query.

This allows for the query to be optimized through selecting less data.

Partial objects will be returned from the query, where the unspecified attributes will be left null. The primary key will always be selected to allow re-querying of the whole object.

Note: Because the object is not fully initialized it cannot be cached, and cannot be edited.

Note: You cannot have 2 partial attributes of the same type. You also cannot add a partial attribute which is of the same type as the class being queried.

Example: query.addPartialAttribute("firstName")

See Also:
addPartialAttribute(Expression), Example: FetchGroup fetchGroup = new FetchGroup(); fetchGroup.addAttribute("address.city"); query.setFetchGroup(fetchGroup);

setAsOfClause

public void setAsOfClause(AsOfClause pastTime)
ADVANCED: Sets the query to execute as of the past time. Both the query execution and result will conform to the database as it existed in the past.

Equivalent to query.getSelectionCriteria().asOf(pastTime) called immediately before query execution.

An as of clause at the query level will override any clauses set at the expression level. Useful in cases where the selection criteria is not known in advance, such as for query by example or primary key (selection object), or where you do not need to cache the result (report query).

Ideally an as of clause at the session level is superior as query results can then be cached. You must set setShouldMaintainCache(false)

To query all joined/batched attributes as of the same time set this.cascadeAllParts().

Throws:
QueryException - (at execution time) unless setShouldMaintainCache(false) is set. If some more recent data were in the cache, this would be returned instead, and both the cache and query result would become inconsistent.
Since:
OracleAS TopLink 10g (10.0.3)
See Also:
hasAsOfClause(), Session.acquireHistoricalSession(org.eclipse.persistence.history.AsOfClause), Expression.asOf(org.eclipse.persistence.history.AsOfClause)

addPartialAttribute

public void addPartialAttribute(Expression attributeExpression)
Deprecated. since EclipseLink 2.1, partial attributes replaced by fetch groups.

PUBLIC: Specify that only a subset of the class' attributes be selected in this query.

This allows for the query to be optimized through selecting less data.

Partial objects will be returned from the query, where the unspecified attributes will be left null. The primary key will always be selected to allow re-querying of the whole object.

Note: Because the object is not fully initialized it cannot be cached, and cannot be edited.

Note: You cannot have 2 partial attributes of the same type. You also cannot add a partial attribute which is of the same type as the class being queried.

Example: query.addPartialAttribute(query.getExpressionBuilder().get("address").get("city"))

See Also:
Example: FetchGroup fetchGroup = new FetchGroup(); fetchGroup.addAttribute("address.city"); query.setFetchGroup(fetchGroup);

buildObject

public Object buildObject(org.eclipse.persistence.internal.sessions.AbstractRecord row)
INTERNAL: Used to build the object, and register it if in the context of a unit of work.

Overrides:
buildObject in class ReadQuery

checkCacheOnly

public void checkCacheOnly()
PUBLIC: The cache will checked completely, if the object is not found null will be returned or an error if the query is too complex. Queries can be configured to use the cache at several levels. Other caching option are available.

See Also:
setCacheUsage(int)

checkDescriptor

public void checkDescriptor(org.eclipse.persistence.internal.sessions.AbstractSession session)
                     throws QueryException
INTERNAL: Ensure that the descriptor has been set.

Overrides:
checkDescriptor in class DatabaseQuery
Throws:
QueryException

checkEarlyReturn

public Object checkEarlyReturn(org.eclipse.persistence.internal.sessions.AbstractSession session,
                               org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
INTERNAL: Check to see if this query already knows the return value without performing any further work.

Overrides:
checkEarlyReturn in class DatabaseQuery

checkPrepare

public void checkPrepare(org.eclipse.persistence.internal.sessions.AbstractSession session,
                         org.eclipse.persistence.internal.sessions.AbstractRecord translationRow,
                         boolean force)
INTERNAL: Check to see if this query needs to be prepare and prepare it. The prepare is done on the original query to ensure that the work is not repeated.

Overrides:
checkPrepare in class DatabaseQuery

changeDescriptor

public void changeDescriptor(org.eclipse.persistence.internal.sessions.AbstractSession theSession)
INTERNAL: The reference class has been changed, need to reset the descriptor. Null out the current descriptor and call checkDescriptor Added Feb 27, 2001 JED for EJBQL feature


conformResultsInUnitOfWork

public void conformResultsInUnitOfWork()
PUBLIC: The cache will checked completely, if the object is not found the database will be queried, and the database result will be verified with what is in the cache and/or unit of work including new objects. This can lead to poor performance so it is recommended that only the database be queried in most cases. Queries can be configured to use the cache at several levels. Other caching option are available.

See Also:
setCacheUsage(int)

dontAcquireLocks

public void dontAcquireLocks()
PUBLIC: Set the query not to lock.


dontCheckCache

public void dontCheckCache()
PUBLIC: This can be used to explicitly disable the cache hit. The cache hit may not be desired in some cases, such as stored procedures that accept the primary key but do not query on it.


dontRefreshIdentityMapResult

public void dontRefreshIdentityMapResult()
PUBLIC: When unset means perform read normally and dont do refresh.

Overrides:
dontRefreshIdentityMapResult in class ObjectBuildingQuery

dontRefreshRemoteIdentityMapResult

public void dontRefreshRemoteIdentityMapResult()
PUBLIC: When unset means perform read normally and dont do refresh.

Overrides:
dontRefreshRemoteIdentityMapResult in class ObjectBuildingQuery

dontUseDistinct

public void dontUseDistinct()
ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by EclipseLink for batch reading but may also be used directly for advanced queries or report queries.


prepareOutsideUnitOfWork

public DatabaseQuery prepareOutsideUnitOfWork(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: There is a very special case where a query may be a bean-level pessimistic locking query.

If that is so, only queries executed inside of a UnitOfWork should have a locking clause. In the extremely rare case that we execute a locking query outside of a UnitOfWork, must disable locking so that we do not get a fetch out of sequence error.


execute

public Object execute(org.eclipse.persistence.internal.sessions.AbstractSession session,
                      org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
               throws DatabaseException,
                      OptimisticLockException
INTERNAL: Execute the query. If there are objects in the cache return the results of the cache lookup.

Overrides:
execute in class DatabaseQuery
Parameters:
session - - the session in which the receiver will be executed.
Returns:
An object, the result of executing the query.
Throws:
DatabaseException - - an error has occurred on the database.
OptimisticLockException - - an error has occurred using the optimistic lock feature.

executeDatabaseQuery

public Object executeDatabaseQuery()
                            throws DatabaseException
INTERNAL: Executes the prepared query on the datastore.

Specified by:
executeDatabaseQuery in class DatabaseQuery
Returns:
- the result of executing the query.
Throws:
DatabaseException - - an error has occurred on the database.

executeInUnitOfWork

public Object executeInUnitOfWork(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork,
                                  org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
                           throws DatabaseException,
                                  OptimisticLockException
INTERNAL: Execute the query in the unit of work. This allows any pre-execute checks to be done for unit of work queries.

Overrides:
executeInUnitOfWork in class DatabaseQuery
Parameters:
unitOfWork - - the session in which the receiver will be executed.
translationRow - - the arguments
Returns:
An object, the result of executing the query.
Throws:
DatabaseException - - an error has occurred on the database.
OptimisticLockException - - an error has occurred using the optimistic lock feature.

getAdditionalFields

public List<Object> getAdditionalFields()
INTERNAL: Additional fields can be added to a query. This is used in m-m batch reading to bring back the key from the join table.


getAsOfClause

public AsOfClause getAsOfClause()
ADVANCED: Answers the past time this query is as of.

Returns:
An immutable object representation of the past time. null if no clause set, AsOfClause.NO_CLAUSE if clause explicitly set to null.
See Also:
AsOfClause, setAsOfClause(org.eclipse.persistence.history.AsOfClause), hasAsOfClause()

getCacheUsage

public int getCacheUsage()
PUBLIC: Return the cache usage. By default only primary key read object queries will first check the cache before accessing the database. Any query can be configure to query against the cache completely, by key or ignore the cache check.

Valid values are:


getDistinctState

public short getDistinctState()
ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by EclipseLink for batch reading but may also be used directly for advanced queries or report queries.


getExampleObject

public Object getExampleObject()
PUBLIC: This method returns the current example object. The "example" object is an actual domain object, provided by the client, from which an expression is generated. This expression is used for a query of all objects from the same class, that match the attribute values of the "example" object.


getExpressionBuilder

public ExpressionBuilder getExpressionBuilder()
REQUIRED: Get the expression builder which should be used for this query. This expression builder should be used to build all expressions used by this query.


setExpressionBuilder

public void setExpressionBuilder(ExpressionBuilder builder)
INTERNAL Sets the default expression builder for this query.


getInMemoryQueryIndirectionPolicyState

public int getInMemoryQueryIndirectionPolicyState()
PUBLIC: Returns the InMemoryQueryIndirectionPolicy for this query


getInMemoryQueryIndirectionPolicy

public InMemoryQueryIndirectionPolicy getInMemoryQueryIndirectionPolicy()
PUBLIC: Returns the InMemoryQueryIndirectionPolicy for this query


getJoinedAttributeManager

public org.eclipse.persistence.internal.queries.JoinedAttributeManager getJoinedAttributeManager()
INTERNAL: Return join manager responsible for managing all aspects of joining for the query. Queries without joining should not have a joinedAttributeManager.


setJoinedAttributeManager

public void setJoinedAttributeManager(org.eclipse.persistence.internal.queries.JoinedAttributeManager joinedAttributeManager)
INTERNAL: Set join manager responsible for managing all aspects of joining for the query.


hasJoining

public boolean hasJoining()
INTERNAL: Return if any attributes are joined. To avoid the initialization of the JoinedAttributeManager this should be first checked before accessing.


getJoinedAttributeExpressions

public List getJoinedAttributeExpressions()
INTERNAL: Convenience method for project mapping.


setJoinedAttributeExpressions

public void setJoinedAttributeExpressions(List expressions)
INTERNAL: Convenience method for project mapping.


getOrderByExpressions

public List<Expression> getOrderByExpressions()
INTERNAL: Return the order expressions for the query.


setOrderByExpressions

public void setOrderByExpressions(List<Expression> orderByExpressions)
INTERNAL: Set the order expressions for the query.


hasOrderByExpressions

public boolean hasOrderByExpressions()
INTERNAL: The order bys are lazy initialized to conserve space.


shouldFilterDuplicates

public boolean shouldFilterDuplicates()
PUBLIC: Return if duplicate rows should be filter when using 1-m joining.


setShouldFilterDuplicates

public void setShouldFilterDuplicates(boolean shouldFilterDuplicates)
PUBLIC: Set if duplicate rows should be filter when using 1-m joining.


getLeafMappingFor

public DatabaseMapping getLeafMappingFor(Expression expression,
                                         ClassDescriptor rootDescriptor)
                                  throws QueryException
INTERNAL: Lookup the mapping for this item by traversing its expression recursively. If an aggregate of foreign mapping is found it is traversed.

Throws:
QueryException

getLeafDescriptorFor

public ClassDescriptor getLeafDescriptorFor(Expression expression,
                                            ClassDescriptor rootDescriptor)
                                     throws QueryException
INTERNAL: Lookup the descriptor for this item by traversing its expression recursively.

Parameters:
expression -
rootDescriptor -
Returns:
Throws:
QueryException

getLockMode

public short getLockMode()
PUBLIC: Return the current locking mode.

Overrides:
getLockMode in class ObjectBuildingQuery

getLockingClause

public org.eclipse.persistence.internal.expressions.ForUpdateClause getLockingClause()
INTERNAL: It is not exactly as simple as a query being either locking or not. Any combination of the reference class object and joined attributes may be locked.


getNonFetchJoinAttributeExpressions

public List<Expression> getNonFetchJoinAttributeExpressions()
INTERNAL: Return the attributes that must be joined, but not fetched, that is, do not trigger the value holder.


getPartialAttributeExpressions

public List<Expression> getPartialAttributeExpressions()
INTERNAL: Return the partial attributes to select.


getQueryByExamplePolicy

public QueryByExamplePolicy getQueryByExamplePolicy()
PUBLIC: When using Query By Example, an instance of QueryByExamplePolicy is used to customize the query. The policy is useful when special operations are to be used for comparisons (notEqual, lessThan, greaterThan, like etc.), when a certain value is to be ignored, or when dealing with nulls.


getReferenceClass

public Class getReferenceClass()
PUBLIC: Return the reference class of the query.

Overrides:
getReferenceClass in class ObjectBuildingQuery

getReferenceClassName

public String getReferenceClassName()
INTERNAL: Return the reference class of the query.

Overrides:
getReferenceClassName in class ObjectBuildingQuery

hasAsOfClause

public boolean hasAsOfClause()
PUBLIC: Answers if the domain objects are to be read as of a past time.

See Also:
getAsOfClause()

hasNonFetchJoinedAttributeExpressions

public boolean hasNonFetchJoinedAttributeExpressions()
INTERNAL: Return the attributes that must be joined.


hasPartialAttributeExpressions

public boolean hasPartialAttributeExpressions()
INTERNAL: Return if partial attributes.

Overrides:
hasPartialAttributeExpressions in class ObjectBuildingQuery

hasAdditionalFields

public boolean hasAdditionalFields()
INTERNAL: Return if additional field.


getPartialAttributeSelectionFields

public Vector getPartialAttributeSelectionFields(boolean isCustomSQL)
INTERNAL: Return the fields required in the select clause, for patial attribute reading.


getFetchGroupNonNestedFieldsSet

public Set<org.eclipse.persistence.internal.helper.DatabaseField> getFetchGroupNonNestedFieldsSet()
INTERNAL: Return the set of fields required in the select clause, for fetch group reading.


getFetchGroupNonNestedFieldsSet

public Set<org.eclipse.persistence.internal.helper.DatabaseField> getFetchGroupNonNestedFieldsSet(DatabaseMapping nestedMapping)

getFetchGroupSelectionFields

public List<org.eclipse.persistence.internal.helper.DatabaseField> getFetchGroupSelectionFields()
INTERNAL: Return the fields required in the select clause, for fetch group reading.


addJoinSelectionFields

public void addJoinSelectionFields(Vector fields,
                                   boolean isCustomSQL)
INTERNAL: The method adds to the passed input vector the fields or expressions corresponding to the joins.


getSelectionFields

public Vector getSelectionFields()
INTERNAL: Return the fields selected by the query. This includes the partial or joined fields. This is only used for custom SQL executions.


getWaitTimeout

public Integer getWaitTimeout()
PUBLIC: Return the WAIT timeout value of pessimistic locking query.


isDistinctComputed

public boolean isDistinctComputed()
INTERNAL: return true if this query has computed its distinct value already


isLockQuery

public boolean isLockQuery()
PUBLIC: Answers if the query lock mode is known to be LOCK or LOCK_NOWAIT. In the case of DEFAULT_LOCK_MODE and the query reference class being a CMP entity bean, at execution time LOCK, LOCK_NOWAIT, or NO_LOCK will be decided.

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.

Overrides:
isLockQuery in class ObjectBuildingQuery

isLockQuery

public boolean isLockQuery(Session session)
ADVANCED: Answers if this query will issue any pessimistic locks.

If the lock mode is not known (DEFAULT_LOCK_MODE / descriptor specified fine-grained locking) the lock mode will be determined now, to be either LOCK, LOCK_NOWAIT, or NO_LOCK.

See Also:
isLockQuery()

isObjectLevelReadQuery

public boolean isObjectLevelReadQuery()
PUBLIC: Return if this is an object level read query.

Overrides:
isObjectLevelReadQuery in class DatabaseQuery

isPartialAttribute

public boolean isPartialAttribute(String attributeName)
INTERNAL: Return if partial attribute.


shouldExtendPessimisticLockScope

public boolean shouldExtendPessimisticLockScope()
INTERNAL: Indicates whether pessimistic lock should also be applied to relation tables (ManyToMany and OneToOne mappings), reference tables (DirectCollection and AggregateCollection mapping).


setShouldExtendPessimisticLockScope

public void setShouldExtendPessimisticLockScope(boolean isExtended)
INTERNAL: Indicates whether pessimistic lock should also be applied to relation tables (ManyToMany and OneToOne mappings), reference tables (DirectCollection and AggregateCollection mapping).


setIsPrepared

public void setIsPrepared(boolean isPrepared)
INTERNAL: Clear cached flags when un-preparing.

Overrides:
setIsPrepared in class DatabaseQuery

copyFromQuery

public void copyFromQuery(DatabaseQuery query)
INTERNAL: Copy all setting from the query. This is used to morph queries from one type to the other. By default this calls prepareFromQuery, but additional properties may be required to be copied as prepareFromQuery only copies properties that affect the SQL.

Overrides:
copyFromQuery in class ObjectBuildingQuery

prepareFromQuery

public void prepareFromQuery(DatabaseQuery query)
INTERNAL: Prepare the query from the prepared query. This allows a dynamic query to prepare itself directly from a prepared query instance. This is used in the EJBQL parse cache to allow preparsed queries to be used to prepare dynamic queries. This only copies over properties that are configured through EJBQL.

Overrides:
prepareFromQuery in class ObjectBuildingQuery

prepareFetchGroup

public void prepareFetchGroup()
                       throws QueryException
INTERNAL: Add mandatory attributes to fetch group, create entityFetchGroup.

Throws:
QueryException

refreshIdentityMapResult

public void refreshIdentityMapResult()
PUBLIC: Refresh the attributes of the object(s) resulting from the query. If cascading is used the private parts of the objects will also be refreshed.

Overrides:
refreshIdentityMapResult in class ObjectBuildingQuery

refreshRemoteIdentityMapResult

public void refreshRemoteIdentityMapResult()
PUBLIC: Refresh the attributes of the object(s) resulting from the query. If cascading is used the private parts of the objects will also be refreshed.

Overrides:
refreshRemoteIdentityMapResult in class ObjectBuildingQuery

registerResultInUnitOfWork

public abstract Object registerResultInUnitOfWork(Object result,
                                                  org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork,
                                                  org.eclipse.persistence.internal.sessions.AbstractRecord arguments,
                                                  boolean buildDirectlyFromRows)
INTERNAL: All objects queried via a UnitOfWork get registered here. If the query went to the database.

Involves registering the query result individually and in totality, and hence refreshing / conforming is done here.

Parameters:
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 conforming
buildDirectlyFromRows - If in transaction must construct a registered result from raw database rows.
Returns:
the final (conformed, refreshed, wrapped) UnitOfWork query result

resetDistinct

public void resetDistinct()
ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by TopLink for batch reading but may also be used directly for advanced queries or report queries.


setAdditionalFields

public void setAdditionalFields(List<Object> additionalFields)
INTERNAL: Additional fields can be added to a query. This is used in m-m batch reading to bring back the key from the join table.


shouldCheckCache

public boolean shouldCheckCache()
PUBLIC: Return if the cache should be checked.


setCacheUsage

public void setCacheUsage(int cacheUsage)
PUBLIC: Set the cache usage. By default only primary key read object queries will first check the cache before accessing the database. Any query can be configure to query against the cache completely, by key or ignore the cache check.

Valid values are:


setDescriptor

public void setDescriptor(ClassDescriptor descriptor)
INTERNAL: Set the descriptor for the query.

Overrides:
setDescriptor in class DatabaseQuery

setDistinctState

public void setDistinctState(short distinctState)
ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by TopLink for batch reading but may also be used directly for advanced queries or report queries.


setExampleObject

public void setExampleObject(Object newExampleObject)
PUBLIC: Set the example object of the query to be the newExampleObject. The example object is used for Query By Example. When doing a Query By Example, an instance of the desired object is created, and the fields are filled with the values that are required in the result set. From these values the corresponding expression is built by EclipseLink, and the query is executed, returning the set of results.

If a query already has a selection criteria this criteria and the generated query by example criteria will be conjuncted.

Once a query is executed you must make an explicit call to setExampleObject if the example object is changed, so the query will know to prepare itself again.

There is a caution to setting both a selection criteria and an example object: Only in this case if you set the example object again after execution you must then also reset the selection criteria. (This is because after execution the original criteria and Query By Example criteria were fused together, and the former cannot be easily recovered from the now invalid result).


setInMemoryQueryIndirectionPolicy

public void setInMemoryQueryIndirectionPolicy(InMemoryQueryIndirectionPolicy inMemoryQueryIndirectionPolicy)
PUBLIC: Set the InMemoryQueryIndirectionPolicy for this query.


setInMemoryQueryIndirectionPolicyState

public void setInMemoryQueryIndirectionPolicyState(int inMemoryQueryIndirectionPolicy)
PUBLIC: Set the InMemoryQueryIndirectionPolicy for this query.


setLockMode

public void setLockMode(short lockMode)
PUBLIC: Sets whether this is a pessimistically locking query.

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"));

Overrides:
setLockMode in class ObjectBuildingQuery
See Also:
PessimisticLockingPolicy

setLockModeType

public boolean setLockModeType(String lockModeType,
                               org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Sets a javax.persistence.LockModeType to used with this queries execution. The valid types are: - WRITE - READ - OPTIMISTIC - OPTIMISTIC_FORCE_INCREMENT - PESSIMISTIC_READ - PESSIMISTIC_WRITE - PESSIMISTIC_FORCE_INCREMENT - NONE Setting a null type will do nothing.

Returns:
returns a failure flag indicating that we were UNABLE to set the lock mode because of validation. Callers to this method should check the return value and throw the necessary exception.

setLockingClause

public void setLockingClause(org.eclipse.persistence.internal.expressions.ForUpdateClause clause)
INTERNAL: The locking clause contains a list of expressions representing which objects are to be locked by the query.

Use for even finer grained control over what is and is not locked by a particular query.


setPartialAttributeExpressions

public void setPartialAttributeExpressions(List<Expression> partialAttributeExpressions)
INTERNAL: Set the partial attributes to select.


setEJBQLString

public void setEJBQLString(String ejbqlString)
Description copied from class: DatabaseQuery
PUBLIC: Set the EJBQL string of the query. If arguments are required in the string they will be preceded by "?" then the argument number.

Overrides:
setEJBQLString in class DatabaseQuery

setQueryByExamplePolicy

public void setQueryByExamplePolicy(QueryByExamplePolicy queryByExamplePolicy)
PUBLIC: The QueryByExamplePolicy, is a useful to customize the query when Query By Example is used. The policy will control what attributes should, or should not be included in the query. When dealing with nulls, using special operations (notEqual, lessThan, like, etc.) for comparison, or choosing to include certain attributes at all times, it is useful to modify the policy accordingly.

Once a query is executed you must make an explicit call to setQueryByExamplePolicy when changing the policy, so the query will know to prepare itself again.

There is a caution to setting both a selection criteria and an example object: If you set the policy after execution you must also reset the selection criteria. (This is because after execution the original criteria and Query By Example criteria are fused together, and the former cannot be easily recovered).


setReferenceClass

public void setReferenceClass(Class aClass)
REQUIRED: Set the reference class for the query.

Overrides:
setReferenceClass in class ObjectBuildingQuery

setReferenceClassName

public void setReferenceClassName(String aClass)
INTERNAL: Set the reference class for the query.

Overrides:
setReferenceClassName in class ObjectBuildingQuery

setSelectionCriteria

public void setSelectionCriteria(Expression expression)
Description copied from class: DatabaseQuery
PUBLIC: To any user of this object. Set the selection criteria of the query. This method be used when dealing with expressions.

Overrides:
setSelectionCriteria in class DatabaseQuery

setShouldIncludeData

public void setShouldIncludeData(boolean shouldIncludeData)
INTERNAL: Set if the rows for the result of the query should also be returned using a complex query result.

See Also:
ComplexQueryResult

shouldCheckCacheOnly

public boolean shouldCheckCacheOnly()
PUBLIC: Return if cache should be checked.


shouldCheckDescriptorForCacheUsage

public boolean shouldCheckDescriptorForCacheUsage()
PUBLIC: Return whether the descriptor's disableCacheHits setting should be checked prior to querying the cache.


shouldConformResultsInUnitOfWork

public boolean shouldConformResultsInUnitOfWork()
PUBLIC: Should the results will be checked against the changes within the unit of work and object no longer matching or deleted will be remove, matching new objects will also be added..


shouldDistinctBeUsed

public boolean shouldDistinctBeUsed()
INTERNAL: return true if this query should use a distinct


shouldIncludeData

public boolean shouldIncludeData()
INTERNAL: Return if the rows for the result of the query should also be returned using a complex query result.

See Also:
ComplexQueryResult

shouldOuterJoinSubclasses

public boolean shouldOuterJoinSubclasses()
PUBLIC: Return if an outer join should be used to read subclasses. By default a separate query is done for each subclass when querying for a root or branch inheritance class that has subclasses that span multiple tables.


setShouldOuterJoinSubclasses

public void setShouldOuterJoinSubclasses(boolean shouldOuterJoinSubclasses)
PUBLIC: Set if an outer join should be used to read subclasses. By default a separate query is done for each subclass when querying for a root or branch inheritance class that has subclasses that span multiple tables.


shouldReadAllMappings

public boolean shouldReadAllMappings()
INTERNAL: Return if this is a full object query, not partial nor fetch group.

Overrides:
shouldReadAllMappings in class ObjectBuildingQuery

shouldReadMapping

public boolean shouldReadMapping(DatabaseMapping mapping)
INTERNAL: Check if the mapping is part of the partial attributes.

Overrides:
shouldReadMapping in class ObjectBuildingQuery

useDistinct

public void useDistinct()
ADVANCED: If a distinct has been set the DISTINCT clause will be printed. This is used internally by EclipseLink for batch reading but may also be used directly for advanced queries or report queries.


isClonePessimisticLocked

public boolean isClonePessimisticLocked(Object clone,
                                        org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow)
INTERNAL: Helper method that checks if clone has been locked with uow.

Overrides:
isClonePessimisticLocked in class ObjectBuildingQuery

recordCloneForPessimisticLocking

public void recordCloneForPessimisticLocking(Object clone,
                                             org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow)
INTERNAL: Helper method that records clone with uow if query is pessimistic locking.

Overrides:
recordCloneForPessimisticLocking in class ObjectBuildingQuery

isResultSetOptimizedQuery

public boolean isResultSetOptimizedQuery()
ADVANCED: Return if the query should be optimized to build directly from the result set. This optimization follows an optimized path and can only be used for, singleton primary key, direct mapped, simple type, no inheritance, uow isolated objects.


setIsResultSetOptimizedQuery

public void setIsResultSetOptimizedQuery(boolean isResultSetOptimizedQuery)
ADVANCED: Set if the query should be optimized to build directly from the result set. This optimization follows an optimized path and can only be used for, singleton primary key, direct mapped, simple type, no inheritance, uow isolated objects.


isDefaultLock

public boolean isDefaultLock()
INTERNAL: Helper method to determine the default mode. If true and query has a pessimistic locking policy, locking will be configured according to the pessimistic locking policy.

Overrides:
isDefaultLock in class ObjectBuildingQuery

isDefaultPropertiesQuery

public boolean isDefaultPropertiesQuery()
INTERNAL: Return true if the query uses default properties. This is used to determine if this query is cacheable. i.e. does not use any properties that may conflict with another query with the same JPQL or selection criteria.

Overrides:
isDefaultPropertiesQuery in class ReadQuery

hasDefaultBuilder

public boolean hasDefaultBuilder()
INTERNAL: Checks to see if a builder has been set on the query.


hasFetchGroup

public boolean hasFetchGroup()
Return if a fetch group is set in the query.


getFetchGroup

public FetchGroup getFetchGroup()
Return the fetch group set in the query. If a fetch group is not explicitly set in the query, default fetch group optionally defined in the descriptor would be used, unless the user explicitly calls query.setShouldUseDefaultFetchGroup(false). Note that the returned fetchGroup may be updated during preProcess.

See Also:
for named and default FetchGroup lookup.

getLoadGroup

public LoadGroup getLoadGroup()
Return the load group set in the query.


getExecutionFetchGroup

public FetchGroup getExecutionFetchGroup()
INTERNAL: Returns FetchGroup that will be applied to the query. Note that the returned fetchGroup may be updated during preProcess.

Overrides:
getExecutionFetchGroup in class ObjectBuildingQuery

getEntityFetchGroup

public org.eclipse.persistence.internal.queries.EntityFetchGroup getEntityFetchGroup()
INTERNAL: Returns EntityFetchGroup that will be applied to objects returned by the query. Should not be called before preProcess - may not yet exist.

Overrides:
getEntityFetchGroup in class ObjectBuildingQuery

hasExecutionFetchGroup

public boolean hasExecutionFetchGroup()
INTERNAL: Indicates whether a FetchGroup will be applied to the query.

Overrides:
hasExecutionFetchGroup in class ObjectBuildingQuery

setFetchGroup

public void setFetchGroup(FetchGroup newFetchGroup)
Set a dynamic (use case) fetch group to the query.


setFetchGroupName

public void setFetchGroupName(String groupName)
Set a descriptor-level pre-defined named fetch group to the query.


setLoadGroup

public void setLoadGroup(LoadGroup loadGroup)
Set a load group to the query.


getFetchGroupName

public String getFetchGroupName()
Return the fetch group name set in the query.


shouldUseDefaultFetchGroup

public boolean shouldUseDefaultFetchGroup()
Return false if the query does not use the default fetch group defined in the descriptor level.


setShouldUseDefaultFetchGroup

public void setShouldUseDefaultFetchGroup(boolean shouldUseDefaultFetchGroup)
Set false if the user does not want to use the default fetch group defined in the descriptor level.


getConcreteSubclassCalls

public Map<Class,org.eclipse.persistence.internal.databaseaccess.DatabaseCall> getConcreteSubclassCalls()
INTERNAL: Return the cache of concrete subclass calls. This allow concrete subclasses calls to be prepared and cached for inheritance queries.


isPrimaryKeyQuery

public boolean isPrimaryKeyQuery()
INTERNAL: Return if the query is known to be by primary key.


extendPessimisticLockScope

public void extendPessimisticLockScope()
INTERNAL: Extends pessimistic lock scope.


getBatchFetchPolicy

public BatchFetchPolicy getBatchFetchPolicy()
Return the batch fetch policy for configuring batch fetching.


setBatchFetchPolicy

public void setBatchFetchPolicy(BatchFetchPolicy batchFetchPolicy)
Set the batch fetch policy for configuring batch fetching.


getBatchReadAttributeExpressions

public List<Expression> getBatchReadAttributeExpressions()
INTERNAL: Return all attributes specified for batch reading.


setBatchReadAttributeExpressions

public void setBatchReadAttributeExpressions(List<Expression> attributeExpressions)
INTERNAL: Set all attributes specified for batch reading.


hasBatchReadAttributes

public boolean hasBatchReadAttributes()
INTERNAL: Return true is this query has batching


isAttributeBatchRead

public boolean isAttributeBatchRead(ClassDescriptor mappingDescriptor,
                                    String attributeName)
INTERNAL: Return if the attribute is specified for batch reading.


computeBatchReadMappingQueries

public void computeBatchReadMappingQueries()
INTERNAL: Used to optimize joining by pre-computing the nested join queries for the mappings.


addBatchReadAttribute

public void addBatchReadAttribute(String attributeName)
PUBLIC: Specify the foreign-reference mapped attribute to be optimized in this query. The query will execute normally, however when any of the batched parts is accessed, the parts will all be read in a single query, this allows all of the data required for the parts to be read in a single query instead of (n) queries. This should be used when the application knows that it requires the part for all of the objects being read. This can be used for one-to-one, one-to-many, many-to-many and direct collection mappings. The use of the expression allows for nested batch reading to be expressed.

Example: query.addBatchReadAttribute("phoneNumbers")

See Also:
addBatchReadAttribute(Expression), setBatchFetchType(BatchFetchType), addJoinedAttribute(String)

addBatchReadAttribute

public void addBatchReadAttribute(Expression attributeExpression)
PUBLIC: Specify the foreign-reference mapped attribute to be optimized in this query. The query will execute normally, however when any of the batched parts is accessed, the parts will all be read in a single query, this allows all of the data required for the parts to be read in a single query instead of (n) queries. This should be used when the application knows that it requires the part for all of the objects being read. This can be used for one-to-one, one-to-many, many-to-many and direct collection mappings. The use of the expression allows for nested batch reading to be expressed.

Example: query.addBatchReadAttribute(query.getExpressionBuilder().get("policies").get("claims"))

See Also:
setBatchFetchType(BatchFetchType), addJoinedAttribute(String)

setBatchFetchType

public void setBatchFetchType(BatchFetchType type)
PUBLIC: Set the batch fetch type for the query. This can be JOIN, EXISTS, or IN. This defines the type of batch reading to use with the query. The query must have defined batch read attributes to set its fetch type.

See Also:
addBatchReadAttribute(Expression)

setBatchFetchSize

public void setBatchFetchSize(int size)
PUBLIC: Set the batch fetch size for the query. This is only relevant for the IN batch fetch type. This defines the max number of keys for the IN clause.

See Also:
setBatchFetchType(BatchFetchType), addBatchReadAttribute(Expression)

getBatchObjects

public Map<Object,Object> getBatchObjects()
INTERNAL: Return temporary map of batched objects.

Overrides:
getBatchObjects in class DatabaseQuery

setBatchObjects

public void setBatchObjects(Map<Object,Object> batchObjects)
INTERNAL: Set temporary map of batched objects.

Overrides:
setBatchObjects in class DatabaseQuery

toString

public String toString()
Overrides:
toString in class DatabaseQuery