Class JDOQuery<T>
java.lang.Object
org.datanucleus.api.jdo.JDOQuery<T>
- Type Parameters:
T- Candidate class for this query
- All Implemented Interfaces:
Serializable, AutoCloseable, javax.jdo.Query<T>
Wrapper for JDO Query class.
Stores the PM the query is executed against, the internal query, and the query language.
The language is stored since it is referenced by the JDO API and so we don't have to embody knowledge
of which internal query type is for which language (could be moved to the internal query).
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean(package private) JDOFetchPlanJDO Fetch Plan.static final Stringstatic final String(package private) StringQuery language.(package private) MapMap of parameters keyed by their name.(package private) Object[]Positional parameter values.(package private) javax.jdo.PersistenceManagerPersistenceManager for the query.static final String(package private) org.datanucleus.store.query.Query<T> Underlying query that will be executed.private static final longstatic final StringFields inherited from interface javax.jdo.Query
JDOQL, SQL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExtension(String key, Object value) Method to add an extension to the query.voidaddSubquery(javax.jdo.Query sub, String variableDecl, String candidateExpr) Add a subquery to this query.voidaddSubquery(javax.jdo.Query sub, String variableDecl, String candidateExpr, String parameter) Add a subquery to this query.voidaddSubquery(javax.jdo.Query sub, String variableDecl, String candidateExpr, String... parameters) Add a subquery to this query.voidaddSubquery(javax.jdo.Query sub, String variableDecl, String candidateExpr, Map parameters) Add a subquery to this query.protected voidMethod to assert if this Query is open.voidMethod to cancel the executing query for the supplied thread.voidMethod to cancel any executing queries.voidclose()voidClose the query result.voidcloseAll()Close all query results for this query.voidcompile()Compile the query.javax.jdo.Query<T> datastoreReadTimeoutMillis(Integer interval) javax.jdo.Query<T> datastoreWriteTimeoutMillis(Integer interval) voiddeclareImports(String imports) Declare any imports for the query.voiddeclareParameters(String parameters) Declare any parameters for the query.voiddeclareVariables(String variables) Declare any variables for the query.longExecute the query deleting all instances found.longdeletePersistentAll(Object... parameters) Execute the query deleting all instances found.longdeletePersistentAll(Map parameters) Execute the query deleting all instances found.protected longexecute()Execute the query.Execute the query.Execute the query.Execute the query.protected Object<R> List<R> executeResultList(Class<R> resultCls) <R> RexecuteResultUnique(Class<R> resultCls) executeWithArray(Object... parameterValues) Execute the query.executeWithMap(Map parameters) Execute the query.javax.jdo.Query<T> javax.jdo.Query<T> extensions(Map values) javax.jdo.Query<T> Accessor for the datastore read timeout.Accessor for the datastore write timeout.javax.jdo.FetchPlanAccessor for the fetch plan to use.booleanAccessor for the ignore cache settingorg.datanucleus.store.query.Query<T> Accessor for the internal query.Accessor for the query language.Accessor for the native query invoked by this query (if known at this time and supported by the store plugin).javax.jdo.PersistenceManagerAccessor for the PersistenceManager.Accessor for whether to serialise any read objects in this query.javax.jdo.Query<T> javax.jdo.Query<T> ignoreCache(boolean flag) javax.jdo.Query<T> booleanisClosed()Accessor for whether this Query is closed.booleanAccessor for whether the query is modifiable.javax.jdo.Query<T> javax.jdo.Query<T> parameters(String parameters) javax.jdo.Query<T> range(long fromIncl, long toExcl) javax.jdo.Query<T> javax.jdo.Query<T> javax.jdo.Query<T> saveAsNamedQuery(String name) Save this query as a named query with the specified name.javax.jdo.Query<T> serializeRead(Boolean serialize) voidsetCandidates(Collection<T> pcs) Set the candidates for the query.voidsetCandidates(javax.jdo.Extent<T> extent) Set the candidates for the query.voidSet the candidate class for the query.voidsetDatastoreReadTimeoutMillis(Integer timeout) Set the datastore read timeout.voidsetDatastoreWriteTimeoutMillis(Integer timeout) Set the datastore write timeout.voidsetExtensions(Map extensions) Set the extensions for the query.voidSet the filter for the query.voidsetGrouping(String grouping) Set the grouping for the query.voidsetIgnoreCache(boolean ignoreCache) Set the ignore cache setting for the query.javax.jdo.Query<T> setNamedParameters(Map<String, ?> paramMap) voidsetOrdering(String ordering) Set the ordering for the query.javax.jdo.Query<T> setParameters(Object... paramValues) voidsetRange(long fromIncl, long toExcl) Set the range for the query.voidSet the range for the query.voidSet the result for the query.voidsetResultClass(Class result_cls) Set the result class for the query.voidsetSerializeRead(Boolean serialize) Mutator for whether to serialise any read objects.voidsetUnique(boolean unique) Set whether to expect a unique result.voidSet the query to be unmodifiable.javax.jdo.Query<T> javax.jdo.Query<T> javax.jdo.Query<T> javax.jdo.Query<T> toString()Convenience method to return the query in string form.javax.jdo.Query<T> javax.jdo.Query<T>
-
Field Details
-
PROPERTY_CLOSEABLE_QUERY
- See Also:
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
JDOQL_QUERY_LANGUAGE
- See Also:
-
JPQL_QUERY_LANGUAGE
- See Also:
-
SQL_QUERY_LANGUAGE
- See Also:
-
pm
transient javax.jdo.PersistenceManager pmPersistenceManager for the query. -
query
org.datanucleus.store.query.Query<T> queryUnderlying query that will be executed. -
closed
private boolean closed -
language
String languageQuery language. -
fetchPlan
JDOFetchPlan fetchPlanJDO Fetch Plan. -
parameterValueByName
Map parameterValueByNameMap of parameters keyed by their name. -
parameterValues
Object[] parameterValuesPositional parameter values.
-
-
Constructor Details
-
JDOQuery
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacejavax.jdo.Query<T>
-
isClosed
public boolean isClosed()Accessor for whether this Query is closed.- Returns:
- Whether this Query is closed.
-
close
-
closeAll
public void closeAll()Close all query results for this query.- Specified by:
closeAllin interfacejavax.jdo.Query<T>
-
compile
-
declareImports
-
declareParameters
-
declareVariables
-
imports
-
parameters
-
variables
-
setParameters
-
setNamedParameters
-
execute
-
execute
-
execute
-
execute
-
executeWithArray
-
executeWithMap
-
executeList
-
executeUnique
-
executeResultList
-
executeResultUnique
-
executeResultList
-
executeResultUnique
-
executeInternal
-
deletePersistentAll
public long deletePersistentAll()Execute the query deleting all instances found.- Specified by:
deletePersistentAllin interfacejavax.jdo.Query<T>- Returns:
- Number of deleted instances
-
deletePersistentAll
-
deletePersistentAll
-
deletePersistentInternal
protected long deletePersistentInternal() -
cancelAll
public void cancelAll()Method to cancel any executing queries.- Specified by:
cancelAllin interfacejavax.jdo.Query<T>- Throws:
javax.jdo.JDOUnsupportedOptionException- if the datastore doesn't support cancellation of queries
-
cancel
-
setCandidates
-
setCandidates
Set the candidates for the query.- Specified by:
setCandidatesin interfacejavax.jdo.Query<T>- Parameters:
pcs- PC candidates
-
setClass
-
addExtension
-
setExtensions
-
extension
-
extensions
-
getFetchPlan
public javax.jdo.FetchPlan getFetchPlan()Accessor for the fetch plan to use.- Specified by:
getFetchPlanin interfacejavax.jdo.Query<T>- Returns:
- The fetch plan
-
filter
-
setFilter
-
groupBy
-
setGrouping
-
getIgnoreCache
public boolean getIgnoreCache()Accessor for the ignore cache setting- Specified by:
getIgnoreCachein interfacejavax.jdo.Query<T>- Returns:
- Ignore cache
-
setIgnoreCache
public void setIgnoreCache(boolean ignoreCache) Set the ignore cache setting for the query.- Specified by:
setIgnoreCachein interfacejavax.jdo.Query<T>- Parameters:
ignoreCache- The ignore cache setting
-
ignoreCache
-
orderBy
-
setOrdering
-
getPersistenceManager
public javax.jdo.PersistenceManager getPersistenceManager()Accessor for the PersistenceManager.- Specified by:
getPersistenceManagerin interfacejavax.jdo.Query<T>- Returns:
- PM
-
range
-
range
-
setRange
-
setRange
public void setRange(long fromIncl, long toExcl) Set the range for the query.- Specified by:
setRangein interfacejavax.jdo.Query<T>- Parameters:
fromIncl- From range inclusivetoExcl- To range exclusive
-
result
-
setResult
-
setResultClass
-
setDatastoreReadTimeoutMillis
-
getDatastoreReadTimeoutMillis
-
setDatastoreWriteTimeoutMillis
-
getDatastoreWriteTimeoutMillis
-
datastoreReadTimeoutMillis
-
datastoreWriteTimeoutMillis
-
setUnique
public void setUnique(boolean unique) Set whether to expect a unique result.- Specified by:
setUniquein interfacejavax.jdo.Query<T>- Parameters:
unique- Whether results are unique
-
isUnmodifiable
public boolean isUnmodifiable()Accessor for whether the query is modifiable.- Specified by:
isUnmodifiablein interfacejavax.jdo.Query<T>- Returns:
- Whether it is modifiable
-
setUnmodifiable
public void setUnmodifiable()Set the query to be unmodifiable.- Specified by:
setUnmodifiablein interfacejavax.jdo.Query<T>
-
unmodifiable
-
addSubquery
Add a subquery to this query.- Specified by:
addSubqueryin interfacejavax.jdo.Query<T>- Parameters:
sub- the subquery to add to this QueryvariableDecl- the name of the variable in the outer query to bind the results of the subquerycandidateExpr- the candidate collection of the subquery as an expression using terms of the outer query
-
addSubquery
public void addSubquery(javax.jdo.Query sub, String variableDecl, String candidateExpr, String parameter) Add a subquery to this query. The String version of the method binds the named expression to the parameter implictly or explicitly declared in the subquery.- Specified by:
addSubqueryin interfacejavax.jdo.Query<T>- Parameters:
sub- the subquery to add to this QueryvariableDecl- the name of the variable to be used in this QuerycandidateExpr- the candidate collection to apply to the subqueryparameter- the expression from the outer query to bind the parameter in the subquery
-
addSubquery
public void addSubquery(javax.jdo.Query sub, String variableDecl, String candidateExpr, String... parameters) Add a subquery to this query. The String version of the method binds the named expression to the parameter implictly or explicitly declared in the subquery.- Specified by:
addSubqueryin interfacejavax.jdo.Query<T>- Parameters:
sub- the subquery to add to this QueryvariableDecl- the name of the variable to be used in this QuerycandidateExpr- the candidate collection to apply to the subqueryparameters- the expressions from the outer query to bind the parameter in the subquery
-
addSubquery
public void addSubquery(javax.jdo.Query sub, String variableDecl, String candidateExpr, Map parameters) Add a subquery to this query. The String version of the method binds the named expression to the parameter implictly or explicitly declared in the subquery.- Specified by:
addSubqueryin interfacejavax.jdo.Query<T>- Parameters:
sub- the subquery to add to this QueryvariableDecl- the name of the variable to be used in this QuerycandidateExpr- the candidate collection to apply to the subqueryparameters- the expressions from the outer query to bind the parameter in the subquery
-
subquery
-
subquery
-
subquery
-
subquery
-
getSerializeRead
-
setSerializeRead
-
serializeRead
-
getInternalQuery
Accessor for the internal query.- Returns:
- Internal query
-
getLanguage
-
saveAsNamedQuery
-
toString
-
getNativeQuery
Accessor for the native query invoked by this query (if known at this time and supported by the store plugin).- Returns:
- The native query (e.g for RDBMS this is the SQL).
-
assertIsOpen
protected void assertIsOpen()Method to assert if this Query is open.- Throws:
javax.jdo.JDOFatalUserException- if the Query is closed.
-