public class ExpressionStoreQuery extends AbstractStoreQuery
AbstractStoreQuery.supportsDataStoreExecution()
to return
true
.executeQuery(org.apache.openjpa.kernel.StoreQuery.Executor, org.apache.openjpa.meta.ClassMetaData, org.apache.openjpa.meta.ClassMetaData[], boolean, org.apache.openjpa.kernel.exps.ExpressionFactory[], org.apache.openjpa.kernel.exps.QueryExpressions[], java.lang.Object[], org.apache.openjpa.kernel.StoreQuery.Range)
, executeDelete(org.apache.openjpa.kernel.StoreQuery.Executor, org.apache.openjpa.meta.ClassMetaData, org.apache.openjpa.meta.ClassMetaData[], boolean, org.apache.openjpa.kernel.exps.ExpressionFactory[], org.apache.openjpa.kernel.exps.QueryExpressions[], java.lang.Object[])
, and
executeUpdate(org.apache.openjpa.kernel.StoreQuery.Executor, org.apache.openjpa.meta.ClassMetaData, org.apache.openjpa.meta.ClassMetaData[], boolean, org.apache.openjpa.kernel.exps.ExpressionFactory[], org.apache.openjpa.kernel.exps.QueryExpressions[], java.lang.Object[])
to execute the query against the data store.
Keep in mind that the parameters passed to this method might be in use
by several threads in different query instances. Thus components like
the expression factory must either be thread safe, or this method must
synchronize on them.getDataStoreActions(org.apache.openjpa.meta.ClassMetaData, org.apache.openjpa.meta.ClassMetaData[], boolean, org.apache.openjpa.kernel.exps.ExpressionFactory[], org.apache.openjpa.kernel.exps.QueryExpressions[], java.lang.Object[], org.apache.openjpa.kernel.StoreQuery.Range)
to return a representation of
the actions that will be taken on the data store. For use in visual
tools.getExpressionFactory(org.apache.openjpa.meta.ClassMetaData)
to return a factory for creating
expressions in the datastore's language. The factory must be cachable.Modifier and Type | Class and Description |
---|---|
static class |
ExpressionStoreQuery.AbstractExpressionExecutor
Provides support for queries that hold query information
in a
QueryExpressions instance. |
static class |
ExpressionStoreQuery.DataStoreExecutor
The DataStoreExecutor executes the query against the
implementation's overridden
ExpressionStoreQuery.DataStoreExecutor.executeQuery(org.apache.openjpa.kernel.StoreQuery, java.lang.Object[], org.apache.openjpa.kernel.StoreQuery.Range) method. |
static class |
ExpressionStoreQuery.InMemoryExecutor
Runs the expression query in memory.
|
AbstractStoreQuery.AbstractExecutor
StoreQuery.Executor, StoreQuery.Range
Modifier and Type | Field and Description |
---|---|
protected Object |
_parsed |
protected ExpressionParser |
_parser |
ctx
EMPTY_BOOLEANS, EMPTY_CLASSES, EMPTY_METAS, EMPTY_OBJECTS, EMPTY_ORDERED_PARAMS, EMPTY_PARAMS, EMPTY_STRINGS
OP_DELETE, OP_SELECT, OP_UPDATE
Constructor and Description |
---|
ExpressionStoreQuery(ExpressionParser parser)
Construct a query with a parser for the language.
|
Modifier and Type | Method and Description |
---|---|
protected Number |
executeDelete(StoreQuery.Executor ex,
ClassMetaData base,
ClassMetaData[] types,
boolean subclasses,
ExpressionFactory[] facts,
QueryExpressions[] parsed,
Object[] params)
Execute the given expression against the given candidate extent
and delete the instances.
|
protected ResultObjectProvider |
executeQuery(StoreQuery.Executor ex,
ClassMetaData base,
ClassMetaData[] types,
boolean subclasses,
ExpressionFactory[] facts,
QueryExpressions[] parsed,
Object[] params,
StoreQuery.Range range)
Execute the given expression against the given candidate extent.
|
protected Number |
executeUpdate(StoreQuery.Executor ex,
ClassMetaData base,
ClassMetaData[] types,
boolean subclasses,
ExpressionFactory[] facts,
QueryExpressions[] parsed,
Object[] params)
Execute the given expression against the given candidate extent
and updates the instances.
|
Object |
getCompilation()
Get the current compilation for this query.
|
protected String[] |
getDataStoreActions(ClassMetaData base,
ClassMetaData[] types,
boolean subclasses,
ExpressionFactory[] facts,
QueryExpressions[] parsed,
Object[] params,
StoreQuery.Range range)
Return the commands that will be sent to the datastore in order
to execute the query, typically in the database's native language.
|
protected ExpressionFactory |
getExpressionFactory(ClassMetaData type)
Return an
ExpressionFactory to use to create an expression to
be executed against an extent. |
FilterListener |
getFilterListener(String tag)
Return the standard filter listener for the given tag, or null.
|
protected ClassMetaData[] |
getIndependentExpressionCandidates(ClassMetaData type,
boolean subclasses)
Return the assignable types for the given metadata whose expression
trees must be compiled independently.
|
Resolver |
getResolver()
Resolver used in parsing.
|
void |
invalidateCompilation()
Invalidate any internal compilation state.
|
Object |
newCompilation()
Create a new compilation for this query.
|
StoreQuery.Executor |
newDataStoreExecutor(ClassMetaData meta,
boolean subs)
Return an executor for datastore execution of this query.
|
StoreQuery.Executor |
newInMemoryExecutor(ClassMetaData meta,
boolean subs)
Return an executor for in-memory execution of this query.
|
void |
populateFromCompilation(Object comp)
Populate internal data from compilation.
|
boolean |
setQuery(Object query)
Allow direct setting of parsed state for facades that do parsing.
|
boolean |
supportsInMemoryExecution()
True if this query supports in-memory execution, false if it
can only run against the datastore.
|
evaluate, getAggregateListener, getContext, newCompilationKey, requiresCandidateType, requiresParameterDeclarations, setContext, supportsAbstractExecutors, supportsDataStoreExecution, supportsParameterDeclarations
protected final ExpressionParser _parser
protected transient Object _parsed
public ExpressionStoreQuery(ExpressionParser parser)
public Resolver getResolver()
public boolean setQuery(Object query)
setQuery
in interface StoreQuery
setQuery
in class AbstractStoreQuery
public FilterListener getFilterListener(String tag)
StoreQuery
getFilterListener
in interface StoreQuery
getFilterListener
in class AbstractStoreQuery
public Object newCompilation()
StoreQuery
newCompilation
in interface StoreQuery
newCompilation
in class AbstractStoreQuery
public Object getCompilation()
StoreQuery
getCompilation
in interface StoreQuery
getCompilation
in class AbstractStoreQuery
public void populateFromCompilation(Object comp)
StoreQuery
populateFromCompilation
in interface StoreQuery
populateFromCompilation
in class AbstractStoreQuery
public void invalidateCompilation()
StoreQuery
invalidateCompilation
in interface StoreQuery
invalidateCompilation
in class AbstractStoreQuery
public boolean supportsInMemoryExecution()
StoreQuery
supportsInMemoryExecution
in interface StoreQuery
supportsInMemoryExecution
in class AbstractStoreQuery
public StoreQuery.Executor newInMemoryExecutor(ClassMetaData meta, boolean subs)
StoreQuery
StoreQuery.supportsAbstractExecutors()
, the given metadata
will always be for the candidate class of this query, or possibly
null if the candidate class is not itself persistence capable (like
an interface or abstract base class). Otherwise, the given type will
be a mapped class.newInMemoryExecutor
in interface StoreQuery
newInMemoryExecutor
in class AbstractStoreQuery
subs
- whether to include dependent mapped subclasses in the
results; independent subclasses should never be includedpublic StoreQuery.Executor newDataStoreExecutor(ClassMetaData meta, boolean subs)
StoreQuery
StoreQuery.supportsAbstractExecutors()
, the given metadata
will always be for the candidate class of this query, or possibly
null if the candidate class is not itself persistence capable (like
an interface or abstract base class). Otherwise, the given type will
be a mapped class.newDataStoreExecutor
in interface StoreQuery
newDataStoreExecutor
in class AbstractStoreQuery
subs
- whether to include dependent mapped subclasses in the
results; independent subclasses should never be includedprotected ResultObjectProvider executeQuery(StoreQuery.Executor ex, ClassMetaData base, ClassMetaData[] types, boolean subclasses, ExpressionFactory[] facts, QueryExpressions[] parsed, Object[] params, StoreQuery.Range range)
ex
- current executorbase
- the base type the query should matchtypes
- the independent candidate typessubclasses
- true if subclasses should be included in the resultsfacts
- the expression factory used to build the query for
each base typeparsed
- the parsed query valuesparams
- parameter values, or empty arrayrange
- result rangeprotected Number executeDelete(StoreQuery.Executor ex, ClassMetaData base, ClassMetaData[] types, boolean subclasses, ExpressionFactory[] facts, QueryExpressions[] parsed, Object[] params)
ex
- current executorbase
- the base type the query should matchtypes
- the independent candidate typessubclasses
- true if subclasses should be included in the resultsfacts
- the expression factory used to build the query for
each base typeparsed
- the parsed query valuesparams
- parameter values, or empty arrayprotected Number executeUpdate(StoreQuery.Executor ex, ClassMetaData base, ClassMetaData[] types, boolean subclasses, ExpressionFactory[] facts, QueryExpressions[] parsed, Object[] params)
ex
- current executorbase
- the base type the query should matchtypes
- the independent candidate typessubclasses
- true if subclasses should be included in the resultsfacts
- the expression factory used to build the query for
each base typeparsed
- the parsed query valuesparams
- parameter values, or empty arrayprotected String[] getDataStoreActions(ClassMetaData base, ClassMetaData[] types, boolean subclasses, ExpressionFactory[] facts, QueryExpressions[] parsed, Object[] params, StoreQuery.Range range)
base
- the base type the query should matchtypes
- the independent candidate typessubclasses
- true if subclasses should be included in the resultsfacts
- the expression factory used to build the query for
each base typeparsed
- the parsed query valuesparams
- parameter values, or empty arrayrange
- result rangeprotected ClassMetaData[] getIndependentExpressionCandidates(ClassMetaData type, boolean subclasses)
protected ExpressionFactory getExpressionFactory(ClassMetaData type)
ExpressionFactory
to use to create an expression to
be executed against an extent. Each factory will be used to compile
one filter only. The factory must be cachable.Copyright © 2006–2022 Apache Software Foundation. All rights reserved.