public class QueryImpl extends Object implements Query
| Modifier and Type | Field and Description |
|---|---|
protected static ResourceBundle |
messages
I18N support
|
| Constructor and Description |
|---|
QueryImpl(PersistenceManager pm)
Create an empty query instance with no elements.
|
QueryImpl(PersistenceManager pm,
Class candidateClass)
Create a query instance with the candidate class specified.
|
QueryImpl(PersistenceManager pm,
Class candidateClass,
Collection candidateCollection)
Create a query instance with the candidate class and
candidate collection specified.
|
QueryImpl(PersistenceManager pm,
Class candidateClass,
Collection candidateCollection,
String filter)
Create a query instance with the candidate class,
the candidate collection, and filter specified.
|
QueryImpl(PersistenceManager pm,
Class candidateClass,
String filter)
Create a query instance with the candidate class and
filter specified.
|
QueryImpl(PersistenceManager pm,
Object compiled)
Create a new Query using elements from another Query.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearPersistenceManager()
This method clears the PersistenceManager and the candidateCollection fields.
|
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)
Bind the import statements to the query instance.
|
void |
declareParameters(String parameters)
Bind the parameter statements to the query instance.
|
void |
declareVariables(String variables)
Bind the unbound variable statements to the query instance.
|
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 candidateCollection)
Bind the candidate Collection to the query instance.
|
void |
setClass(Class candidateClass)
Bind the candidate class to the query instance.
|
void |
setFilter(String filter)
Bind the query filter to the query instance.
|
void |
setIgnoreCache(boolean ignoreCache)
Set the ignoreCache option.
|
void |
setOrdering(String ordering)
Bind the ordering statements to the query instance.
|
void |
setPrefetchEnabled(boolean prefetchEnabled)
Sets the prefetchEnabled option.
|
void |
setResult(String result)
Set the result of the query.
|
String |
toString()
Returns a string representation of the object.
|
protected static final ResourceBundle messages
public QueryImpl(PersistenceManager pm)
public QueryImpl(PersistenceManager pm, Object compiled)
compiled - another Query from the same JDO implementationpublic QueryImpl(PersistenceManager pm, Class candidateClass)
candidateClass - the Class of the candidate instances.public QueryImpl(PersistenceManager pm, Class candidateClass, Collection candidateCollection)
candidateClass - the Class of the candidate instances.candidateCollection - the Collection of candidate instances.public QueryImpl(PersistenceManager pm, Class candidateClass, String filter)
candidateClass - the Class of the candidate instances.filter - the Filter for candidate instances.public QueryImpl(PersistenceManager pm, Class candidateClass, Collection candidateCollection, String filter)
candidateClass - the Class of the candidate instances.candidateCollection - the Collection of candidate instances.filter - the Filter for candidate instancespublic void setClass(Class candidateClass)
public void setCandidates(Collection candidateCollection)
setCandidates in interface QuerycandidateCollection - the Candidate collection.public void setFilter(String filter)
public void declareImports(String imports)
declareImports in interface Queryimports - import statements separated by semicolons.public void declareParameters(String parameters)
declareParameters in interface Queryparameters - the list of parameters separated by commas.public void declareVariables(String variables)
declareVariables in interface Queryvariables - the variables separated by semicolons.public void setOrdering(String ordering)
setOrdering in interface Queryordering - the ordering declarations separated by comma.public 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.
public void setIgnoreCache(boolean ignoreCache)
setIgnoreCache in interface QueryignoreCache - the setting of the ignoreCache option.public boolean getIgnoreCache()
getIgnoreCache in interface QuerysetIgnoreCache(boolean)public void setPrefetchEnabled(boolean prefetchEnabled)
setPrefetchEnabled in interface QueryprefetchEnabled - the setting of the prefetchEnabled option.public void compile()
public Object execute()
execute in interface Query(Object[] parameters)public Object execute(Object p1)
execute in interface Queryp1 - the value of the first parameter declared.(Object[] parameters)public Object execute(Object p1, Object p2)
execute in interface Queryp1 - the value of the first parameter declared.p2 - the value of the second parameter declared.(Object[] parameters)public Object execute(Object p1, Object p2, Object p3)
execute in interface Queryp1 - 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)public Object executeWithMap(Map parameters)
executeWithMap in interface Queryparameters - the Map containing all of the parameters.(Object[] parameters)public 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.
executeWithArray in interface Queryparameters - the Object array with all of the parameters.public PersistenceManager getPersistenceManager()
If this Query has no PersistenceManager return null.
getPersistenceManager in interface Querypublic void clearPersistenceManager()
This method effectively disconnects the PersistenceManager allowing it to be garbage collected.
Copyright © 2019. All rights reserved.