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

B15903-01


oracle.toplink.jdo
Class JDOQuery

java.lang.Object
  extended byoracle.toplink.jdo.JDOQuery

All Implemented Interfaces:
javax.jdo.Query, java.io.Serializable

public class JDOQuery
extends java.lang.Object
implements javax.jdo.Query

PROTOTYPE: JDO wrapper for a TopLink query.

See Also:
Serialized Form

Constructor Summary
JDOQuery(JDOPersistenceManager manager)
JDOQuery constructor comment.

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 addArgument(java.lang.String argumentName)
PUBLIC: Add the argument named argumentName.
void addAscendingOrdering(java.lang.String queryKeyName)
PUBLIC: Order the query results by the object's attribute or query key name.
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 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 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 addDescendingOrdering(java.lang.String queryKeyName)
PUBLIC: Order the query results by the object's attribute or query key name.
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 addJoinedAttribute(Expression attributeExpression)
PUBLIC: Specify the one-to-one mapped attribute to be optimized in this query.
void addJoinedAttribute(java.lang.String attributeName)
PUBLIC: Specify the one-to-one mapped attribute to be optimized in this query.
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 addOrdering(Expression orderingExpression)
PUBLIC: Add the ordering expression.
void addPartialAttribute(Expression attributeExpression)
PUBLIC: Specify that only a subset of the class' attributes be selected in this query.
void addPartialAttribute(java.lang.String attributeName)
PUBLIC: Specify that only a subset of the class' attributes be selected in this query.
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 asReadAllQuery()
PUBLIC: Reset the TOPLink query to be a new ReadAllQuery.
void asReadObjectQuery()
PUBLIC: Reset the TOPLink query to be a new ReadObjectQuery.
void asReportQuery()
PUBLIC: Reset the TOPLink query to be a new ReportQuery.
void bindAllParameters()
Bind all arguments to any SQL statement.
void cacheStatement()
Cache the prepared statements, this requires full parameter binding as well.
void cascadeAllParts()
PUBLIC: Cascade the query and its properties on the queries object(s) and all objects related to the queries object(s).
void cascadePrivateParts()
PUBLIC: Cascade the query and its properties on the queries object(s) and all privately owned objects related to the queries object(s).
void checkCacheByExactPrimaryKey()
PUBLIC: The cache will be checked only if the query contains exactly the primary key.
void checkCacheByPrimaryKey()
PUBLIC: This is the default, the cache will be checked only if the query contains the primary key.
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 checkCacheThenDatabase()
PUBLIC: The cache will be checked completely, then if the object is not found or the query too complex the database will be queried.
void close(java.lang.Object queryResult)
Close a query result and release any resources associated with it.
void closeAll()
Close all query results associated with this Query instance, and release all resources associated with them.
void compile()
Verify the elements of the query and provide a hint to the query to prepare and optimize an execution plan.
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 declareImports(java.lang.String arg1)
Set the import statements to be used to identify the fully qualified name of variables or parameters.
void declareParameters(java.lang.String parameters)
Declare the list of parameters query execution.
void declareVariables(java.lang.String arg1)
Declare the unbound variables to be used in the query.
void dontAcquireLocks()
PUBLIC: Set the query not to lock.
void dontBindAllParameters()
Do not Bind all arguments to any SQL statement.
void dontCacheStatement()
Dont cache the prepared statements, this requires full parameter binding as well.
void dontCascadeParts()
PUBLIC: Do not cascade the query and its properties on the queries object(s) relationships.
void dontCheckCache()
PUBLIC: This can be used to explicitly disable the cache hit.
void dontMaintainCache()
PUBLIC: Set for the identity map (cache) to be ignored completely.
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.
java.lang.Object execute()
Execute the query and return the filtered Collection.
java.lang.Object execute(java.lang.Object arg1)
Execute the query and return the filtered Collection.
java.lang.Object execute(java.lang.Object arg1, java.lang.Object arg2)
Execute the query and return the filtered Collection.
java.lang.Object execute(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
Execute the query and return the filtered Collection.
java.lang.Object executeWithArray(java.lang.Object[] arg1)
Execute the query and return the filtered Collection.
java.lang.Object executeWithMap(java.util.Map arg1)
Execute the query and return the filtered Collection.
oracle.toplink.internal.databaseaccess.DatabaseCall getCall()
ADVANCED: Return the call for this query.
java.lang.Object getExampleObject()
PUBLIC: This method returns the current example object.
ExpressionBuilder getExpressionBuilder()
Return the query's expression builder.
boolean getIgnoreCache()
Get the ignoreCache option setting.
javax.jdo.PersistenceManager getPersistenceManager()
Get the PersistenceManager associated with this Query.
DatabaseQuery getQuery()
Return the associated TopLink query.
int getQueryTimeout()
PUBLIC: Return the number of seconds the driver will wait for a Statement to execute to the given number of seconds.
ReadAllQuery getReadAllQuery()
Return the associated TopLink ReadAllQuery.
ReadObjectQuery getReadObjectQuery()
Return the associated TopLink ReadObjectQuery.
java.lang.Class getReferenceClass()
PUBLIC: Return the domain class associated with this query.
ReportQuery getReportQuery()
Return the associated TopLink ReportQuery.
Expression getSelectionCriteria()
PUBLIC: Return the selection criteria of the query.
void maintainCache()
PUBLIC: Set for the identity map (cache) to be maintained.
void refreshIdentityMapResult()
PUBLIC: Refresh the attributes of the object(s) resulting from the query.
void setCall(Call call)
PUBLIC: Used to define a store procedure or SQL query.
void setCandidates(java.util.Collection arg1)
Set the candidate Collection to query.
void setCandidates(javax.jdo.Extent arg1)
Set the candidate Extent to query.
void setClass(java.lang.Class queryClass)
Set the class of the candidate instances of the query.
void setEJBQLString(java.lang.String ejbqlString)
Set the filter to an EJBQL string.
void setFilter(Expression selectionCriteria)
Set the filter to a TopLink expression.
void setFilter(java.lang.String arg1)
JDO-QL is not currently supported.
void setIgnoreCache(boolean shouldMaintainCache)
Sets maintainCache in the TopLink query, if set this will by-pass the cache.
void setOrdering(java.lang.String attribute)
The JDO order clause is not currently supported.
void setQuery(DatabaseQuery newQuery)
Set the associated TopLink query.
void setQueryByExampleFilter(java.lang.Object exampleObject)
Set the filter based on the query by example object.
void setQueryByExamplePolicy(QueryByExamplePolicy newPolicy)
PUBLIC: Policy, an instance of oracle.toplink.queryframework.QueryByExamplePolicy, is a useful tool to customising the query when Query By Example is used.
void setQueryTimeout(int queryTimeout)
PUBLIC: Set the number of seconds the driver will wait for a Statement to execute to the given number of seconds.
void setShouldBindAllParameters(boolean shouldBindAllParameters)
Bind all arguments to any SQL statement.
void setShouldCacheStatement(boolean shouldCacheStatement)
Cache the prepared statements, this requires full parameter binding as well.
void setShouldMaintainCache(boolean shouldMaintainCache)
PUBLIC: Set if the identity map (cache) should be used or not.
void setShouldRefreshIdentityMapResult(boolean shouldRefreshIdentityMapResult)
PUBLIC: Set if the attributes of the object(s) resulting from the query should be refreshed.
void setSQLString(java.lang.String sqlString)
PUBLIC: To any user of this object.
boolean shouldBindAllParameters()
Bind all arguments to any SQL statement.
boolean shouldCacheStatement()
Cache the prepared statements, this requires full parameter binding as well.
boolean shouldCascadeAllParts()
PUBLIC: Flag used to determine if all parts should be cascaded
boolean shouldCascadeParts()
PUBLIC: Flag used to determine if any parts should be cascaded
boolean shouldCascadePrivateParts()
PUBLIC: Flag used to determine if any private parts should be cascaded
boolean shouldMaintainCache()
PUBLIC: Return if the identity map (cache) should be used or not.
boolean shouldRefreshIdentityMapResult()
PUBLIC: Set to a boolean.
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 useDistinct()
ADVANCED: If a distinct has been set the DISTINCT clause will be printed.
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.

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

Constructor Detail

JDOQuery

public JDOQuery(JDOPersistenceManager manager)
JDOQuery constructor comment.

Method Detail

compile

public void compile()
Verify the elements of the query and provide a hint to the query to prepare and optimize an execution plan.
Specified by:
compile in interface javax.jdo.Query

declareImports

public void declareImports(java.lang.String arg1)
Set the import statements to be used to identify the fully qualified name of variables or parameters. Parameters and unbound variables might come from a different class from the candidate class, and the names need to be declared in an import statement to eliminate ambiguity. Import statements are specified as a String with semicolon-separated statements.

The String parameter to this method follows the syntax of the import statement of the Java language.

Specified by:
declareImports in interface javax.jdo.Query

declareParameters

public void declareParameters(java.lang.String parameters)
Declare the list of parameters query execution. The parameter declaration is a String containing one or more query parameter declarations separated with commas. Each parameter named in the parameter declaration must be bound to a value when the query is executed.

The String parameter to this method follows the syntax for formal parameters in the Java language.

Specified by:
declareParameters in interface javax.jdo.Query
Parameters:
parameters - the list of parameters separated by commas.

declareVariables

public void declareVariables(java.lang.String arg1)
Declare the unbound variables to be used in the query. Variables might be used in the filter, and these variables must be declared with their type. The unbound variable declaration is a String containing one or more unbound variable declarations separated with semicolons. It follows the syntax for local variables in the Java language.
Specified by:
declareVariables in interface javax.jdo.Query

execute

public java.lang.Object execute()
Execute the query and return the filtered Collection.
Specified by:
execute in interface javax.jdo.Query
Returns:
the filtered Collection.
See Also:
executeWithArray(Object[] parameters)

execute

public java.lang.Object execute(java.lang.Object arg1)
Execute the query and return the filtered Collection.
Specified by:
execute in interface javax.jdo.Query
Returns:
the filtered Collection.
See Also:
executeWithArray(Object[] parameters)

execute

public java.lang.Object execute(java.lang.Object arg1,
                                java.lang.Object arg2)
Execute the query and return the filtered Collection.
Specified by:
execute in interface javax.jdo.Query
Returns:
the filtered Collection.
See Also:
executeWithArray(Object[] parameters)

execute

public java.lang.Object execute(java.lang.Object arg1,
                                java.lang.Object arg2,
                                java.lang.Object arg3)
Execute the query and return the filtered Collection.
Specified by:
execute in interface javax.jdo.Query
Returns:
the filtered Collection.
See Also:
executeWithArray(Object[] parameters)

executeWithArray

public java.lang.Object executeWithArray(java.lang.Object[] arg1)
Execute the query and return the filtered Collection.

The execution of the query obtains the values of the parameters and matches them against the declared parameters in order. The names of the declared parameters are ignored. The type of the declared parameters must match the type of the passed parameters, except that the passed parameters might need to be unwrapped to get their primitive values.

The filter, import, declared parameters, declared variables, and ordering statements are verified for consistency.

Each element in the candidate Collection is examined to see that it is assignment compatible to the Class of the query. It is then evaluated by the boolean expression of the filter. The element passes the filter if there exist unique values for all variables for which the filter expression evaluates to true.

Specified by:
executeWithArray in interface javax.jdo.Query
Returns:
the filtered Collection.

getIgnoreCache

public boolean getIgnoreCache()
Get the ignoreCache option setting.
Specified by:
getIgnoreCache in interface javax.jdo.Query
Returns:
the ignoreCache option setting.
See Also:
setIgnoreCache(boolean)

getPersistenceManager

public javax.jdo.PersistenceManager getPersistenceManager()
Get the PersistenceManager associated with this Query.

If this Query was restored from a serialized form, it has no PersistenceManager, and this method returns null.

Specified by:
getPersistenceManager in interface javax.jdo.Query
Returns:
the PersistenceManager associated with this Query.

setCandidates

public void setCandidates(javax.jdo.Extent arg1)
Set the candidate Extent to query.
Specified by:
setCandidates in interface javax.jdo.Query

setClass

public void setClass(java.lang.Class queryClass)
Set the class of the candidate instances of the query.

The class specifies the class of the candidates of the query. Elements of the candidate collection that are of the specified class are filtered before being put into the result Collection.

Specified by:
setClass in interface javax.jdo.Query

setFilter

public void setFilter(java.lang.String arg1)
JDO-QL is not currently supported. This API currently only allows for an SQL filter. TopLink expressions, query by example objects, store-procedure calls can also be used as filters.

JDO: Set the filter for the query.

The filter specification is a String containing a boolean expression that is to be evaluated for each of the instances in the candidate collection. If the filter is not specified, then it defaults to "true", which has the effect of filtering the input Collection only for class type.

An element of the candidate collection is returned in the result if:

The user may denote uniqueness in the filter expression by explicitly declaring an expression (for example, e1 != e2).

Rules for constructing valid expressions follow the Java language, except for these differences:

Identifiers in the expression are considered to be in the name space of the specified class, with the addition of declared imports, parameters and variables. As in the Java language, this is a reserved word which means the element of the collection being evaluated.

Navigation through single-valued fields is specified by the Java language syntax of field_name.field_name....field_name.

A JDO implementation is allowed to reorder the filter expression for optimization purposes.

Specified by:
setFilter in interface javax.jdo.Query

setIgnoreCache

public void setIgnoreCache(boolean shouldMaintainCache)
Sets maintainCache in the TopLink query, if set this will by-pass the cache.

JDO: Set the ignoreCache option. The default value for this option was set by the PersistenceManagerFactory or the PersistenceManager used to create this Query. The ignoreCache option setting specifies whether the query should execute entirely in the back end, instead of in the cache. If this flag is set to true, an implementation might be able to optimize the query execution by ignoring changed values in the cache. For optimistic transactions, this can dramatically improve query response times.

Specified by:
setIgnoreCache in interface javax.jdo.Query

setOrdering

public void setOrdering(java.lang.String attribute)
The JDO order clause is not currently supported. Adds the attribute to be ordered by. JDO: Set the ordering specification for the result Collection. The ordering specification is a String containing one or more ordering declarations separated by commas.

Each ordering declaration is the name of the field on which to order the results followed by one of the following words: "ascending" or "descending".

The field must be declared in the candidate class or must be a navigation expression starting with a field in the candidate class.

Valid field types are primitive types except boolean; wrapper types except Boolean; BigDecimal; BigInteger; String; and Date.

Specified by:
setOrdering in interface javax.jdo.Query

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.

addArgument

public void addArgument(java.lang.String argumentName)
PUBLIC: Add the argument named argumentName. This will cause the translation of references of argumentName in the receiver's expression, with the value of the argument as supplied to the query in order from executeQuery()

addAscendingOrdering

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

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

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)

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

addDescendingOrdering

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

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

addJoinedAttribute

public void addJoinedAttribute(java.lang.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, 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. 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 ommited from the result set, unless an outer join is used through passing and expression using "getAllowingNull".

Example: query.addJoinedAttribute("address")

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

addJoinedAttribute

public void addJoinedAttribute(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, 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. 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 ommited from the result set, unless an outer join is used through passing and expression using "getAllowingNull".

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

See Also:
ReadAllQuery.addBatchReadAttribute(String)

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

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())

addPartialAttribute

public void addPartialAttribute(java.lang.String attributeName)
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 it cannot be cached, and cannot be editted. Example: query.addPartialAttribute("firstName")

addPartialAttribute

public void addPartialAttribute(Expression attributeExpression)
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 it cannot be cached, and cannot be editted. Example: query.addPartialAttribute(query.getExpressionBuilder().get("address").get("city"))

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

asReadAllQuery

public void asReadAllQuery()
PUBLIC: Reset the TOPLink query to be a new ReadAllQuery.

asReadObjectQuery

public void asReadObjectQuery()
PUBLIC: Reset the TOPLink query to be a new ReadObjectQuery.

asReportQuery

public void asReportQuery()
PUBLIC: Reset the TOPLink query to be a new ReportQuery.

bindAllParameters

public void bindAllParameters()
Bind all arguments to any SQL statement.

cacheStatement

public void cacheStatement()
Cache the prepared statements, this requires full parameter binding as well.

cascadeAllParts

public void cascadeAllParts()
PUBLIC: Cascade the query and its properties on the queries object(s) and all objects related to the queries object(s). This includes private and independent relationships, but not read-only relationships. This will still stop on uninstantiated indirection objects except for deletion. Great caution should be used in using the property as the query may effect a large number of objects. This policy is used by the unit of work to ensure persistence by reachability.

cascadePrivateParts

public void cascadePrivateParts()
PUBLIC: Cascade the query and its properties on the queries object(s) and all privately owned objects related to the queries object(s). This is the default for write and delete queries. This policy should normally be used for refreshing, otherwise you could refresh half of any object.

checkCacheByExactPrimaryKey

public void checkCacheByExactPrimaryKey()
PUBLIC: The cache will be checked only if the query contains exactly the primary key. Queries can be configured to use the cache at several levels. Other caching option are available.
See Also:
#setCacheUsage(int)

checkCacheByPrimaryKey

public void checkCacheByPrimaryKey()
PUBLIC: This is the default, the cache will be checked only if the query contains the primary key. Queries can be configured to use the cache at several levels. Other caching option are available.
See Also:
#setCacheUsage(int)

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)

checkCacheThenDatabase

public void checkCacheThenDatabase()
PUBLIC: The cache will be checked completely, then if the object is not found or the query too complex the database will be queried. Queries can be configured to use the cache at several levels. Other caching option are available.
See Also:
#setCacheUsage(int)

close

public void close(java.lang.Object queryResult)
Close a query result and release any resources associated with it. The parameter is the return from execute(...) and might have iterators open on it. Iterators associated with the query result are invalidated: they return false to hasNext() and throw NoSuchElementException to next().
Specified by:
close in interface javax.jdo.Query
Parameters:
queryResult - the result of execute(...) on this Query instance.

closeAll

public void closeAll()
Close all query results associated with this Query instance, and release all resources associated with them. The query results might have iterators open on them. Iterators associated with the query results are invalidated: they return false to hasNext() and throw NoSuchElementException to next().
Specified by:
closeAll in interface javax.jdo.Query

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 recomended 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.

dontBindAllParameters

public void dontBindAllParameters()
Do not Bind all arguments to any SQL statement.

dontCacheStatement

public void dontCacheStatement()
Dont cache the prepared statements, this requires full parameter binding as well.

dontCascadeParts

public void dontCascadeParts()
PUBLIC: Do not cascade the query and its properties on the queries object(s) relationships. This does not effect the queries private parts but only the object(s) direct row-level attributes. This is the default for read queries and can be used in writting if it is known that only row-level attributes changed, or to resolve circular foreign key dependencies.

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.

dontMaintainCache

public void dontMaintainCache()
PUBLIC: Set for the identity map (cache) to be ignored completely. The cache check will be skipped and the result will not be put into the identity map. This can be used to retreive the exact state of an object on the database. By default the identity map is always maintained.

dontRefreshIdentityMapResult

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

dontRefreshRemoteIdentityMapResult

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

dontUseDistinct

public void dontUseDistinct()
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.

executeWithMap

public java.lang.Object executeWithMap(java.util.Map arg1)
Execute the query and return the filtered Collection. The query is executed with the parameters set by the Map values. Each Map entry consists of a key which is the name of the parameter in the declareParameters method, and a value which is the value used in the execute method. The keys in the Map and the declared parameters must exactly match or a JDOUserException is thrown.
Specified by:
executeWithMap in interface javax.jdo.Query
Returns:
the filtered Collection.
See Also:
executeWithArray(Object[] parameters)

getCall

public oracle.toplink.internal.databaseaccess.DatabaseCall getCall()
ADVANCED: Return the call for this query. This call contains the SQL and argument list.
See Also:
prepareCall(Session, DatabaseRow);

getExampleObject

public java.lang.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()
Return the query's expression builder.

getQuery

public DatabaseQuery getQuery()
Return the associated TopLink query. This is normally a ReadAllQuery.

getQueryTimeout

public int getQueryTimeout()
PUBLIC: Return the number of seconds the driver will wait for a Statement to execute to the given number of seconds.

getReadAllQuery

public ReadAllQuery getReadAllQuery()
Return the associated TopLink ReadAllQuery.

getReadObjectQuery

public ReadObjectQuery getReadObjectQuery()
Return the associated TopLink ReadObjectQuery.

getReferenceClass

public java.lang.Class getReferenceClass()
PUBLIC: Return the domain class associated with this query. By default this is null, but should be overridden in subclasses.

getReportQuery

public ReportQuery getReportQuery()
Return the associated TopLink ReportQuery.

getSelectionCriteria

public Expression getSelectionCriteria()
PUBLIC: Return the selection criteria of the query. This should only be used with expression queries, null will be returned for others.

maintainCache

public void maintainCache()
PUBLIC: Set for the identity map (cache) to be maintained. This is the default.

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.

setCall

public void setCall(Call call)
PUBLIC: Used to define a store procedure or SQL query.

setCandidates

public void setCandidates(java.util.Collection arg1)
Set the candidate Collection to query.
Specified by:
setCandidates in interface javax.jdo.Query

setEJBQLString

public void setEJBQLString(java.lang.String ejbqlString)
Set the filter to an EJBQL string. Refer to document for EJBQL support

setFilter

public void setFilter(Expression selectionCriteria)
Set the filter to a TopLink expression.

setQuery

public void setQuery(DatabaseQuery newQuery)
Set the associated TopLink query.

setQueryByExampleFilter

public void setQueryByExampleFilter(java.lang.Object exampleObject)
Set the filter based on the query by example object.

setQueryByExamplePolicy

public void setQueryByExamplePolicy(QueryByExamplePolicy newPolicy)
PUBLIC: Policy, an instance of oracle.toplink.queryframework.QueryByExamplePolicy, is a useful tool to customising the query when Query By Example is used. The pollicy will control what attributes should, or should not be included in the query. When dealing with nulls, using specail operations (notEqual, lessThan, like, etc.) for comparison, or chosing to include certain attributes at all times, it is useful to modify the policy accordingly.

setQueryTimeout

public void setQueryTimeout(int queryTimeout)
PUBLIC: Set the number of seconds the driver will wait for a Statement to execute to the given number of seconds. If the limit is exceeded, a DatabaseException is thrown. queryTimeout - the new query timeout limit in seconds; zero means unlimited (by default)

setShouldBindAllParameters

public void setShouldBindAllParameters(boolean shouldBindAllParameters)
Bind all arguments to any SQL statement.

setShouldCacheStatement

public void setShouldCacheStatement(boolean shouldCacheStatement)
Cache the prepared statements, this requires full parameter binding as well.

setShouldMaintainCache

public void setShouldMaintainCache(boolean shouldMaintainCache)
PUBLIC: Set if the identity map (cache) should be used or not. If not the cache check will be skipped and the result will not be put into the identity map. By default the identity map is always maintained.

setShouldRefreshIdentityMapResult

public void setShouldRefreshIdentityMapResult(boolean shouldRefreshIdentityMapResult)
PUBLIC: Set if the attributes of the object(s) resulting from the query should be refreshed. If cascading is used the private parts of the objects will also be refreshed.

setSQLString

public void setSQLString(java.lang.String sqlString)
PUBLIC: To any user of this object. Set the SQL string of the query. This method should only be used when dealing with user defined SQL strings. If arguments are required in the string they will be preceeded by "#" then the argument name.

shouldBindAllParameters

public boolean shouldBindAllParameters()
Bind all arguments to any SQL statement.

shouldCacheStatement

public boolean shouldCacheStatement()
Cache the prepared statements, this requires full parameter binding as well.

shouldCascadeAllParts

public boolean shouldCascadeAllParts()
PUBLIC: Flag used to determine if all parts should be cascaded

shouldCascadeParts

public boolean shouldCascadeParts()
PUBLIC: Flag used to determine if any parts should be cascaded

shouldCascadePrivateParts

public boolean shouldCascadePrivateParts()
PUBLIC: Flag used to determine if any private parts should be cascaded

shouldMaintainCache

public boolean shouldMaintainCache()
PUBLIC: Return if the identity map (cache) should be used or not. If not the cache check will be skipped and the result will not be put into the identity map. By default the identity map is always maintained.

shouldRefreshIdentityMapResult

public boolean shouldRefreshIdentityMapResult()
PUBLIC: Set to a boolean. When set means refresh the instance variables of referenceObject from the database.

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)

useDistinct

public void useDistinct()
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.

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.

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