Oracle Application Server TopLink API Reference
10g Release 2 (10.1.2)

B15903-01


oracle.toplink.queryframework
Class ReportQuery

java.lang.Object
  extended byoracle.toplink.queryframework.DatabaseQuery
      extended byoracle.toplink.queryframework.ReadQuery
          extended byoracle.toplink.queryframework.ObjectLevelReadQuery
              extended byoracle.toplink.queryframework.ReadAllQuery
                  extended byoracle.toplink.queryframework.ReportQuery

All Implemented Interfaces:
java.lang.Cloneable, oracle.toplink.internal.helper.FalseUndefinedTrue, java.io.Serializable

public class ReportQuery
extends ReadAllQuery

Purpose: Query for information about a set of objects instead of the objects themselves. This supports select single attributes, nested attributes, aggregation functions and group bys.

Attribute Types:

  1. addAttribute("directQueryKey") is a short cut method to add an attribute with the same name as its corresponding direct query key.
  2. addAttribute("attributeName", expBuilder.get("oneToOneMapping").get("directQueryKey")) is the full approach for get values through joined 1:1 relationships.
  3. addAttribute("attributeName", expBuilder.getField("TABLE.FIELD")) allows the addition of raw values or values which were not mapped in the object model directly (i.e. FK attributes).
  4. addAttribute("attributeName", null) Leave a place holder (NULL) value in the result (used for included values from other systems or calculated values).

Retrieving Primary Keys: It is possble to retrieve the primary key raw values within each result, but stored in a separate (internal) vector. This primary key vector can later be used to retrieve the real object.

Since:
TOPLink/Java 2.0
See Also:
retrievePrimaryKeys(), If the values are wanted in the result array then they must be added as attributes. For primary keys which are not mapped directly you can add them as DatabaseFields (see above)., Serialized Form

Field Summary

Fields inherited from class oracle.toplink.queryframework.ObjectLevelReadQuery
CheckCacheByExactPrimaryKey, CheckCacheByPrimaryKey, CheckCacheOnly, CheckCacheThenDatabase, ConformResultsInUnitOfWork, DoNotCheckCache, DONT_USE_DISTINCT, inMemoryQueryIndirectionPolicy, LOCK, LOCK_NOWAIT, NO_LOCK, UNCOMPUTED_DISTINCT, USE_DISTINCT, UseDescriptorSetting

Fields inherited from class oracle.toplink.queryframework.DatabaseQuery
CascadeAggregateDelete, CascadeAllParts, CascadeDependentParts, CascadePrivateParts, NoCascading, QUERY_PREPARE

Constructor Summary
ReportQuery(java.lang.Class javaClass, Expression expression)
ReportQuery(java.lang.Class javaClass, ExpressionBuilder builder)
PUBLIC: The report query is require to be constructor with an expression builder.
ReportQuery(ExpressionBuilder builder)
PUBLIC: The report query is require to be constructor with an expression builder.

Method Summary
void addAttribute(java.lang.String itemName)
PUBLIC: Add the attribute from the reference class to be included in the result.
void addAttribute(java.lang.String itemName, Expression attributeExpression)
PUBLIC: Add the attribute to be included in the result.
void addAverage(java.lang.String itemName)
PUBLIC: Add the average value of the attribute to be included in the result.
void addAverage(java.lang.String itemName, Expression attributeExpression)
PUBLIC: Add the average value of the attribute to be included in the result.
void addCount()
PUBLIC: Add the count of the size of the result to be included in the result.
void addCount(java.lang.String itemName)
PUBLIC: Add the count of the size of the result to be included in the result.
void addCount(java.lang.String itemName, Expression attributeExpression)
PUBLIC: Add the count of the size of the result to be included in the result.
void addFunctionItem(java.lang.String itemName, Expression attributeExpression, java.lang.String functionName)
ADVANCED: Add the function against the attribute expression to be included in the result.
void addGrouping(Expression expression)
PUBLIC: Add the attribute expression to the group by expressions.
void addGrouping(java.lang.String attributeName)
PUBLIC: Add the attribute to the group by expressions.
void addItem(java.lang.String itemName, Expression attributeExpression)
ADVANCED: Add the expression value to be included in the result.
void addMaximum(java.lang.String itemName)
PUBLIC: Add the maximum value of the attribute to be included in the result.
void addMaximum(java.lang.String itemName, Expression attributeExpression)
PUBLIC: Add the maximum value of the attribute to be included in the result.
void addMinimum(java.lang.String itemName)
PUBLIC: Add the minimum value of the attribute to be included in the result.
void addMinimum(java.lang.String itemName, Expression attributeExpression)
PUBLIC: Add the minimum value of the attribute to be included in the result.
void addStandardDeviation(java.lang.String itemName)
PUBLIC: Add the standard deviation value of the attribute to be included in the result.
void addStandardDeviation(java.lang.String itemName, Expression attributeExpression)
PUBLIC: Add the standard deviation value of the attribute to be included in the result.
void addSum(java.lang.String itemName)
PUBLIC: Add the sum value of the attribute to be included in the result.
void addSum(java.lang.String itemName, Expression attributeExpression)
PUBLIC: Add the sum value of the attribute to be included in the result.
void addVariance(java.lang.String itemName)
PUBLIC: Add the variance value of the attribute to be included in the result.
void addVariance(java.lang.String itemName, Expression attributeExpression)
PUBLIC: Add the variance value of the attribute to be included in the result.
void dontRetrievePrimaryKeys()
PUBLIC: Set if the query results should contain the primary keys or each associated object.
void dontReturnSingleAttribute()
PUBLIC: Don't simplify the result by returning the single attribute.
void dontReturnSingleResult()
PUBLIC: Simplifies the result by only returning the first result.
void dontReturnSingleValue()
PUBLIC: Simplifies the result by only returning a single value.
boolean isReportQuery()
PUBLIC: Return if this is a report query.
void retrievePrimaryKeys()
PUBLIC: Set if the query results should contain the primary keys or each associated object.
void returnSingleAttribute()
PUBLIC: Simplify the result by returning a single attribute.
void returnSingleResult()
PUBLIC: Simplifies the result by only returning the first result.
void returnSingleValue()
PUBLIC: Simplifies the result by only returning a single value.
void setShouldRetrievePrimaryKeys(boolean shouldRetrievePrimaryKeys)
PUBLIC: Set if the query results should contain the primary keys or each associated object.
void setShouldReturnSingleAttribute(boolean newChoice)
PUBLIC: Simplifies the result by only returning the attribute (as opposed to wrapping in a ReportQueryResult).
void setShouldReturnSingleResult(boolean newChoice)
PUBLIC: Simplifies the result by only returning the first result.
void setShouldReturnSingleValue(boolean newChoice)
PUBLIC: Simplifies the result by only returning a single value.
boolean shouldCacheQueryResults()
PUBLIC: Report query results are never cached.
boolean shouldRetrievePrimaryKeys()
PUBLIC: Return if the query results should contain the primary keys or each associated object.
boolean shouldReturnSingleAttribute()
PUBLIC: Answer if we are only returning the attribute (as opposed to wrapping in a ReportQueryResult).
boolean shouldReturnSingleResult()
PUBLIC: Simplifies the result by only returning the first result.
boolean shouldReturnSingleValue()
PUBLIC: Simplifies the result by only returning a single value.

Methods inherited from class oracle.toplink.queryframework.ReadAllQuery
addAscendingOrdering, addBatchReadAttribute, addBatchReadAttribute, addDescendingOrdering, addOrdering, dontUseCursoredStream, getConnectByExpression, getCursorPageAmount, getCursorThreshold, getOrderSiblingsByExpressions, getStartWithExpression, isReadAllQuery, remoteExecute, setContainerPolicy, setCursorPageAmount, setCursorThreshold, setHierarchicalQueryClause, setUsesCursoredStream, useCollectionClass, useCursoredStream, useCursoredStream, useCursoredStream, useMapClass, useScrollableCursor, useScrollableCursor, useScrollableCursor

Methods inherited from class oracle.toplink.queryframework.ObjectLevelReadQuery
acquireLocks, acquireLocksWithoutWaiting, addJoinedAttribute, addJoinedAttribute, addPartialAttribute, addPartialAttribute, checkCacheOnly, conformResultsInUnitOfWork, dontAcquireLocks, dontCheckCache, dontRefreshIdentityMapResult, dontRefreshRemoteIdentityMapResult, dontUseDistinct, getCacheUsage, getDistinctState, getExampleObject, getExpressionBuilder, getInMemoryQueryIndirectionPolicy, getLockMode, getQueryByExamplePolicy, getReferenceClass, hasJoinedMappings, isLockQuery, isObjectLevelReadQuery, refreshIdentityMapResult, refreshRemoteIdentityMapResult, resetDistinct, setCacheUsage, setDistinctState, setExampleObject, setInMemoryQueryIndirectionPolicy, setLockMode, setQueryByExamplePolicy, setReferenceClass, setShouldRefreshIdentityMapResult, setShouldRefreshRemoteIdentityMapResult, shouldCheckCacheOnly, shouldCheckDescriptorForCacheUsage, shouldConformResultsInUnitOfWork, shouldRefreshIdentityMapResult, shouldRefreshRemoteIdentityMapResult, toString, useDistinct

Methods inherited from class oracle.toplink.queryframework.ReadQuery
cacheQueryResults, clearQueryResults, doNotCacheQueryResults, getMaxRows, isReadQuery, setMaxRows, setShouldCacheQueryResults

Methods inherited from class oracle.toplink.queryframework.DatabaseQuery
addArgument, addArgument, addArgument, addArgumentValue, addArgumentValues, addCall, addStatement, bindAllParameters, cacheStatement, cascadeAllParts, cascadePrivateParts, dontBindAllParameters, dontCacheStatement, dontCascadeParts, dontMaintainCache, getCall, getEJBQLString, getHintString, getName, getQueryTimeout, getRedirector, getSelectionCriteria, getSessionName, getSQLStatement, getSQLString, getTranslatedSQLString, hasSessionName, ignoreBindAllParameters, ignoreCacheStatement, isCallQuery, isDataModifyQuery, isDataReadQuery, isDeleteObjectQuery, isExpressionQuery, isModifyQuery, isObjectLevelModifyQuery, isReadObjectQuery, isSQLCallQuery, isWriteObjectQuery, maintainCache, prepareCall, setCall, setEJBQLString, setHintString, setName, setQueryTimeout, setRedirector, setSelectionCriteria, setSessionName, setShouldBindAllParameters, setShouldCacheStatement, setShouldMaintainCache, setShouldPrepare, setShouldUseWrapperPolicy, setSQLStatement, setSQLString, shouldBindAllParameters, shouldCacheStatement, shouldCascadeAllParts, shouldCascadeParts, shouldCascadePrivateParts, shouldIgnoreBindAllParameters, shouldIgnoreCacheStatement, shouldMaintainCache, shouldPrepare, shouldUseWrapperPolicy

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail

ReportQuery

public ReportQuery(java.lang.Class javaClass,
                   Expression expression)

ReportQuery

public ReportQuery(java.lang.Class javaClass,
                   ExpressionBuilder builder)
PUBLIC: The report query is require to be constructor with an expression builder. This build must be used for the selection critiera, any item expressions, group bys and order bys.

ReportQuery

public ReportQuery(ExpressionBuilder builder)
PUBLIC: The report query is require to be constructor with an expression builder. This build must be used for the selection critiera, any item expressions, group bys and order bys.

Method Detail

addAttribute

public void addAttribute(java.lang.String itemName)
PUBLIC: Add the attribute from the reference class to be included in the result. EXAMPLE: reportQuery.addAttribute("firstName");

addAttribute

public void addAttribute(java.lang.String itemName,
                         Expression attributeExpression)
PUBLIC: Add the attribute to be included in the result. EXAMPLE: reportQuery.addAttribute("city", expBuilder.get("address").get("city"));

addAverage

public void addAverage(java.lang.String itemName)
PUBLIC: Add the average value of the attribute to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addAverage("salary");

addAverage

public void addAverage(java.lang.String itemName,
                       Expression attributeExpression)
PUBLIC: Add the average value of the attribute to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addAverage("managerSalary", expBuilder.get("manager").get("salary"));

addCount

public void addCount()
PUBLIC: Add the count of the size of the result to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addCount();

addCount

public void addCount(java.lang.String itemName)
PUBLIC: Add the count of the size of the result to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addCount("id");

addCount

public void addCount(java.lang.String itemName,
                     Expression attributeExpression)
PUBLIC: Add the count of the size of the result to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addCount("id", expBuilder.get("id"));

addFunctionItem

public void addFunctionItem(java.lang.String itemName,
                            Expression attributeExpression,
                            java.lang.String functionName)
ADVANCED: Add the function against the attribute expression to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. Example: reportQuery.addFunctionItem("average", expBuilder.get("salary"), "average");

addGrouping

public void addGrouping(java.lang.String attributeName)
PUBLIC: Add the attribute to the group by expressions. This will group the result set on that attribute and is normally used in conjunction with aggregation functions. Example: reportQuery.addGrouping("lastName")

addGrouping

public void addGrouping(Expression expression)
PUBLIC: Add the attribute expression to the group by expressions. This will group the result set on that attribute and is normally used in conjunction with aggregation functions. Example: reportQuery.addGrouping(expBuilder.get("address").get("country"))

addItem

public void addItem(java.lang.String itemName,
                    Expression attributeExpression)
ADVANCED: Add the expression value to be included in the result. EXAMPLE: reportQuery.addItem("name", expBuilder.get("firstName").toUpperCase());

addMaximum

public void addMaximum(java.lang.String itemName)
PUBLIC: Add the maximum value of the attribute to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addMaximum("salary");

addMaximum

public void addMaximum(java.lang.String itemName,
                       Expression attributeExpression)
PUBLIC: Add the maximum value of the attribute to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addMaximum("managerSalary", expBuilder.get("manager").get("salary"));

addMinimum

public void addMinimum(java.lang.String itemName)
PUBLIC: Add the minimum value of the attribute to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addMinimum("salary");

addMinimum

public void addMinimum(java.lang.String itemName,
                       Expression attributeExpression)
PUBLIC: Add the minimum value of the attribute to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addMinimum("managerSalary", expBuilder.get("manager").get("salary"));

addStandardDeviation

public void addStandardDeviation(java.lang.String itemName)
PUBLIC: Add the standard deviation value of the attribute to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addStandardDeviation("salary");

addStandardDeviation

public void addStandardDeviation(java.lang.String itemName,
                                 Expression attributeExpression)
PUBLIC: Add the standard deviation value of the attribute to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addStandardDeviation("managerSalary", expBuilder.get("manager").get("salary"));

addSum

public void addSum(java.lang.String itemName)
PUBLIC: Add the sum value of the attribute to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addSum("salary");

addSum

public void addSum(java.lang.String itemName,
                   Expression attributeExpression)
PUBLIC: Add the sum value of the attribute to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addSum("managerSalary", expBuilder.get("manager").get("salary"));

addVariance

public void addVariance(java.lang.String itemName)
PUBLIC: Add the variance value of the attribute to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addVariance("salary");

addVariance

public void addVariance(java.lang.String itemName,
                        Expression attributeExpression)
PUBLIC: Add the variance value of the attribute to be included in the result. Aggregation functions can be used with a group by, or on the entire result set. EXAMPLE: reportQuery.addVariance("managerSalary", expBuilder.get("manager").get("salary"));

dontRetrievePrimaryKeys

public void dontRetrievePrimaryKeys()
PUBLIC: Set if the query results should contain the primary keys or each associated object. This make retrieving the real object easier. By default they are not retrieved.

dontReturnSingleAttribute

public void dontReturnSingleAttribute()
PUBLIC: Don't simplify the result by returning the single attribute. Wrap in a ReportQueryResult.

dontReturnSingleResult

public void dontReturnSingleResult()
PUBLIC: Simplifies the result by only returning the first result. This can be used if it known that only one row is returned by the report query.

dontReturnSingleValue

public void dontReturnSingleValue()
PUBLIC: Simplifies the result by only returning a single value. This can be used if it known that only one row is returned by the report query and only a single item is added to the report.

isReportQuery

public boolean isReportQuery()
PUBLIC: Return if this is a report query.
Overrides:
isReportQuery in class DatabaseQuery

retrievePrimaryKeys

public void retrievePrimaryKeys()
PUBLIC: Set if the query results should contain the primary keys or each associated object. This make retrieving the real object easier. By default they are not retrieved.

returnSingleAttribute

public void returnSingleAttribute()
PUBLIC: Simplify the result by returning a single attribute. Don't wrap in a ReportQueryResult.

returnSingleResult

public void returnSingleResult()
PUBLIC: Simplifies the result by only returning the first result. This can be used if it known that only one row is returned by the report query.

returnSingleValue

public void returnSingleValue()
PUBLIC: Simplifies the result by only returning a single value. This can be used if it known that only one row is returned by the report query and only a single item is added to the report.

setShouldRetrievePrimaryKeys

public void setShouldRetrievePrimaryKeys(boolean shouldRetrievePrimaryKeys)
PUBLIC: Set if the query results should contain the primary keys or each associated object. This make retrieving the real object easier. By default they are not retrieved.

setShouldReturnSingleAttribute

public void setShouldReturnSingleAttribute(boolean newChoice)
PUBLIC: Simplifies the result by only returning the attribute (as opposed to wrapping in a ReportQueryResult). This can be used if it is known that only one attribute is returned by the report query.

setShouldReturnSingleResult

public void setShouldReturnSingleResult(boolean newChoice)
PUBLIC: Simplifies the result by only returning the first result. This can be used if it known that only one row is returned by the report query.

setShouldReturnSingleValue

public void setShouldReturnSingleValue(boolean newChoice)
PUBLIC: Simplifies the result by only returning a single value. This can be used if it known that only one row is returned by the report query and only a single item is added to the report.

shouldCacheQueryResults

public boolean shouldCacheQueryResults()
PUBLIC: Report query results are never cached.
Overrides:
shouldCacheQueryResults in class ReadQuery

shouldRetrievePrimaryKeys

public boolean shouldRetrievePrimaryKeys()
PUBLIC: Return if the query results should contain the primary keys or each associated object. This make retrieving the real object easier.

shouldReturnSingleAttribute

public boolean shouldReturnSingleAttribute()
PUBLIC: Answer if we are only returning the attribute (as opposed to wrapping in a ReportQueryResult). This can be used if it is known that only one attribute is returned by the report query.

shouldReturnSingleResult

public boolean shouldReturnSingleResult()
PUBLIC: Simplifies the result by only returning the first result. This can be used if it known that only one row is returned by the report query.

shouldReturnSingleValue

public boolean shouldReturnSingleValue()
PUBLIC: Simplifies the result by only returning a single value. This can be used if it known that only one row is returned by the report query and only a single item is added to the report.

Copyright © 1998, 2005 Oracle Corporation. All Rights Reserved.