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_UPDATE
FLUSH_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
FieldMetaData s to Constant s. |
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()
Query
public Query getQuery()
QueryContext
getQuery
in interface QueryContext
public StoreContext getStoreContext()
QueryContext
getStoreContext
in interface QueryContext
public String getLanguage()
QueryContext
getLanguage
in interface QueryContext
public FetchConfiguration getFetchConfiguration()
QueryContext
getFetchConfiguration
in interface QueryContext
public String getQueryString()
QueryContext
getQueryString
in interface QueryContext
public boolean getIgnoreChanges()
QueryContext
getIgnoreChanges
in interface QueryContext
public void setIgnoreChanges(boolean flag)
Query
setIgnoreChanges
in interface Query
public boolean isReadOnly()
QueryContext
isReadOnly
in interface QueryContext
public void setReadOnly(boolean flag)
QueryContext
setReadOnly
in interface QueryContext
public void addFilterListener(FilterListener listener)
Query
addFilterListener
in interface Query
public void removeFilterListener(FilterListener listener)
Query
removeFilterListener
in interface Query
public Collection<FilterListener> getFilterListeners()
QueryContext
getFilterListeners
in interface QueryContext
public FilterListener getFilterListener(String tag)
QueryContext
getFilterListener
in interface QueryContext
public void addAggregateListener(AggregateListener listener)
Query
addAggregateListener
in interface Query
public void removeAggregateListener(AggregateListener listener)
Query
removeAggregateListener
in interface Query
public Collection<AggregateListener> getAggregateListeners()
QueryContext
getAggregateListeners
in interface QueryContext
public AggregateListener getAggregateListener(String tag)
QueryContext
getAggregateListener
in interface QueryContext
public Extent getCandidateExtent()
Query
null
if a
collection was specified instead of an extent.getCandidateExtent
in interface Query
public void setCandidateExtent(Extent candidateExtent)
Query
setCandidateExtent
in interface Query
public Collection<?> getCandidateCollection()
QueryContext
null
if an
extent was specified instead of a collection.getCandidateCollection
in interface QueryContext
public void setCandidateCollection(Collection<?> candidateCollection)
Query
setCandidateCollection
in interface Query
public Class getCandidateType()
QueryContext
null
if this information is not available / not relevant.getCandidateType
in interface QueryContext
public void setCandidateType(Class candidateClass, boolean subs)
QueryContext
setCandidateType
in interface QueryContext
public boolean hasSubclasses()
QueryContext
hasSubclasses
in interface QueryContext
public String getResultMappingName()
QueryContext
getResultMappingName
in interface QueryContext
public Class getResultMappingScope()
QueryContext
getResultMappingScope
in interface QueryContext
public void setResultMapping(Class<?> scope, String name)
QueryContext
setResultMapping
in interface QueryContext
public boolean isUnique()
QueryContext
isUnique
in interface QueryContext
public boolean isParsedQuery()
public void setUnique(boolean unique)
QueryContext
setUnique
in interface QueryContext
public Class getResultType()
QueryContext
QueryContext.setResultType(java.lang.Class<?>)
, or null if none.getResultType
in interface QueryContext
public void setResultType(Class cls)
QueryContext
setResultType
in interface QueryContext
public long getStartRange()
QueryContext
getStartRange
in interface QueryContext
public long getEndRange()
QueryContext
Long.MAX_VALUE
for no limit.getEndRange
in interface QueryContext
public void setRange(long start, long end)
QueryContext
setRange
in interface QueryContext
start
- 0-based inclusive start indexend
- 0-based exclusive end index, or
Long.MAX_VALUE
for no limitpublic String getParameterDeclaration()
QueryContext
getParameterDeclaration
in interface QueryContext
public void declareParameters(String params)
QueryContext
declareParameters
in interface QueryContext
public void compile()
Query
public Object getCompilation()
QueryContext
getCompilation
in interface QueryContext
protected QueryImpl.Compilation compilationFromCache()
public Object execute(Object[] params)
Query
public Object execute(Map params)
Query
public long deleteAll()
Query
public long deleteAll(Object[] params)
Query
public long deleteAll(Map params)
Query
public long updateAll()
Query
public long updateAll(Object[] params)
Query
public long updateAll(Map params)
Query
public Number deleteInMemory(StoreQuery q, StoreQuery.Executor executor, Object[] params)
QueryContext
deleteInMemory
in interface QueryContext
public Number updateInMemory(StoreQuery q, StoreQuery.Executor executor, Object[] params)
QueryContext
updateInMemory
in interface QueryContext
protected Object toResult(StoreQuery q, StoreQuery.Executor ex, ResultObjectProvider rop, StoreQuery.Range range) throws Exception
Exception
protected QueryImpl.RemoveOnCloseResultList decorateResultList(ResultList<?> res)
public static boolean isAccessPathDirty(Broker broker, ClassMetaData[] accessMetas)
public void closeAll()
Query
public void closeResources()
Query
closeResources
in interface Query
public String[] getDataStoreActions(Map params)
Query
getDataStoreActions
in interface Query
params
- the named parameter map for the query invocationpublic boolean setQuery(Object query)
Query
public String getAlias()
QueryContext
getAlias
in interface QueryContext
public String[] getProjectionAliases()
QueryContext
getProjectionAliases
in interface QueryContext
public Class<?>[] getProjectionTypes()
QueryContext
getProjectionTypes
in interface QueryContext
public int getOperation()
QueryContext
getOperation
in interface QueryContext
QueryOperations
public boolean isAggregate()
QueryContext
isAggregate
in interface QueryContext
public boolean isDistinct()
QueryContext
isDistinct
in interface QueryContext
public boolean hasGrouping()
QueryContext
hasGrouping
in interface QueryContext
public ClassMetaData[] getAccessPathMetaDatas()
QueryContext
getAccessPathMetaDatas
in interface QueryContext
public OrderedMap<Object,Class<?>> getOrderedParameterTypes()
QueryContext
getOrderedParameterTypes
in interface QueryContext
public LinkedMap getParameterTypes()
QueryContext
getParameterTypes
in interface QueryContext
public Map getUpdates()
QueryContext
FieldMetaData
s to Constant
s.getUpdates
in interface QueryContext
public void lock()
QueryContext
lock
in interface QueryContext
public void unlock()
QueryContext
unlock
in interface QueryContext
public void startLocking()
public void stopLocking()
public Class classForName(String name, String[] imports)
QueryContext
classForName
in interface QueryContext
public void assertOpen()
Query
assertOpen
in interface Query
public void assertNotReadOnly()
Query
assertNotReadOnly
in interface Query
public void assertNotSerialized()
Query
assertNotSerialized
in interface Query
protected 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.