EclipseLink 2.0.0, build 'v20091127-r5931' API Reference

org.eclipse.persistence.queries
Class ReadAllQuery

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
                  extended by org.eclipse.persistence.queries.ReadAllQuery
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
ReportQuery

public class ReadAllQuery
extends ObjectLevelReadQuery

Purpose: Concrete class for all read queries involving a collection of objects.

Responsibilities: Return a container of the objects generated by the query. Implements the inheritance feature when dealing with abstract descriptors

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

Field Summary
protected  java.util.Vector batchReadAttributeExpressions
          Used for query optimization.
protected  java.util.List batchReadAttributes
          PERF: Cache the local batch read attribute names.
protected  java.util.Map batchReadMappingQueries
          PERF: Used internally for batch reading.
protected  Expression connectByExpression
           
protected  org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy
          Used for collection and stream support.
protected  java.util.Vector orderSiblingsByExpressions
           
protected  Expression startWithExpression
          Used for Oracle HierarchicalQuery support
 
Fields inherited from class org.eclipse.persistence.queries.ObjectLevelReadQuery
additionalFields, cacheUsage, CheckCacheByExactPrimaryKey, CheckCacheByPrimaryKey, CheckCacheOnly, CheckCacheThenDatabase, concreteSubclassCalls, ConformResultsInUnitOfWork, defaultBuilder, distinctState, DoNotCheckCache, DONT_USE_DISTINCT, executionTime, fetchGroup, fetchGroupName, inMemoryQueryIndirectionPolicy, isPrePrepared, isReadOnly, isReferenceClassLocked, isResultSetOptimizedQuery, joinedAttributeManager, lockModeType, NONE, nonFetchJoinAttributeExpressions, OPTIMISTIC, OPTIMISTIC_FORCE_INCREMENT, orderByExpressions, partialAttributeExpressions, PESSIMISTIC_, PESSIMISTIC_FORCE_INCREMENT, PESSIMISTIC_READ, PESSIMISTIC_WRITE, READ, shouldExtendPessimisticLockScope, shouldIncludeData, shouldOuterJoinSubclasses, shouldUseDefaultFetchGroup, UNCOMPUTED_DISTINCT, USE_DISTINCT, UseDescriptorSetting, waitTimeout, WRITE
 
Fields inherited from class org.eclipse.persistence.queries.ObjectBuildingQuery
DEFAULT_LOCK_MODE, LOCK, LOCK_NOWAIT, LOCK_RESULT_PROPERTY, lockingClause, NO_LOCK, referenceClass, referenceClassName, shouldBuildNullForNullPk, shouldProcessResultsInUnitOfWork, shouldRefreshIdentityMapResult, shouldRefreshRemoteIdentityMapResult, shouldRegisterResultsInUnitOfWork, shouldUseExclusiveConnection, wasDefaultLockMode
 
Fields inherited from class org.eclipse.persistence.queries.ReadQuery
fetchSize, firstResult, maxRows, queryId, queryResultCachingPolicy, temporaryCachedQueryResults
 
Fields inherited from class org.eclipse.persistence.queries.DatabaseQuery
accessor, argumentFields, arguments, argumentTypeNames, argumentTypes, argumentValues, CascadeAggregateDelete, CascadeAllParts, CascadeByMapping, CascadeDependentParts, cascadePolicy, CascadePrivateParts, descriptor, doNotRedirect, executionSession, flushOnExecute, hintString, isCustomQueryUsed, isExecutionClone, isNativeConnectionRequired, isPrepared, isUserDefined, name, NoCascading, properties, queryMechanism, queryTimeout, redirector, session, sessionName, shouldBindAllParameters, shouldCacheStatement, shouldCloneCall, shouldMaintainCache, shouldPrepare, shouldRetrieveBypassCache, shouldStoreBypassCache, shouldUseWrapperPolicy, sourceMapping, translationRow
 
Constructor Summary
ReadAllQuery()
          PUBLIC: Return a new read all query.
ReadAllQuery(Call call)
          PUBLIC: Create a read all query with the database call.
ReadAllQuery(java.lang.Class classToRead)
          PUBLIC: Return a new read all query.
ReadAllQuery(java.lang.Class classToRead, Call call)
          PUBLIC: Return a new read all query.
ReadAllQuery(java.lang.Class classToRead, Expression selectionCriteria)
          PUBLIC: Return a new read all query for the class and the selection criteria.
ReadAllQuery(java.lang.Class classToRead, ExpressionBuilder builder)
          PUBLIC: Return a new read all query for the class.
ReadAllQuery(ExpressionBuilder builder)
          PUBLIC: The expression builder should be provide on creation to ensure only one is used.
ReadAllQuery(java.lang.Object exampleObject, QueryByExamplePolicy policy)
          PUBLIC: Return a query by example query to find all objects matching the attributes of the example object.
 
Method Summary
 void addAscendingOrdering(java.lang.String queryKeyName)
          PUBLIC: Order the query results by the object's attribute or query key name.
 void addBatchReadAttribute(Expression attributeExpression)
          PUBLIC: Specify the foreign-reference mapped attribute to be optimized in this query.
 void addBatchReadAttribute(java.lang.String attributeName)
          PUBLIC: Specify the foreign-reference mapped attribute to be optimized in this query.
 void cacheResult(java.lang.Object unwrappedOriginal)
          INTERNAL: This method is called by the object builder when building an original.
protected  java.lang.Object checkEarlyReturnImpl(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
          INTERNAL: The cache check is done before the prepare as a hit will not require the work to be done.
protected  DatabaseQuery checkForCustomQuery(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
          INTERNAL: Check to see if a custom query should be used for this query.
 java.lang.Object clone()
          INTERNAL: Clone the query.
 void computeBatchReadMappingQueries()
          INTERNAL: Used to optimize joining by pre-computing the nested join queries for the mappings.
protected  void computeNestedQueriesForBatchReadExpressions(java.util.Vector batchReadExpressions)
          INTERNAL: This method is used when computing the nested queries for batch read mappings.
protected  java.lang.Object conformResult(java.lang.Object result, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, org.eclipse.persistence.internal.sessions.AbstractRecord arguments, boolean buildDirectlyFromRows)
          INTERNAL: Conform the result if specified.
 boolean equals(java.lang.Object object)
          INTERNAL: Return if the query is equal to the other.
 java.lang.Object execute(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord row)
          INTERNAL: Execute the query.
protected  java.lang.Object executeObjectLevelReadQuery()
          INTERNAL: Execute the query.
protected  java.lang.Object executeObjectLevelReadQueryFromResultSet()
          INTERNAL: Execute the query building the objects directly from the database result-set.
 java.lang.Object extractRemoteResult(org.eclipse.persistence.internal.sessions.remote.Transporter transporter)
          INTERNAL: Extract the correct query result from the transporter.
 java.util.Vector getBatchReadAttributeExpressions()
          INTERNAL: Return all attributes specified for batch reading.
 java.util.Map getBatchReadMappingQueries()
          INTERNAL: Return the batch read mapping queries, used to optimize batch reading, only compute the nested queries once.
 Expression getConnectByExpression()
          PUBLIC:
 org.eclipse.persistence.internal.queries.ContainerPolicy getContainerPolicy()
          INTERNAL: Return the query's container policy.
protected  QueryRedirector getDefaultRedirector()
          INTERNAL: Returns the specific default redirector for this query type.
 java.util.Vector getOrderSiblingsByExpressions()
          PUBLIC:
 Expression getStartWithExpression()
          PUBLIC:
 boolean hasBatchReadAttributes()
          INTERNAL: Return true is this query has batching
 boolean hasHierarchicalExpressions()
          INTERNAL: Verify that we have hierarchical query expressions
 boolean isAttributeBatchRead(ClassDescriptor mappingDescriptor, java.lang.String attributeName)
          INTERNAL: Return if the attribute is specified for batch reading.
 boolean isAttributeBatchRead(java.lang.String attributeName)
          INTERNAL: Return if the attribute is specified for batch reading.
 boolean isDefaultPropertiesQuery()
          INTERNAL: Return true if the query uses default properties.
 boolean isReadAllQuery()
          PUBLIC: Return if this is a read all query.
protected  void prepare()
          INTERNAL: Prepare the receiver for execution in a session.
protected  void prepareCustomQuery(DatabaseQuery customQuery)
          INTERNAL: Set the properties needed to be cascaded into the custom query.
 void prepareForExecution()
          INTERNAL: Prepare the receiver for execution in a session.
 void prepareFromQuery(DatabaseQuery query)
          INTERNAL: Prepare the query from the prepared query.
protected  void prepareSelectAllRows()
          INTERNAL: Prepare the mechanism.
 java.lang.Object registerResultInUnitOfWork(java.lang.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.
 java.lang.Object remoteExecute()
          INTERNAL: Execute the query through remote session.
 java.util.Map replaceValueHoldersIn(java.lang.Object object, org.eclipse.persistence.internal.sessions.remote.RemoteSessionController controller)
          INTERNAL: replace the value holders in the specified result object(s)
 void setBatchReadAttributeExpressions(java.util.Vector batchReadAttributeExpressions)
          INTERNAL: Return all attributes specified for batch reading.
protected  void setBatchReadMappingQueries(java.util.Map batchReadMappingQueries)
          INTERNAL: Set the batch read mapping queries, used to optimize batch reading, only compute the nested queries once.
 void setContainerPolicy(org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy)
          PUBLIC: Set the container policy.
 void setHierarchicalQueryClause(Expression startWith, Expression connectBy, java.util.Vector orderSiblingsExpressions)
          PUBLIC: Set the Hierarchical Query Clause for the query Example: Expression startWith = builder.get("id").equal(new Integer(100)); //can be any expression which identifies a set of employees Expression connectBy = builder.get("managedEmployees"); //indicated the relationship that the hierarchy is based on, must be self-referential Vector orderBy = new Vector(); orderBy.addElement(builder.get("startDate")); readAllQuery.setHierarchicalQueryClause(startWith, connectBy, orderBy); This query would generate SQL like this: SELECT * FROM EMPLOYEE START WITH ID=100 CONNECT BY PRIOR ID = MANAGER_ID ORDER SIBLINGS BY START_DATE
 void useCollectionClass(java.lang.Class concreteClass)
          PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects.
 void useCursoredStream()
          PUBLIC: Use a CursoredStream as the result collection.
 void useCursoredStream(int initialReadSize, int pageSize)
          PUBLIC: Use a CursoredStream as the result collection.
 void useCursoredStream(int initialReadSize, int pageSize, ValueReadQuery sizeQuery)
          PUBLIC: Use a CursoredStream as the result collection.
 void useMapClass(java.lang.Class concreteClass, java.lang.String methodName)
          PUBLIC: Configure the query to use an instance of the specified container class to hold the result objects.
 void useScrollableCursor()
          PUBLIC: Use a ScrollableCursor as the result collection.
 void useScrollableCursor(int pageSize)
          PUBLIC: Use a ScrollableCursor as the result collection.
 void useScrollableCursor(ScrollableCursorPolicy policy)
          PUBLIC: Use a ScrollableCursor as the result collection.
 
Methods inherited from class org.eclipse.persistence.queries.ObjectLevelReadQuery
acquireLocks, acquireLocksWithoutWaiting, addAdditionalField, addAdditionalField, addDescendingOrdering, addJoinedAttribute, addJoinedAttribute, addNonFetchJoinedAttribute, addNonFetchJoinedAttribute, addOrdering, addPartialAttribute, addPartialAttribute, addSelectionFieldsForJoinedExpressions, buildObject, changeDescriptor, checkCacheOnly, checkDescriptor, checkEarlyReturn, checkPrepare, checkPrePrepare, conformIndividualResult, conformResultsInUnitOfWork, copyFromQuery, deepClone, dontAcquireLocks, dontCheckCache, dontRefreshIdentityMapResult, dontRefreshRemoteIdentityMapResult, dontUseDistinct, executeDatabaseQuery, executeInUnitOfWork, extendPessimisticLockScope, getAdditionalFields, getAsOfClause, getCacheUsage, getConcreteSubclassCalls, getDistinctState, getExampleObject, getExecutionTime, getExpressionBuilder, getFetchGroup, getFetchGroupName, getFetchGroupSelectionFields, getInMemoryQueryIndirectionPolicy, getInMemoryQueryIndirectionPolicyState, getJoinedAttributeExpressions, getJoinedAttributeManager, getLeafDescriptorFor, getLeafMappingFor, getLockingClause, getLockMode, getNonFetchJoinAttributeExpressions, getOrderByExpressions, getPartialAttributeExpressions, getPartialAttributeSelectionFields, getQueryByExamplePolicy, getReferenceClass, getReferenceClassName, getSelectionFields, getWaitTimeout, hasAdditionalFields, hasAsOfClause, hasDefaultBuilder, hasFetchGroup, hashCode, hasJoining, hasNonFetchJoinedAttributeExpressions, hasOrderByExpressions, hasPartialAttributeExpressions, initializeDefaultBuilder, initializeFetchGroup, isClonePessimisticLocked, isDefaultLock, isDistinctComputed, isFetchGroupAttribute, isLockQuery, isLockQuery, isObjectLevelReadQuery, isPartialAttribute, isPrePrepared, isPrimaryKeyQuery, isReadOnly, isReferenceClassLocked, isRegisteringResults, isResultSetOptimizedQuery, prepareForRemoteExecution, prepareFromCachedQuery, prepareOutsideUnitOfWork, prepareQuery, prePrepare, recordCloneForPessimisticLocking, refreshIdentityMapResult, refreshRemoteIdentityMapResult, resetDistinct, setAdditionalFields, setAsOfClause, setCacheUsage, setDescriptor, setDistinctState, setEJBQLString, setExampleObject, setExecutionTime, setExpressionBuilder, setFetchGroup, setFetchGroupName, setInMemoryQueryIndirectionPolicy, setInMemoryQueryIndirectionPolicyState, setIsPrepared, setIsPrePrepared, setIsReadOnly, setIsResultSetOptimizedQuery, setJoinedAttributeExpressions, setJoinedAttributeManager, setLockingClause, setLockMode, setLockModeType, setNonFetchJoinAttributeExpressions, setOrderByExpressions, setPartialAttributeExpressions, setQueryByExamplePolicy, setReferenceClass, setReferenceClassName, setSelectionCriteria, setShouldExtendPessimisticLockScope, setShouldFilterDuplicates, setShouldIncludeData, setShouldOuterJoinSubclasses, setShouldProcessResultsInUnitOfWork, setShouldRefreshIdentityMapResult, setShouldRefreshRemoteIdentityMapResult, setShouldRegisterResultsInUnitOfWork, setShouldUseDefaultFetchGroup, setWaitTimeout, setWasDefaultLockMode, shouldCheckCacheOnly, shouldCheckDescriptorForCacheUsage, shouldConformResultsInUnitOfWork, shouldDistinctBeUsed, shouldExtendPessimisticLockScope, shouldFilterDuplicates, shouldIncludeData, shouldOuterJoinSubclasses, shouldProcessResultsInUnitOfWork, shouldReadAllMappings, shouldReadMapping, shouldRefreshIdentityMapResult, shouldRefreshRemoteIdentityMapResult, shouldRegisterResultsInUnitOfWork, shouldUseDefaultFetchGroup, useDistinct, wasDefaultLockMode
 
Methods inherited from class org.eclipse.persistence.queries.ObjectBuildingQuery
convertClassNamesToClasses, getDataResults, isAttributeJoined, isObjectBuildingQuery, registerIndividualResult, setShouldBuildNullForNullPk, setShouldUseExclusiveConnection, shouldBuildNullForNullPk, shouldUseExclusiveConnection
 
Methods inherited from class org.eclipse.persistence.queries.ReadQuery
cacheQueryResults, clearQueryResults, clonedQueryExecutionComplete, doNotCacheQueryResults, getFetchSize, getFirstResult, getMaxRows, getQueryId, getQueryResults, getQueryResults, getQueryResults, getQueryResultsCachePolicy, getTemporaryCachedQueryResults, isReadQuery, remoteExecute, setFetchSize, setFirstResult, setMaxRows, setQueryId, setQueryResults, setQueryResultsCachePolicy, setTemporaryCachedQueryResults, shouldCacheQueryResults
 
Methods inherited from class org.eclipse.persistence.queries.DatabaseQuery
addArgument, addArgument, addArgument, addArgumentByTypeName, addArgumentValue, addArgumentValues, addCall, addStatement, bindAllParameters, buildArgumentFields, buildSelectionCriteria, cacheStatement, cascadeAllParts, cascadeByMapping, cascadeOnlyDependentParts, cascadePrivateParts, checkPrepare, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, 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, isCustomSelectionQuery, isDataModifyQuery, isDataReadQuery, isDeleteAllQuery, isDeleteObjectQuery, isDirectReadQuery, isExecutionClone, isExpressionQuery, isInsertObjectQuery, isJPQLCallQuery, isModifyAllQuery, isModifyQuery, isNativeConnectionRequired, isObjectLevelModifyQuery, isPrepared, isReadObjectQuery, isReportQuery, isSQLCallQuery, isUpdateAllQuery, isUpdateObjectQuery, isUserDefined, isValueReadQuery, isWriteObjectQuery, maintainCache, prepareCall, redirectQuery, removeProperty, retrieveBypassCache, rowFromArguments, setAccessor, setArguments, setArgumentTypeNames, setArgumentTypes, setArgumentValues, setCall, setCascadePolicy, setDatasourceCall, setDoNotRedirect, setExecutionSession, setFlushOnExecute, setHintString, setIsCustomQueryUsed, setIsExecutionClone, setIsNativeConnectionRequired, setIsUserDefined, setJPQLString, setName, setProperties, setProperty, setQueryMechanism, 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, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

batchReadAttributeExpressions

protected java.util.Vector batchReadAttributeExpressions
Used for query optimization.


batchReadMappingQueries

protected transient java.util.Map batchReadMappingQueries
PERF: Used internally for batch reading.


batchReadAttributes

protected java.util.List batchReadAttributes
PERF: Cache the local batch read attribute names.


containerPolicy

protected org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy
Used for collection and stream support.


startWithExpression

protected Expression startWithExpression
Used for Oracle HierarchicalQuery support


connectByExpression

protected Expression connectByExpression

orderSiblingsByExpressions

protected java.util.Vector orderSiblingsByExpressions
Constructor Detail

ReadAllQuery

public ReadAllQuery()
PUBLIC: Return a new read all query. A reference class must be specified before execution. It is better to provide the class and expression builder on construction to ensure a single expression builder is used. If no selection criteria is specified this will read all objects of the class from the database.


ReadAllQuery

public ReadAllQuery(java.lang.Class classToRead)
PUBLIC: Return a new read all query. It is better to provide the class and expression builder on construction to esnure a single expression builder is used. If no selection criteria is specified this will read all objects of the class from the database.


ReadAllQuery

public ReadAllQuery(java.lang.Class classToRead,
                    Expression selectionCriteria)
PUBLIC: Return a new read all query for the class and the selection criteria.


ReadAllQuery

public ReadAllQuery(java.lang.Class classToRead,
                    ExpressionBuilder builder)
PUBLIC: Return a new read all query for the class. The expression builder must be used for all associated expressions used with the query.


ReadAllQuery

public ReadAllQuery(java.lang.Class classToRead,
                    Call call)
PUBLIC: Return a new read all query. The call represents a database interaction such as SQL, Stored Procedure.


ReadAllQuery

public ReadAllQuery(java.lang.Object exampleObject,
                    QueryByExamplePolicy policy)
PUBLIC: Return a query by example query to find all objects matching the attributes of the example object.


ReadAllQuery

public ReadAllQuery(ExpressionBuilder builder)
PUBLIC: The expression builder should be provide on creation to ensure only one is used.


ReadAllQuery

public ReadAllQuery(Call call)
PUBLIC: Create a read all query with the database call.

Method Detail

addAscendingOrdering

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


addBatchReadAttribute

public void addBatchReadAttribute(java.lang.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), ObjectLevelReadQuery.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:
ObjectLevelReadQuery.addJoinedAttribute(String)

cacheResult

public void cacheResult(java.lang.Object unwrappedOriginal)
INTERNAL:

This method is called by the object builder when building an original. It will cause the original to be cached in the query results if the query is set to do so.

Specified by:
cacheResult in class ReadQuery

checkEarlyReturnImpl

protected java.lang.Object checkEarlyReturnImpl(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
INTERNAL: The cache check is done before the prepare as a hit will not require the work to be done.

Specified by:
checkEarlyReturnImpl in class ObjectLevelReadQuery

checkForCustomQuery

protected DatabaseQuery checkForCustomQuery(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                            org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
INTERNAL: Check to see if a custom query should be used for this query. This is done before the query is copied and prepared/executed. null means there is none.

Overrides:
checkForCustomQuery in class DatabaseQuery

clone

public java.lang.Object clone()
INTERNAL: Clone the query.

Overrides:
clone in class ObjectLevelReadQuery

conformResult

protected java.lang.Object conformResult(java.lang.Object result,
                                         org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork,
                                         org.eclipse.persistence.internal.sessions.AbstractRecord arguments,
                                         boolean buildDirectlyFromRows)
INTERNAL: Conform the result if specified.


execute

public java.lang.Object execute(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                org.eclipse.persistence.internal.sessions.AbstractRecord row)
                         throws DatabaseException
INTERNAL: Execute the query. If there are cached results return those. This must override the super to support result caching.

Overrides:
execute in class ObjectLevelReadQuery
Parameters:
session - - the session in which the receiver will be executed.
Returns:
An object or vector, the result of executing the query.
Throws:
DatabaseException - - an error has occurred on the database

executeObjectLevelReadQuery

protected java.lang.Object executeObjectLevelReadQuery()
                                                throws DatabaseException
INTERNAL: Execute the query. Get the rows and build the object from the rows.

Specified by:
executeObjectLevelReadQuery in class ObjectLevelReadQuery
Returns:
java.lang.Object collection of objects resulting from execution of query.
Throws:
DatabaseException - - an error has occurred on the database

executeObjectLevelReadQueryFromResultSet

protected java.lang.Object executeObjectLevelReadQueryFromResultSet()
                                                             throws DatabaseException
INTERNAL: Execute the query building the objects directly from the database result-set.

Specified by:
executeObjectLevelReadQueryFromResultSet in class ObjectLevelReadQuery
Returns:
object - the first object found or null if none.
Throws:
DatabaseException - - an error has occurred on the database

extractRemoteResult

public java.lang.Object extractRemoteResult(org.eclipse.persistence.internal.sessions.remote.Transporter transporter)
INTERNAL: Extract the correct query result from the transporter.

Overrides:
extractRemoteResult in class DatabaseQuery

getBatchReadAttributeExpressions

public java.util.Vector getBatchReadAttributeExpressions()
INTERNAL: Return all attributes specified for batch reading.


getContainerPolicy

public org.eclipse.persistence.internal.queries.ContainerPolicy getContainerPolicy()
INTERNAL: Return the query's container policy.

Returns:
org.eclipse.persistence.internal.queries.ContainerPolicy

getDefaultRedirector

protected QueryRedirector getDefaultRedirector()
INTERNAL: Returns the specific default redirector for this query type. There are numerous default query redirectors. See ClassDescriptor for their types.

Overrides:
getDefaultRedirector in class DatabaseQuery

getStartWithExpression

public Expression getStartWithExpression()
PUBLIC:

Returns:
Expression - the start with expression used to generated the hierarchical query clause in Oracle

getConnectByExpression

public Expression getConnectByExpression()
PUBLIC:

Returns:
Expression - the connect by expression used to generate the hierarchical query caluse in Oracle

getOrderSiblingsByExpressions

public java.util.Vector getOrderSiblingsByExpressions()
PUBLIC:

Returns:
Vector - the ordering expressions used to generate the hierarchical query clause in Oracle

hasHierarchicalExpressions

public boolean hasHierarchicalExpressions()
INTERNAL: Verify that we have hierarchical query expressions


hasBatchReadAttributes

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


isAttributeBatchRead

public boolean isAttributeBatchRead(java.lang.String attributeName)
INTERNAL: Return if the attribute is specified for batch reading.


isAttributeBatchRead

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


getBatchReadMappingQueries

public java.util.Map getBatchReadMappingQueries()
INTERNAL: Return the batch read mapping queries, used to optimize batch reading, only compute the nested queries once.


setBatchReadMappingQueries

protected void setBatchReadMappingQueries(java.util.Map batchReadMappingQueries)
INTERNAL: Set the batch read mapping queries, used to optimize batch reading, only compute the nested queries once.


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 ObjectLevelReadQuery

equals

public boolean equals(java.lang.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 ObjectLevelReadQuery

isReadAllQuery

public boolean isReadAllQuery()
PUBLIC: Return if this is a read all query.

Overrides:
isReadAllQuery in class DatabaseQuery

prepare

protected void prepare()
                throws QueryException
INTERNAL: Prepare the receiver for execution in a session.

Overrides:
prepare in class ObjectLevelReadQuery
Throws:
QueryException

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 JPQL parse cache to allow preparsed queries to be used to prepare dynamic queries. This only copies over properties that are configured through JPQL.

Overrides:
prepareFromQuery in class ObjectLevelReadQuery

prepareCustomQuery

protected void prepareCustomQuery(DatabaseQuery customQuery)
INTERNAL: Set the properties needed to be cascaded into the custom query.

Overrides:
prepareCustomQuery in class DatabaseQuery

prepareForExecution

public void prepareForExecution()
                         throws QueryException
INTERNAL: Prepare the receiver for execution in a session.

Overrides:
prepareForExecution in class ReadQuery
Throws:
QueryException

prepareSelectAllRows

protected void prepareSelectAllRows()
INTERNAL: Prepare the mechanism.


registerResultInUnitOfWork

public java.lang.Object registerResultInUnitOfWork(java.lang.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.

Specified by:
registerResultInUnitOfWork in class ObjectLevelReadQuery
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

remoteExecute

public java.lang.Object remoteExecute()
INTERNAL: Execute the query through remote session.

Overrides:
remoteExecute in class DatabaseQuery

replaceValueHoldersIn

public java.util.Map replaceValueHoldersIn(java.lang.Object object,
                                           org.eclipse.persistence.internal.sessions.remote.RemoteSessionController controller)
INTERNAL: replace the value holders in the specified result object(s)

Overrides:
replaceValueHoldersIn in class DatabaseQuery

setBatchReadAttributeExpressions

public void setBatchReadAttributeExpressions(java.util.Vector batchReadAttributeExpressions)
INTERNAL: Return all attributes specified for batch reading.


setContainerPolicy

public void setContainerPolicy(org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy)
PUBLIC: Set the container policy. Used to support different containers (e.g. Collections, Maps).


setHierarchicalQueryClause

public void setHierarchicalQueryClause(Expression startWith,
                                       Expression connectBy,
                                       java.util.Vector orderSiblingsExpressions)
PUBLIC: Set the Hierarchical Query Clause for the query

Example:

Expression startWith = builder.get("id").equal(new Integer(100)); //can be any expression which identifies a set of employees

Expression connectBy = builder.get("managedEmployees"); //indicated the relationship that the hierarchy is based on, must be self-referential

Vector orderBy = new Vector();

orderBy.addElement(builder.get("startDate"));

readAllQuery.setHierarchicalQueryClause(startWith, connectBy, orderBy);

This query would generate SQL like this:

SELECT * FROM EMPLOYEE START WITH ID=100 CONNECT BY PRIOR ID = MANAGER_ID ORDER SIBLINGS BY START_DATE

Parameters:
startWith - Describes the START WITH clause of the query - null if not needed
connectBy - This should be a query key expression which indicates an attribute who's mapping describes the hierarchy
orderSiblingsExpressions - Contains expressions which indicate fields to be included in the ORDER SIBLINGS BY clause - null if not required

useCollectionClass

public void useCollectionClass(java.lang.Class concreteClass)
PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects.

jdk1.2.x: The container class must implement (directly or indirectly) the Collection interface.

jdk1.1.x: The container class must be a subclass of Vector.


useCursoredStream

public void useCursoredStream()
PUBLIC: Use a CursoredStream as the result collection. The initial read size is 10 and page size is 5.


useCursoredStream

public void useCursoredStream(int initialReadSize,
                              int pageSize)
PUBLIC: Use a CursoredStream as the result collection.

Parameters:
initialReadSize - the initial number of objects to read
pageSize - the number of objects to read when more objects are needed from the database

useCursoredStream

public void useCursoredStream(int initialReadSize,
                              int pageSize,
                              ValueReadQuery sizeQuery)
PUBLIC: Use a CursoredStream as the result collection.

Parameters:
initialReadSize - the initial number of objects to read
pageSize - the number of objects to read when more objects are needed from the database
sizeQuery - a query that will return the size of the result set; this must be set if an expression is not used (i.e. custom SQL)

useMapClass

public void useMapClass(java.lang.Class concreteClass,
                        java.lang.String methodName)
PUBLIC: Configure the query to use an instance of the specified container class to hold the result objects. The key used to index the value in the Map is the value returned by a call to the specified zero-argument method. The method must be implemented by the class (or a superclass) of the value to be inserted into the Map.

jdk1.2.x: The container class must implement (directly or indirectly) the Map interface.

jdk1.1.x: The container class must be a subclass of Hashtable.

The referenceClass must set before calling this method.


useScrollableCursor

public void useScrollableCursor()
PUBLIC: Use a ScrollableCursor as the result collection.


useScrollableCursor

public void useScrollableCursor(int pageSize)
PUBLIC: Use a ScrollableCursor as the result collection.

Parameters:
pageSize - the number of elements to be read into a the cursor when more elements are needed from the database.

useScrollableCursor

public void useScrollableCursor(ScrollableCursorPolicy policy)
PUBLIC: Use a ScrollableCursor as the result collection.

Parameters:
policy - the scrollable cursor policy allows for additional result set options. Example:

ScrollableCursorPolicy policy = new ScrollableCursorPolicy()

policy.setResultSetType(ScrollableCursorPolicy.TYPE_SCROLL_INSENSITIVE);

query.useScrollableCursor(policy);


computeBatchReadMappingQueries

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


computeNestedQueriesForBatchReadExpressions

protected void computeNestedQueriesForBatchReadExpressions(java.util.Vector batchReadExpressions)
INTERNAL: This method is used when computing the nested queries for batch read mappings. It recurses computing the nested mapping queries.


EclipseLink 2.0.0, build 'v20091127-r5931' API Reference