public class DelegatingQuery extends Object implements Query
OP_DELETE, OP_SELECT, OP_UPDATE
FLUSH_FALSE, FLUSH_TRUE, FLUSH_WITH_CONNECTION
Constructor and Description |
---|
DelegatingQuery(Query query)
Constructor; supply delegate.
|
DelegatingQuery(Query query,
RuntimeExceptionTranslator trans)
Constructor; supply delegate and exception translator.
|
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.
|
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.
|
void |
compile()
Compile the query.
|
void |
declareParameters(String params)
Declared parameters, for query languages that use them.
|
long |
deleteAll()
Deletes all of the instances that are satisfied by the query.
|
long |
deleteAll(Map parameterMap)
Deletes all of the instances that are satisfied by the query.
|
long |
deleteAll(Object[] parameters)
Deletes all of the instances that are satisfied by the query.
|
Number |
deleteInMemory(StoreQuery q,
StoreQuery.Executor ex,
Object[] params)
Helper method to delete the objects found by executing a query on
the given executor.
|
boolean |
equals(Object other) |
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 |
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.
|
Query |
getDelegate()
Return the direct delegate.
|
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 |
getFilterListeners()
The set of filter listeners.
|
boolean |
getIgnoreChanges()
Whether to ignore changes in the current transaction.
|
Query |
getInnermostDelegate()
Return the native delegate.
|
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.
|
org.apache.commons.collections4.map.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.
|
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.
|
int |
hashCode() |
boolean |
hasSubclasses()
Whether query results will include subclasses of the candidate class.
|
boolean |
isAggregate()
Return true if the query is an aggregate.
|
boolean |
isDistinct()
Affirms if this query results are distinct instance(s).
|
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 coll)
Set a collection of candidates.
|
void |
setCandidateExtent(Extent extent)
Set the candidate extent.
|
void |
setCandidateType(Class cls,
boolean subs)
Set the candidate type.
|
void |
setIgnoreChanges(boolean ignore)
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 readOnly)
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.
|
protected RuntimeException |
translate(RuntimeException re)
Translate the OpenJPA exception.
|
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 parameterMap)
Performs an update of the instances that are satisfied by the query.
|
long |
updateAll(Object[] parameters)
Performs an update of the instances that are satisfied by the query.
|
Number |
updateInMemory(StoreQuery q,
StoreQuery.Executor ex,
Object[] params)
Helper method to update the objects found by executing a query on
the given executor.
|
public DelegatingQuery(Query query)
public DelegatingQuery(Query query, RuntimeExceptionTranslator trans)
public Query getDelegate()
public Query getInnermostDelegate()
protected RuntimeException translate(RuntimeException re)
public Broker getBroker()
Query
public Query getQuery()
QueryContext
getQuery
in interface QueryContext
public StoreContext getStoreContext()
QueryContext
getStoreContext
in interface QueryContext
public int getOperation()
QueryContext
getOperation
in interface QueryContext
QueryOperations
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 Object getCompilation()
QueryContext
getCompilation
in interface QueryContext
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 boolean isAggregate()
QueryContext
isAggregate
in interface QueryContext
public boolean hasGrouping()
QueryContext
hasGrouping
in interface QueryContext
public ClassMetaData[] getAccessPathMetaDatas()
QueryContext
getAccessPathMetaDatas
in interface QueryContext
public FilterListener getFilterListener(String tag)
QueryContext
getFilterListener
in interface QueryContext
public AggregateListener getAggregateListener(String tag)
QueryContext
getAggregateListener
in interface QueryContext
public Collection getFilterListeners()
QueryContext
getFilterListeners
in interface QueryContext
public Collection getAggregateListeners()
QueryContext
getAggregateListeners
in interface QueryContext
public Collection getCandidateCollection()
QueryContext
null
if an
extent was specified instead of a collection.getCandidateCollection
in interface QueryContext
public Class getCandidateType()
QueryContext
null
if this information is not available / not relevant.getCandidateType
in interface QueryContext
public boolean hasSubclasses()
QueryContext
hasSubclasses
in interface QueryContext
public void setCandidateType(Class cls, boolean subs)
QueryContext
setCandidateType
in interface QueryContext
public boolean isReadOnly()
QueryContext
isReadOnly
in interface QueryContext
public void setReadOnly(boolean readOnly)
QueryContext
setReadOnly
in interface QueryContext
public Class getResultMappingScope()
QueryContext
getResultMappingScope
in interface QueryContext
public String getResultMappingName()
QueryContext
getResultMappingName
in interface QueryContext
public void setResultMapping(Class scope, String name)
QueryContext
setResultMapping
in interface QueryContext
public boolean isUnique()
QueryContext
isUnique
in interface QueryContext
public void setUnique(boolean unique)
QueryContext
setUnique
in interface QueryContext
public boolean isDistinct()
QueryContext
isDistinct
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 OrderedMap<Object,Class<?>> getOrderedParameterTypes()
QueryContext
getOrderedParameterTypes
in interface QueryContext
public org.apache.commons.collections4.map.LinkedMap getParameterTypes()
QueryContext
getParameterTypes
in interface QueryContext
public Map getUpdates()
QueryContext
FieldMetaData
s to Constant
s.getUpdates
in interface QueryContext
public void declareParameters(String params)
QueryContext
declareParameters
in interface QueryContext
public Number deleteInMemory(StoreQuery q, StoreQuery.Executor ex, Object[] params)
QueryContext
deleteInMemory
in interface QueryContext
public Number updateInMemory(StoreQuery q, StoreQuery.Executor ex, Object[] params)
QueryContext
updateInMemory
in interface QueryContext
public Class classForName(String name, String[] imports)
QueryContext
classForName
in interface QueryContext
public void lock()
QueryContext
lock
in interface QueryContext
public void unlock()
QueryContext
unlock
in interface QueryContext
public void addFilterListener(FilterListener listener)
Query
addFilterListener
in interface Query
public void removeFilterListener(FilterListener listener)
Query
removeFilterListener
in interface Query
public void addAggregateListener(AggregateListener listener)
Query
addAggregateListener
in interface Query
public void removeAggregateListener(AggregateListener listener)
Query
removeAggregateListener
in interface Query
public Extent getCandidateExtent()
Query
null
if a
collection was specified instead of an extent.getCandidateExtent
in interface Query
public void setCandidateExtent(Extent extent)
Query
setCandidateExtent
in interface Query
public void setCandidateCollection(Collection coll)
Query
setCandidateCollection
in interface Query
public void compile()
Query
public Object execute(Map params)
Query
public Object execute(Object[] params)
Query
public long deleteAll()
Query
public long deleteAll(Object[] parameters)
Query
public long deleteAll(Map parameterMap)
Query
public long updateAll()
Query
public long updateAll(Object[] parameters)
Query
public long updateAll(Map parameterMap)
Query
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 void setIgnoreChanges(boolean ignore)
Query
setIgnoreChanges
in interface Query
public void assertOpen()
Query
assertOpen
in interface Query
public void assertNotReadOnly()
Query
assertNotReadOnly
in interface Query
public void assertNotSerialized()
Query
assertNotSerialized
in interface Query
Copyright © 2006–2020 Apache Software Foundation. All rights reserved.