public interface Query extends Serializable
There are three required elements in a Query: the class of the candidate instances, the candidate collection of instances, and the filter.
There are optional elements: parameter declarations, variable declarations, import statements, and an ordering specification.
| Modifier and Type | Method and Description |
|---|---|
void |
compile()
Verify the elements of the query and provide a hint to the query to
prepare and optimize an execution plan.
|
void |
declareImports(String imports)
Set the import statements to be used to identify the package name of
variables or parameters.
|
void |
declareParameters(String parameters)
Set the parameter list for query execution.
|
void |
declareVariables(String variables)
Declare the unbound variables to be used in the query.
|
Object |
execute()
Execute the query and return the filtered Collection.
|
Object |
execute(Object p1)
Execute the query and return the filtered Collection.
|
Object |
execute(Object p1,
Object p2)
Execute the query and return the filtered Collection.
|
Object |
execute(Object p1,
Object p2,
Object p3)
Execute the query and return the filtered Collection.
|
Object |
executeWithArray(Object[] parameters)
Execute the query and return the filtered Collection.
|
Object |
executeWithMap(Map parameters)
Execute the query and return the filtered Collection.
|
boolean |
getIgnoreCache()
Get the ignoreCache option setting.
|
PersistenceManager |
getPersistenceManager()
Get the PersistenceManager associated with this Query.
|
void |
setCandidates(Collection pcs)
Set the candidate Collection to query.
|
void |
setClass(Class cls)
Set the class of the candidate instances of the query.
|
void |
setFilter(String filter)
Set the filter for the query.
|
void |
setIgnoreCache(boolean ignoreCache)
Set the ignoreCache option.
|
void |
setOrdering(String ordering)
Bind the ordering declarations to the query instance.
|
void |
setPrefetchEnabled(boolean prefetchEnabled)
Sets the prefetchEnabled option.
|
void |
setResult(String result)
Set the result of the query.
|
void setClass(Class cls)
The class is a PersistenceCapable class which 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.
cls - the Class of the candidate instances.void setCandidates(Collection pcs)
pcs - the Candidate collection.void setFilter(String filter)
filter - the query filter.void declareImports(String imports)
imports - import statements separated by semicolons.void declareParameters(String parameters)
parameters - the list of parameters separated by commas.void declareVariables(String variables)
variables - the variables separated by semicolons.void setOrdering(String ordering)
ordering - the ordering declarations separated by comma.void setResult(String result)
The query result is an optional keyword distinct followed by a Java expression, which tells what values are to be returned by the JDO query. If the result is not specified, then it defaults to "distinct this", which has the effect of returning the elements of the candidates that match the filter.
void setPrefetchEnabled(boolean prefetchEnabled)
prefetchEnabled - the setting of the prefetchEnabled option.void setIgnoreCache(boolean ignoreCache)
ignoreCache - the setting of the ignoreCache option.boolean getIgnoreCache()
setIgnoreCache(boolean)void compile()
Object execute()
(Object[] parameters)Object execute(Object p1)
p1 - the value of the first parameter declared.(Object[] parameters)Object execute(Object p1, Object p2)
p1 - the value of the first parameter declared.p2 - the value of the second parameter declared.(Object[] parameters)Object execute(Object p1, Object p2, Object p3)
p1 - the value of the first parameter declared.p2 - the value of the second parameter declared.p3 - the value of the third parameter declared.(Object[] parameters)Object executeWithMap(Map parameters)
parameters - the Map containing all of the parameters.(Object[] parameters)Object executeWithArray(Object[] parameters)
The execution of the query obtains the values of the parameters and matches them against the declared parameters in order. 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.
parameters - the Object array with all of the parameters.PersistenceManager getPersistenceManager()
If this Query has no PersistenceManager return null.
Copyright © 2017–2020 Eclipse Foundation. All rights reserved.