|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.openjpa.kernel.QueryImpl
public class QueryImpl
Implementation of the Query interface.
| Nested Class Summary | |
|---|---|
protected static class |
QueryImpl.Compilation
Struct of compiled query properties. |
class |
QueryImpl.RemoveOnCloseResultList
Result list that removes itself from the query's open result list when it is closed. |
| Field Summary |
|---|
| Fields inherited from interface org.apache.openjpa.kernel.QueryOperations |
|---|
OP_DELETE, OP_SELECT, OP_UPDATE |
| Fields inherited from interface org.apache.openjpa.kernel.QueryFlushModes |
|---|
FLUSH_FALSE, FLUSH_TRUE, FLUSH_WITH_CONNECTION |
| Constructor Summary | |
|---|---|
QueryImpl(Broker broker,
String language,
StoreQuery storeQuery)
Construct a query managed by the given broker. |
|
| Method Summary | |
|---|---|
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,
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 ResultList |
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 |
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 |
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. |
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 |
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. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public QueryImpl(Broker broker,
String language,
StoreQuery storeQuery)
| Method Detail |
|---|
public StoreQuery getStoreQuery()
public Broker getBroker()
Query
getBroker in interface Querypublic Query getQuery()
QueryContext
getQuery in interface QueryContextpublic StoreContext getStoreContext()
QueryContext
getStoreContext in interface QueryContextpublic String getLanguage()
QueryContext
getLanguage in interface QueryContextpublic FetchConfiguration getFetchConfiguration()
QueryContext
getFetchConfiguration in interface QueryContextpublic String getQueryString()
QueryContext
getQueryString in interface QueryContextpublic boolean getIgnoreChanges()
QueryContext
getIgnoreChanges in interface QueryContextpublic void setIgnoreChanges(boolean flag)
Query
setIgnoreChanges in interface Querypublic boolean isReadOnly()
QueryContext
isReadOnly in interface QueryContextpublic void setReadOnly(boolean flag)
QueryContext
setReadOnly in interface QueryContextpublic void addFilterListener(FilterListener listener)
Query
addFilterListener in interface Querypublic void removeFilterListener(FilterListener listener)
Query
removeFilterListener in interface Querypublic Collection getFilterListeners()
QueryContext
getFilterListeners in interface QueryContextpublic FilterListener getFilterListener(String tag)
QueryContext
getFilterListener in interface QueryContextpublic void addAggregateListener(AggregateListener listener)
Query
addAggregateListener in interface Querypublic void removeAggregateListener(AggregateListener listener)
Query
removeAggregateListener in interface Querypublic Collection getAggregateListeners()
QueryContext
getAggregateListeners in interface QueryContextpublic AggregateListener getAggregateListener(String tag)
QueryContext
getAggregateListener in interface QueryContextpublic Extent getCandidateExtent()
Querynull if a
collection was specified instead of an extent.
getCandidateExtent in interface Querypublic void setCandidateExtent(Extent candidateExtent)
Query
setCandidateExtent in interface Querypublic Collection getCandidateCollection()
QueryContextnull if an
extent was specified instead of a collection.
getCandidateCollection in interface QueryContextpublic void setCandidateCollection(Collection candidateCollection)
Query
setCandidateCollection in interface Querypublic Class getCandidateType()
QueryContextnull if this information is not available / not relevant.
getCandidateType in interface QueryContext
public void setCandidateType(Class candidateClass,
boolean subs)
QueryContext
setCandidateType in interface QueryContextpublic boolean hasSubclasses()
QueryContext
hasSubclasses in interface QueryContextpublic String getResultMappingName()
QueryContext
getResultMappingName in interface QueryContextpublic Class getResultMappingScope()
QueryContext
getResultMappingScope in interface QueryContext
public void setResultMapping(Class scope,
String name)
QueryContext
setResultMapping in interface QueryContextpublic boolean isUnique()
QueryContext
isUnique in interface QueryContextpublic void setUnique(boolean unique)
QueryContext
setUnique in interface QueryContextpublic Class getResultType()
QueryContextQueryContext.setResultType(java.lang.Class), or null if none.
getResultType in interface QueryContextpublic void setResultType(Class cls)
QueryContext
setResultType in interface QueryContextpublic long getStartRange()
QueryContext
getStartRange in interface QueryContextpublic long getEndRange()
QueryContextLong.MAX_VALUE for no limit.
getEndRange in interface QueryContext
public void setRange(long start,
long end)
QueryContext
setRange in interface QueryContextstart - 0-based inclusive start indexend - 0-based exclusive end index, or
Long.MAX_VALUE for no limitpublic String getParameterDeclaration()
QueryContext
getParameterDeclaration in interface QueryContextpublic void declareParameters(String params)
QueryContext
declareParameters in interface QueryContextpublic void compile()
Query
compile in interface Querypublic Object getCompilation()
QueryContext
getCompilation in interface QueryContextprotected QueryImpl.Compilation compilationFromCache()
public Object execute()
Query
execute in interface Querypublic Object execute(Object[] params)
Query
execute in interface Querypublic Object execute(Map params)
Query
execute in interface Querypublic long deleteAll()
Query
deleteAll in interface Querypublic long deleteAll(Object[] params)
Query
deleteAll in interface Queryparams - the poitional parameters for the query
public long deleteAll(Map params)
Query
deleteAll in interface Queryparams - the named parameter map
public long updateAll()
Query
updateAll in interface Querypublic long updateAll(Object[] params)
Query
updateAll in interface Queryparams - the positional parameter array
public long updateAll(Map params)
Query
updateAll in interface Queryparams - the named parameter map
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
Exceptionprotected ResultList decorateResultList(ResultList res)
public static boolean isAccessPathDirty(Broker broker,
ClassMetaData[] accessMetas)
public void closeAll()
Query
closeAll in interface Querypublic void closeResources()
Query
closeResources in interface Querypublic String[] getDataStoreActions(Map params)
Query
getDataStoreActions in interface Queryparams - the named parameter map for the query invocationpublic boolean setQuery(Object query)
Query
setQuery in interface Querypublic String getAlias()
QueryContext
getAlias in interface QueryContextpublic String[] getProjectionAliases()
QueryContext
getProjectionAliases in interface QueryContextpublic Class[] getProjectionTypes()
QueryContext
getProjectionTypes in interface QueryContextpublic int getOperation()
QueryContext
getOperation in interface QueryContextQueryOperationspublic boolean isAggregate()
QueryContext
isAggregate in interface QueryContextpublic boolean hasGrouping()
QueryContext
hasGrouping in interface QueryContextpublic ClassMetaData[] getAccessPathMetaDatas()
QueryContext
getAccessPathMetaDatas in interface QueryContextpublic LinkedMap getParameterTypes()
QueryContext
getParameterTypes in interface QueryContextpublic Map getUpdates()
QueryContextFieldMetaDatas to Constants.
getUpdates in interface QueryContextpublic void lock()
QueryContext
lock in interface QueryContextpublic void unlock()
QueryContext
unlock in interface QueryContext
public Class classForName(String name,
String[] imports)
QueryContext
classForName in interface QueryContextpublic void assertOpen()
Query
assertOpen in interface Querypublic void assertNotReadOnly()
Query
assertNotReadOnly in interface Querypublic void assertNotSerialized()
Query
assertNotSerialized in interface Query
protected void assertParameters(StoreQuery q,
StoreQuery.Executor ex,
Object[] params)
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||