Implementation of an expression-based query, which can handle
String-based query expressions such as JPQL and JDOQL.
This implementation is suitable for in-memory operation.
Override the following methods to also support datastore operation:
| Method from org.apache.openjpa.kernel.ExpressionStoreQuery Detail: |
protected Number executeDelete(Executor ex,
ClassMetaData base,
ClassMetaData[] types,
boolean subclasses,
ExpressionFactory[] facts,
QueryExpressions[] parsed,
Object[] params) {
return null;
}
Execute the given expression against the given candidate extent
and delete the instances. |
protected ResultObjectProvider executeQuery(Executor ex,
ClassMetaData base,
ClassMetaData[] types,
boolean subclasses,
ExpressionFactory[] facts,
QueryExpressions[] parsed,
Object[] params,
Range range) {
throw new UnsupportedException();
}
Execute the given expression against the given candidate extent. |
protected Number executeUpdate(Executor ex,
ClassMetaData base,
ClassMetaData[] types,
boolean subclasses,
ExpressionFactory[] facts,
QueryExpressions[] parsed,
Object[] params) {
return null;
}
Execute the given expression against the given candidate extent
and updates the instances. |
protected String[] getDataStoreActions(ClassMetaData base,
ClassMetaData[] types,
boolean subclasses,
ExpressionFactory[] facts,
QueryExpressions[] parsed,
Object[] params,
Range range) {
return StoreQuery.EMPTY_STRINGS;
}
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) {
throw new UnsupportedException();
}
Return an 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. |
public FilterListener getFilterListener(String tag) {
for (int i = 0; i < _listeners.length; i++)
if (_listeners[i].getTag().equals(tag))
return _listeners[i];
return null;
}
|
protected ClassMetaData[] getIndependentExpressionCandidates(ClassMetaData type,
boolean subclasses) {
return new ClassMetaData[]{ type };
}
Return the assignable types for the given metadata whose expression
trees must be compiled independently. |
public Resolver getResolver() {
return new Resolver() {
public Class classForName(String name, String[] imports) {
return ctx.classForName(name, imports);
}
public FilterListener getFilterListener(String tag) {
return ctx.getFilterListener(tag);
}
public AggregateListener getAggregateListener(String tag) {
return ctx.getAggregateListener(tag);
}
public OpenJPAConfiguration getConfiguration() {
return ctx.getStoreContext().getConfiguration();
}
public QueryContext getQueryContext() {
return ctx;
}
};
}
Resolver used in parsing. |
public void invalidateCompilation() {
_parsed = null;
}
|
public Object newCompilation() {
if (_parsed != null)
return _parsed;
return _parser.parse(ctx.getQueryString(), this);
}
|
public Executor newDataStoreExecutor(ClassMetaData meta,
boolean subs) {
return new DataStoreExecutor(this, meta, subs, _parser,
ctx.getCompilation());
}
|
public Executor newInMemoryExecutor(ClassMetaData meta,
boolean subs) {
return new InMemoryExecutor(this, meta, subs, _parser,
ctx.getCompilation());
}
|
public void populateFromCompilation(Object comp) {
_parser.populate(comp, this);
}
|
public boolean setQuery(Object query) {
_parsed = query;
return true;
}
Allow direct setting of parsed state for facades that do parsing.
The facade should call this method twice: once with the query string,
and again with the parsed state. |
public boolean supportsInMemoryExecution() {
return true;
}
|