public class QueryImpl extends Object implements Query
Query interface.| Modifier and Type | Class and Description |
|---|---|
protected static class |
QueryImpl.Compilation
Struct of compiled query properties.
|
static class |
QueryImpl.PackingResultObjectProvider
Result object provider that packs results before returning them.
|
class |
QueryImpl.RemoveOnCloseResultList
Result list that removes itself from the query's open result list
when it is closed.
|
OP_DELETE, OP_SELECT, OP_UPDATEFLUSH_FALSE, FLUSH_TRUE, FLUSH_WITH_CONNECTION| Constructor and Description |
|---|
QueryImpl(Broker broker,
String language,
StoreQuery storeQuery)
Construct a query managed by the given broker.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAggregateListener(AggregateListener listener)
Register an aggregate listener for the query.
|
void |
addFilterListener(FilterListener listener)
Register a filter listener for the query.
|
void |
assertNotReadOnly()
Assert that the query is not read-only.
|
void |
assertNotSerialized()
Check that the query has not been serialized, which causes it to lose
its association with its Broker.
|
void |
assertOpen()
Assert that the query's broker is still open.
|
protected void |
assertParameters(StoreQuery q,
StoreQuery.Executor ex,
Map params) |
protected void |
assertParameters(StoreQuery q,
StoreQuery.Executor ex,
Object[] params)
Checks that the passed parameters match the declarations.
|
Class |
classForName(String name,
String[] imports)
Helper method to instantiate the class with the given name, taking
into account the query's candidate package, automatic imports, and
the given imports (if any).
|
void |
closeAll()
Close all open query results.
|
void |
closeResources()
Close query results that are consuming resources.
|
protected QueryImpl.Compilation |
compilationFromCache()
Find the cached compilation for the current query, creating one if it
does not exist.
|
void |
compile()
Compile the query.
|
void |
declareParameters(String params)
Declared parameters, for query languages that use them.
|
protected QueryImpl.RemoveOnCloseResultList |
decorateResultList(ResultList<?> res)
Optionally decorate the native result.
|
long |
deleteAll()
Deletes all of the instances that are satisfied by the query.
|
long |
deleteAll(Map params)
Deletes all of the instances that are satisfied by the query.
|
long |
deleteAll(Object[] params)
Deletes all of the instances that are satisfied by the query.
|
Number |
deleteInMemory(StoreQuery q,
StoreQuery.Executor executor,
Object[] params)
Helper method to delete the objects found by executing a query on
the given executor.
|
Object |
execute()
Execute.
|
Object |
execute(Map params)
Execute with parameter map.
|
Object |
execute(Object[] params)
Execute with parameter array.
|
ClassMetaData[] |
getAccessPathMetaDatas()
Return the classes that affect this query.
|
AggregateListener |
getAggregateListener(String tag)
Return the filter listener for the given tag, or null.
|
Collection<AggregateListener> |
getAggregateListeners()
The set of aggregate listeners.
|
String |
getAlias()
If this query is not a projection but places candidate results into a
result class under an alias, return that alias.
|
Broker |
getBroker()
The broker that generated this query.
|
Collection<?> |
getCandidateCollection()
Return the candidate collection, or
null if an
extent was specified instead of a collection. |
Extent |
getCandidateExtent()
Return the candidate extent, or
null if a
collection was specified instead of an extent. |
Class |
getCandidateType()
Return the class of the objects that this query will return,
or
null if this information is not available / not relevant. |
Object |
getCompilation()
Return the query's compilation state.
|
String[] |
getDataStoreActions(Map params)
Returns a description of the commands that will be sent to
the datastore in order to execute this query.
|
long |
getEndRange()
Return the 0-based exclusive end index for the returned results,
or
Long.MAX_VALUE for no limit. |
FetchConfiguration |
getFetchConfiguration()
Return the fetch configuration for this query.
|
FilterListener |
getFilterListener(String tag)
Return the filter listener for the given tag, or null.
|
Collection<FilterListener> |
getFilterListeners()
The set of filter listeners.
|
boolean |
getIgnoreChanges()
Whether to ignore changes in the current transaction.
|
String |
getLanguage()
The query language.
|
int |
getOperation()
Returns the operation that this query will be expected to perform.
|
OrderedMap<Object,Class<?>> |
getOrderedParameterTypes()
Return a map of parameter name to type for this query.
|
String |
getParameterDeclaration()
The parameter declaration.
|
LinkedMap |
getParameterTypes()
Return a map of parameter name to type for this query.
|
String[] |
getProjectionAliases()
If this query is a projection, return the projection aliases.
|
Class<?>[] |
getProjectionTypes()
If this query is a projection, return the projection types.
|
Query |
getQuery()
Return the query for this context.
|
String |
getQueryString()
The query string.
|
String |
getResultMappingName()
Name of a mapping from the result data to its object representation.
|
Class |
getResultMappingScope()
Scope of a mapping from the result data to its object representation.
|
Class |
getResultType()
Returns the result class that has been set through
QueryContext.setResultType(java.lang.Class<?>), or null if none. |
long |
getStartRange()
Return the 0-based start index for the returned results.
|
StoreContext |
getStoreContext()
The persistence context for the query.
|
StoreQuery |
getStoreQuery()
Internal store query.
|
Map |
getUpdates()
If this query is a bulk update, return a map of the
FieldMetaDatas to Constants. |
boolean |
hasGrouping()
Return true if the query uses grouping.
|
boolean |
hasSubclasses()
Whether query results will include subclasses of the candidate class.
|
static boolean |
isAccessPathDirty(Broker broker,
ClassMetaData[] accessMetas) |
boolean |
isAggregate()
Return true if the query is an aggregate.
|
boolean |
isDistinct()
Affirms if this query results are distinct instance(s).
|
boolean |
isParsedQuery()
Affirms if this query has originated by parsing a string-based query.
|
boolean |
isReadOnly()
Whether the query has been marked read-only.
|
boolean |
isUnique()
The unique flag.
|
void |
lock()
Synchronize on the query's internal lock.
|
void |
removeAggregateListener(AggregateListener listener)
Remove an aggregate listener from the query.
|
void |
removeFilterListener(FilterListener listener)
Remove a filter listener from the query.
|
void |
setCandidateCollection(Collection<?> candidateCollection)
Set a collection of candidates.
|
void |
setCandidateExtent(Extent candidateExtent)
Set the candidate extent.
|
void |
setCandidateType(Class candidateClass,
boolean subs)
Set the candidate type.
|
void |
setIgnoreChanges(boolean flag)
Whether to ignore changes in the current transaction.
|
boolean |
setQuery(Object query)
The query string or template.
|
void |
setRange(long start,
long end)
Set the range of results to return.
|
void |
setReadOnly(boolean flag)
Whether the query has been marked read-only.
|
void |
setResultMapping(Class<?> scope,
String name)
Name and scope of a mapping from the result data to its object
representation.
|
void |
setResultType(Class cls)
Specify the type of object in which the result of evaluating this query.
|
void |
setUnique(boolean unique)
Specify that the query will return only 1
result, rather than a collection.
|
void |
startLocking() |
void |
stopLocking() |
protected Object |
toResult(StoreQuery q,
StoreQuery.Executor ex,
ResultObjectProvider rop,
StoreQuery.Range range)
Return the query result for the given result object provider.
|
String |
toString() |
void |
unlock()
Unlock the query's internal lock.
|
long |
updateAll()
Performs an update of the instances that are satisfied by the query.
|
long |
updateAll(Map params)
Performs an update of the instances that are satisfied by the query.
|
long |
updateAll(Object[] params)
Performs an update of the instances that are satisfied by the query.
|
Number |
updateInMemory(StoreQuery q,
StoreQuery.Executor executor,
Object[] params)
Helper method to update the objects found by executing a query on
the given executor.
|
public QueryImpl(Broker broker, String language, StoreQuery storeQuery)
public StoreQuery getStoreQuery()
public Broker getBroker()
Querypublic Query getQuery()
QueryContextgetQuery in interface QueryContextpublic StoreContext getStoreContext()
QueryContextgetStoreContext in interface QueryContextpublic String getLanguage()
QueryContextgetLanguage in interface QueryContextpublic FetchConfiguration getFetchConfiguration()
QueryContextgetFetchConfiguration in interface QueryContextpublic String getQueryString()
QueryContextgetQueryString in interface QueryContextpublic boolean getIgnoreChanges()
QueryContextgetIgnoreChanges in interface QueryContextpublic void setIgnoreChanges(boolean flag)
QuerysetIgnoreChanges in interface Querypublic boolean isReadOnly()
QueryContextisReadOnly in interface QueryContextpublic void setReadOnly(boolean flag)
QueryContextsetReadOnly in interface QueryContextpublic void addFilterListener(FilterListener listener)
QueryaddFilterListener in interface Querypublic void removeFilterListener(FilterListener listener)
QueryremoveFilterListener in interface Querypublic Collection<FilterListener> getFilterListeners()
QueryContextgetFilterListeners in interface QueryContextpublic FilterListener getFilterListener(String tag)
QueryContextgetFilterListener in interface QueryContextpublic void addAggregateListener(AggregateListener listener)
QueryaddAggregateListener in interface Querypublic void removeAggregateListener(AggregateListener listener)
QueryremoveAggregateListener in interface Querypublic Collection<AggregateListener> getAggregateListeners()
QueryContextgetAggregateListeners in interface QueryContextpublic AggregateListener getAggregateListener(String tag)
QueryContextgetAggregateListener in interface QueryContextpublic Extent getCandidateExtent()
Querynull if a
collection was specified instead of an extent.getCandidateExtent in interface Querypublic void setCandidateExtent(Extent candidateExtent)
QuerysetCandidateExtent in interface Querypublic Collection<?> getCandidateCollection()
QueryContextnull if an
extent was specified instead of a collection.getCandidateCollection in interface QueryContextpublic void setCandidateCollection(Collection<?> candidateCollection)
QuerysetCandidateCollection in interface Querypublic Class getCandidateType()
QueryContextnull if this information is not available / not relevant.getCandidateType in interface QueryContextpublic void setCandidateType(Class candidateClass, boolean subs)
QueryContextsetCandidateType in interface QueryContextpublic boolean hasSubclasses()
QueryContexthasSubclasses in interface QueryContextpublic String getResultMappingName()
QueryContextgetResultMappingName in interface QueryContextpublic Class getResultMappingScope()
QueryContextgetResultMappingScope in interface QueryContextpublic void setResultMapping(Class<?> scope, String name)
QueryContextsetResultMapping in interface QueryContextpublic boolean isUnique()
QueryContextisUnique in interface QueryContextpublic boolean isParsedQuery()
public void setUnique(boolean unique)
QueryContextsetUnique in interface QueryContextpublic Class getResultType()
QueryContextQueryContext.setResultType(java.lang.Class<?>), or null if none.getResultType in interface QueryContextpublic void setResultType(Class cls)
QueryContextsetResultType in interface QueryContextpublic long getStartRange()
QueryContextgetStartRange in interface QueryContextpublic long getEndRange()
QueryContextLong.MAX_VALUE for no limit.getEndRange in interface QueryContextpublic void setRange(long start,
long end)
QueryContextsetRange in interface QueryContextstart - 0-based inclusive start indexend - 0-based exclusive end index, or
Long.MAX_VALUE for no limitpublic String getParameterDeclaration()
QueryContextgetParameterDeclaration in interface QueryContextpublic void declareParameters(String params)
QueryContextdeclareParameters in interface QueryContextpublic void compile()
Querypublic Object getCompilation()
QueryContextgetCompilation in interface QueryContextprotected QueryImpl.Compilation compilationFromCache()
public Object execute(Object[] params)
Querypublic Object execute(Map params)
Querypublic long deleteAll()
Querypublic long deleteAll(Object[] params)
Querypublic long deleteAll(Map params)
Querypublic long updateAll()
Querypublic long updateAll(Object[] params)
Querypublic long updateAll(Map params)
Querypublic Number deleteInMemory(StoreQuery q, StoreQuery.Executor executor, Object[] params)
QueryContextdeleteInMemory in interface QueryContextpublic Number updateInMemory(StoreQuery q, StoreQuery.Executor executor, Object[] params)
QueryContextupdateInMemory in interface QueryContextprotected Object toResult(StoreQuery q, StoreQuery.Executor ex, ResultObjectProvider rop, StoreQuery.Range range) throws Exception
Exceptionprotected QueryImpl.RemoveOnCloseResultList decorateResultList(ResultList<?> res)
public static boolean isAccessPathDirty(Broker broker, ClassMetaData[] accessMetas)
public void closeAll()
Querypublic void closeResources()
QuerycloseResources in interface Querypublic String[] getDataStoreActions(Map params)
QuerygetDataStoreActions in interface Queryparams - the named parameter map for the query invocationpublic boolean setQuery(Object query)
Querypublic String getAlias()
QueryContextgetAlias in interface QueryContextpublic String[] getProjectionAliases()
QueryContextgetProjectionAliases in interface QueryContextpublic Class<?>[] getProjectionTypes()
QueryContextgetProjectionTypes in interface QueryContextpublic int getOperation()
QueryContextgetOperation in interface QueryContextQueryOperationspublic boolean isAggregate()
QueryContextisAggregate in interface QueryContextpublic boolean isDistinct()
QueryContextisDistinct in interface QueryContextpublic boolean hasGrouping()
QueryContexthasGrouping in interface QueryContextpublic ClassMetaData[] getAccessPathMetaDatas()
QueryContextgetAccessPathMetaDatas in interface QueryContextpublic OrderedMap<Object,Class<?>> getOrderedParameterTypes()
QueryContextgetOrderedParameterTypes in interface QueryContextpublic LinkedMap getParameterTypes()
QueryContextgetParameterTypes in interface QueryContextpublic Map getUpdates()
QueryContextFieldMetaDatas to Constants.getUpdates in interface QueryContextpublic void lock()
QueryContextlock in interface QueryContextpublic void unlock()
QueryContextunlock in interface QueryContextpublic void startLocking()
public void stopLocking()
public Class classForName(String name, String[] imports)
QueryContextclassForName in interface QueryContextpublic void assertOpen()
QueryassertOpen in interface Querypublic void assertNotReadOnly()
QueryassertNotReadOnly in interface Querypublic void assertNotSerialized()
QueryassertNotSerialized in interface Queryprotected void assertParameters(StoreQuery q, StoreQuery.Executor ex, Object[] params)
protected void assertParameters(StoreQuery q, StoreQuery.Executor ex, Map params)
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.