|
EclipseLink 1.1.1_ 1.1.1.v20090430-r4097 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.persistence.queries.DatabaseQuery org.eclipse.persistence.queries.ReadQuery org.eclipse.persistence.queries.ObjectBuildingQuery org.eclipse.persistence.queries.ObjectLevelReadQuery org.eclipse.persistence.queries.ReadAllQuery
public class ReadAllQuery
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
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 |
orderByExpressions
Used for ordering support. |
protected java.util.Vector |
orderSiblingsByExpressions
|
protected Expression |
startWithExpression
Used for Oracle HierarchicalQuery support |
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 |
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 |
addDescendingOrdering(java.lang.String queryKeyName)
PUBLIC: Order the query results by the object's attribute or query key name. |
void |
addOrdering(Expression orderingExpression)
PUBLIC: Add the ordering expression. |
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 |
getOrderByExpressions()
INTERNAL: Return the order expressions for the query. |
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 |
hasOrderByExpressions()
INTERNAL: The order bys are lazy initialized to conserve space. |
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 |
setOrderByExpressions(java.util.Vector orderByExpressions)
INTERNAL: Set the order expressions for the query. |
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.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 java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Vector orderByExpressions
protected java.util.Vector batchReadAttributeExpressions
protected transient java.util.Map batchReadMappingQueries
protected java.util.List batchReadAttributes
protected org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy
protected Expression startWithExpression
protected Expression connectByExpression
protected java.util.Vector orderSiblingsByExpressions
Constructor Detail |
---|
public ReadAllQuery()
public ReadAllQuery(java.lang.Class classToRead)
public ReadAllQuery(java.lang.Class classToRead, Expression selectionCriteria)
public ReadAllQuery(java.lang.Class classToRead, ExpressionBuilder builder)
public ReadAllQuery(java.lang.Class classToRead, Call call)
public ReadAllQuery(java.lang.Object exampleObject, QueryByExamplePolicy policy)
public ReadAllQuery(ExpressionBuilder builder)
public ReadAllQuery(Call call)
Method Detail |
---|
public void addAscendingOrdering(java.lang.String queryKeyName)
public void addBatchReadAttribute(java.lang.String attributeName)
Example: query.addBatchReadAttribute("phoneNumbers")
addBatchReadAttribute(Expression)
,
ObjectLevelReadQuery.addJoinedAttribute(String)
public void addBatchReadAttribute(Expression attributeExpression)
Example: query.addBatchReadAttribute(query.getExpressionBuilder().get("policies").get("claims"))
ObjectLevelReadQuery.addJoinedAttribute(String)
public void addDescendingOrdering(java.lang.String queryKeyName)
public void addOrdering(Expression orderingExpression)
public void cacheResult(java.lang.Object unwrappedOriginal)
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.
cacheResult
in class ReadQuery
protected java.lang.Object checkEarlyReturnImpl(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
checkEarlyReturnImpl
in class ObjectLevelReadQuery
protected DatabaseQuery checkForCustomQuery(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow)
checkForCustomQuery
in class DatabaseQuery
public java.lang.Object clone()
clone
in class ObjectLevelReadQuery
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)
public java.lang.Object execute(org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord row) throws DatabaseException
execute
in class ObjectLevelReadQuery
session
- - the session in which the receiver will be executed.
DatabaseException
- - an error has occurred on the databaseprotected java.lang.Object executeObjectLevelReadQuery() throws DatabaseException
executeObjectLevelReadQuery
in class ObjectLevelReadQuery
DatabaseException
- - an error has occurred on the databaseprotected java.lang.Object executeObjectLevelReadQueryFromResultSet() throws DatabaseException
executeObjectLevelReadQueryFromResultSet
in class ObjectLevelReadQuery
DatabaseException
- - an error has occurred on the databasepublic java.lang.Object extractRemoteResult(org.eclipse.persistence.internal.sessions.remote.Transporter transporter)
extractRemoteResult
in class DatabaseQuery
public java.util.Vector getBatchReadAttributeExpressions()
public org.eclipse.persistence.internal.queries.ContainerPolicy getContainerPolicy()
protected QueryRedirector getDefaultRedirector()
getDefaultRedirector
in class DatabaseQuery
public Expression getStartWithExpression()
public Expression getConnectByExpression()
public java.util.Vector getOrderSiblingsByExpressions()
public java.util.Vector getOrderByExpressions()
public boolean hasOrderByExpressions()
public boolean hasHierarchicalExpressions()
public boolean hasBatchReadAttributes()
public boolean isAttributeBatchRead(java.lang.String attributeName)
public boolean isAttributeBatchRead(ClassDescriptor mappingDescriptor, java.lang.String attributeName)
public java.util.Map getBatchReadMappingQueries()
protected void setBatchReadMappingQueries(java.util.Map batchReadMappingQueries)
public boolean isDefaultPropertiesQuery()
isDefaultPropertiesQuery
in class ObjectLevelReadQuery
public boolean equals(java.lang.Object object)
equals
in class ObjectLevelReadQuery
public boolean isReadAllQuery()
isReadAllQuery
in class DatabaseQuery
protected void prepare() throws QueryException
prepare
in class ObjectLevelReadQuery
QueryException
public void prepareFromQuery(DatabaseQuery query)
prepareFromQuery
in class ObjectLevelReadQuery
protected void prepareCustomQuery(DatabaseQuery customQuery)
prepareCustomQuery
in class DatabaseQuery
public void prepareForExecution() throws QueryException
prepareForExecution
in class ReadQuery
QueryException
protected void prepareSelectAllRows()
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)
Involves registering the query result individually and in totality, and hence refreshing / conforming is done here.
registerResultInUnitOfWork
in class ObjectLevelReadQuery
result
- may be collection (read all) or an object (read one),
or even a cursor. If in transaction the shared cache will
be bypassed, meaning the result may not be originals from the parent
but raw database rows.unitOfWork
- the unitOfWork the result is being registered in.arguments
- the original arguments/parameters passed to the query
execution. Used by conformingbuildDirectlyFromRows
- If in transaction must construct
a registered result from raw database rows.
public java.lang.Object remoteExecute()
remoteExecute
in class DatabaseQuery
public java.util.Map replaceValueHoldersIn(java.lang.Object object, org.eclipse.persistence.internal.sessions.remote.RemoteSessionController controller)
replaceValueHoldersIn
in class DatabaseQuery
public void setBatchReadAttributeExpressions(java.util.Vector batchReadAttributeExpressions)
public void setContainerPolicy(org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy)
public void setHierarchicalQueryClause(Expression startWith, Expression connectBy, java.util.Vector orderSiblingsExpressions)
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
startWith
- Describes the START WITH clause of the query - null if not neededconnectBy
- This should be a query key expression which indicates an attribute who's mapping describes the hierarchyorderSiblingsExpressions
- Contains expressions which indicate fields to be included in the ORDER SIBLINGS BY clause - null if not requiredpublic void setOrderByExpressions(java.util.Vector orderByExpressions)
public void useCollectionClass(java.lang.Class concreteClass)
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.
public void useCursoredStream()
public void useCursoredStream(int initialReadSize, int pageSize)
initialReadSize
- the initial number of objects to readpageSize
- the number of objects to read when more objects
are needed from the databasepublic void useCursoredStream(int initialReadSize, int pageSize, ValueReadQuery sizeQuery)
initialReadSize
- the initial number of objects to readpageSize
- the number of objects to read when more objects
are needed from the databasesizeQuery
- 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)public void useMapClass(java.lang.Class concreteClass, java.lang.String methodName)
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.
public void useScrollableCursor()
public void useScrollableCursor(int pageSize)
pageSize
- the number of elements to be read into a the cursor
when more elements are needed from the database.public void useScrollableCursor(ScrollableCursorPolicy policy)
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);
public void computeBatchReadMappingQueries()
protected void computeNestedQueriesForBatchReadExpressions(java.util.Vector batchReadExpressions)
|
EclipseLink 1.1.1_ 1.1.1.v20090430-r4097 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |