Class JDOQLQuery
- java.lang.Object
-
- org.datanucleus.store.query.Query<T>
-
- org.datanucleus.store.query.AbstractJavaQuery
-
- org.datanucleus.store.query.AbstractJDOQLQuery
-
- org.datanucleus.store.rdbms.query.JDOQLQuery
-
- All Implemented Interfaces:
Serializable
,org.datanucleus.ExecutionContextListener
public class JDOQLQuery extends org.datanucleus.store.query.AbstractJDOQLQuery
RDBMS representation of a JDOQL query for use by DataNucleus. The query can be specified via method calls, or via a single-string form. This implementation uses the generic query compilation in "org.datanucleus.query". There are the following main ways of running a query here- Totally in the datastore (no candidate collection specified, and no in-memory eval).
- Totally in-memory (candidate collection specified, and in-memory eval)
- Retrieve candidates from datastore (no candidate collection), and evaluate in-memory
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected RDBMSQueryCompilation
datastoreCompilation
The compilation of the query for this datastore.static String
EXTENSION_CANDIDATE_DONT_RESTRICT_DISCRIMINATOR
Extension to not apply a discriminator restriction on the candidate of the query.static String
EXTENSION_FOR_UPDATE_NOWAIT
Extension to add NOWAIT when using FOR UPDATE (when supported).static String
EXTENSION_INCLUDE_SOFT_DELETES
Extension to include soft-deleted objects in any results.static String
EXTENSION_NAVIGATION_JOIN_TYPE
Extension to define the JOIN TYPE to use when navigating single-valued relations.static String
EXTENSION_NAVIGATION_JOIN_TYPE_FILTER
Extension to define the JOIN TYPE to use when navigating single-valued relations, when part of the filter.static String
EXTENSION_NON_DISTINCT_IMPLICIT_JOIN
Extension for whether to disable the setting of DISTINCT when joining with JDOQL.static String
EXTENSION_USE_IS_NULL_WHEN_EQUALS_NULL_PARAM
Extension for whether to convert "== ?" with null parameter to "IS NULL".-
Fields inherited from class org.datanucleus.store.query.AbstractJavaQuery
candidateCollection, singleString
-
Fields inherited from class org.datanucleus.store.query.Query
candidateClass, candidateClassName, clr, compilation, ec, explicitParameters, explicitVariables, EXTENSION_CHECK_UNUSED_PARAMETERS, EXTENSION_CLOSE_RESULTS_AT_EC_CLOSE, EXTENSION_COMPILATION_CACHED, EXTENSION_COMPILE_OPTIMISE_VAR_THIS, EXTENSION_EVALUATE_IN_MEMORY, EXTENSION_EXCLUDE_SUBCLASSES, EXTENSION_FLUSH_BEFORE_EXECUTION, EXTENSION_JDOQL_ALLOW_ALL, EXTENSION_JDOQL_STRICT, EXTENSION_JPQL_ALLOW_RANGE, EXTENSION_JPQL_STRICT, EXTENSION_LOAD_RESULTS_AT_COMMIT, EXTENSION_QUERY_TYPE, EXTENSION_RESULT_CACHE_TYPE, EXTENSION_RESULT_CACHE_VALIDATE_OBJECTS, EXTENSION_RESULT_SIZE_METHOD, EXTENSION_RESULTS_CACHED, EXTENSION_SQL_ALLOW_ALL, EXTENSION_SQL_SYNTAX_CHECKS, EXTENSION_UPDATE_ALL_CANDIDATE_FIELDS, EXTENSION_USE_FETCH_PLAN, extensions, filter, from, fromInclNo, fromInclParam, grouping, having, ignoreCache, implicitParameters, imports, inputParameters, insertFields, insertSelectQuery, ordering, parameterNames, parsedImports, queryResults, range, result, resultClass, resultClassName, resultDistinct, storeMgr, subclasses, subqueries, tasks, toExclNo, toExclParam, type, unique, unmodifiable, update
-
-
Constructor Summary
Constructors Constructor Description JDOQLQuery(org.datanucleus.store.StoreManager storeMgr, org.datanucleus.ExecutionContext ec)
Constructs a new query instance that uses the given object manager.JDOQLQuery(org.datanucleus.store.StoreManager storeMgr, org.datanucleus.ExecutionContext ec, String query)
Constructor for a JDOQL query where the query is specified using the "Single-String" format.JDOQLQuery(org.datanucleus.store.StoreManager storeMgr, org.datanucleus.ExecutionContext ec, JDOQLQuery q)
Constructs a new query instance having the same criteria as the given query.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addExtension(String key, Object value)
Add a vendor-specific extension this query.protected void
assertSupportsCancel()
Method that will throw anUnsupportedOperationException
if the query implementation doesn't support cancelling queries.protected boolean
cancelTaskObject(Object obj)
protected void
compileInternal(Map parameterValues)
Method to compile the JDOQL query.protected void
compileQueryDelete(Map parameterValues, org.datanucleus.metadata.AbstractClassMetaData candidateCmd)
Method to compile the query for RDBMS for a bulk delete.protected void
compileQueryUpdate(Map parameterValues, org.datanucleus.metadata.AbstractClassMetaData candidateCmd)
Method to compile the query for RDBMS for a bulk update.protected void
discardCompiled()
Utility to remove any previous compilation of this Query.protected boolean
evaluateInMemory()
Convenience method to return whether the query should be evaluated in-memory.RDBMSQueryCompilation
getDatastoreCompilation()
Object
getNativeQuery()
protected String
getQueryCacheKey()
Method to get key for query cacheString
getSQL()
Convenience accessor for the SQL to invoke in the datastore for this query.Set<String>
getSupportedExtensions()
Method to return the names of the extensions supported by this query.protected boolean
isCompiled()
Method to return if the query is compiled.protected Object
performExecute(Map parameters)
boolean
processesRangeInDatastoreQuery()
void
setExtensions(Map extensions)
Set multiple extensions, or use null to clear extensions.protected boolean
supportsTimeout()
Convenience method for whether this query supports timeouts.-
Methods inherited from class org.datanucleus.store.query.AbstractJDOQLQuery
compileGeneric, compileSubqueries, getLanguage, getSingleStringQuery, setGrouping, setResult
-
Methods inherited from class org.datanucleus.store.query.AbstractJavaQuery
dereferenceFilter, performDeletePersistentAll, setCandidates, setCandidates, toString
-
Methods inherited from class org.datanucleus.store.query.Query
addSubquery, applyImplicitParameterValueToCompilation, applyImplicitParameterValueToSubqueries, assertIsModifiable, assertIsOpen, cancel, cancel, checkForMissingParameters, checkParameterTypesAgainstCompilation, checkUnusedParameters, close, closeAll, compile, declareExplicitParameters, declareExplicitVariables, declareImports, deepFindSymbolForParameterInCompilation, deletePersistentAll, deletePersistentAll, deletePersistentAll, deregisterTask, equals, execute, executeQuery, executeWithArray, executeWithMap, executionContextClosing, getBooleanExtensionProperty, getCandidateClass, getCandidateClassMetaData, getCandidateClassName, getCompilation, getDatastoreReadTimeoutMillis, getDatastoreWriteTimeoutMillis, getExecutionContext, getExplicitParametersDeclaration, getExplicitVariablesDeclaration, getExtension, getExtensions, getFetchPlan, getFilter, getFrom, getGrouping, getHaving, getIgnoreCache, getImplicitParameters, getImportsDeclaration, getInputParameters, getInsertFields, getInsertSelectQuery, getOrdering, getParameterMapForValues, getParsedImports, getQueryManager, getRange, getRangeFromIncl, getRangeFromInclParam, getRangeToExcl, getRangeToExclParam, getResult, getResultClass, getResultClassName, getResultDistinct, getSerializeRead, getStoreManager, getStringExtensionProperty, getSubqueryForVariable, getType, getUpdate, hashCode, hasSubqueryForVariable, isSubclasses, isUnique, isUnmodifiable, prepareDatastore, registerTask, resolveClassDeclaration, setCacheResults, setCandidateClass, setCandidateClassName, setCompilation, setDatastoreReadTimeoutMillis, setDatastoreWriteTimeoutMillis, setFetchPlan, setFilter, setFrom, setHaving, setIgnoreCache, setImplicitParameter, setImplicitParameter, setInsertFields, setInsertSelectQuery, setOrdering, setRange, setRange, setResultClass, setResultClassName, setResultDistinct, setResultMetaData, setSerializeRead, setSubclasses, setType, setUnique, setUnmodifiable, setUpdate, shouldReturnSingleRow, useCaching, useFetchPlan, useResultsCaching
-
-
-
-
Field Detail
-
EXTENSION_USE_IS_NULL_WHEN_EQUALS_NULL_PARAM
public static final String EXTENSION_USE_IS_NULL_WHEN_EQUALS_NULL_PARAM
Extension for whether to convert "== ?" with null parameter to "IS NULL". Defaults to true to match Java semantics.
-
EXTENSION_FOR_UPDATE_NOWAIT
public static final String EXTENSION_FOR_UPDATE_NOWAIT
Extension to add NOWAIT when using FOR UPDATE (when supported).
-
EXTENSION_CANDIDATE_DONT_RESTRICT_DISCRIMINATOR
public static final String EXTENSION_CANDIDATE_DONT_RESTRICT_DISCRIMINATOR
Extension to not apply a discriminator restriction on the candidate of the query.
-
EXTENSION_INCLUDE_SOFT_DELETES
public static final String EXTENSION_INCLUDE_SOFT_DELETES
Extension to include soft-deleted objects in any results.
-
EXTENSION_NON_DISTINCT_IMPLICIT_JOIN
public static final String EXTENSION_NON_DISTINCT_IMPLICIT_JOIN
Extension for whether to disable the setting of DISTINCT when joining with JDOQL.
-
EXTENSION_NAVIGATION_JOIN_TYPE_FILTER
public static final String EXTENSION_NAVIGATION_JOIN_TYPE_FILTER
Extension to define the JOIN TYPE to use when navigating single-valued relations, when part of the filter.
-
EXTENSION_NAVIGATION_JOIN_TYPE
public static final String EXTENSION_NAVIGATION_JOIN_TYPE
Extension to define the JOIN TYPE to use when navigating single-valued relations.
-
datastoreCompilation
protected transient RDBMSQueryCompilation datastoreCompilation
The compilation of the query for this datastore. Not applicable if totally in-memory.
-
-
Constructor Detail
-
JDOQLQuery
public JDOQLQuery(org.datanucleus.store.StoreManager storeMgr, org.datanucleus.ExecutionContext ec)
Constructs a new query instance that uses the given object manager.- Parameters:
storeMgr
- StoreManager for this queryec
- execution context
-
JDOQLQuery
public JDOQLQuery(org.datanucleus.store.StoreManager storeMgr, org.datanucleus.ExecutionContext ec, JDOQLQuery q)
Constructs a new query instance having the same criteria as the given query.- Parameters:
storeMgr
- StoreManager for this queryec
- execution contextq
- The query from which to copy criteria.
-
JDOQLQuery
public JDOQLQuery(org.datanucleus.store.StoreManager storeMgr, org.datanucleus.ExecutionContext ec, String query)
Constructor for a JDOQL query where the query is specified using the "Single-String" format.- Parameters:
storeMgr
- StoreManager for this queryec
- execution contextquery
- The single-string query form
-
-
Method Detail
-
discardCompiled
protected void discardCompiled()
Utility to remove any previous compilation of this Query.- Overrides:
discardCompiled
in classorg.datanucleus.store.query.AbstractJavaQuery
-
isCompiled
protected boolean isCompiled()
Method to return if the query is compiled.- Overrides:
isCompiled
in classorg.datanucleus.store.query.Query
- Returns:
- Whether it is compiled
-
evaluateInMemory
protected boolean evaluateInMemory()
Convenience method to return whether the query should be evaluated in-memory.- Overrides:
evaluateInMemory
in classorg.datanucleus.store.query.AbstractJavaQuery
- Returns:
- Use in-memory evaluation?
-
getQueryCacheKey
protected String getQueryCacheKey()
Method to get key for query cache- Overrides:
getQueryCacheKey
in classorg.datanucleus.store.query.AbstractJDOQLQuery
- Returns:
- The cache key
-
compileInternal
protected void compileInternal(Map parameterValues)
Method to compile the JDOQL query. Uses the superclass to compile the generic query populating the "compilation", and then generates the datastore-specific "datastoreCompilation".- Overrides:
compileInternal
in classorg.datanucleus.store.query.AbstractJDOQLQuery
- Parameters:
parameterValues
- Map of param values keyed by param name (if available at compile time)
-
getSQL
public String getSQL()
Convenience accessor for the SQL to invoke in the datastore for this query.- Returns:
- The SQL.
-
performExecute
protected Object performExecute(Map parameters)
- Specified by:
performExecute
in classorg.datanucleus.store.query.Query
-
assertSupportsCancel
protected void assertSupportsCancel()
Method that will throw anUnsupportedOperationException
if the query implementation doesn't support cancelling queries.- Overrides:
assertSupportsCancel
in classorg.datanucleus.store.query.Query
-
cancelTaskObject
protected boolean cancelTaskObject(Object obj)
- Overrides:
cancelTaskObject
in classorg.datanucleus.store.query.Query
-
supportsTimeout
protected boolean supportsTimeout()
Convenience method for whether this query supports timeouts.- Overrides:
supportsTimeout
in classorg.datanucleus.store.query.Query
- Returns:
- Whether timeouts are supported.
-
compileQueryUpdate
protected void compileQueryUpdate(Map parameterValues, org.datanucleus.metadata.AbstractClassMetaData candidateCmd)
Method to compile the query for RDBMS for a bulk update.- Parameters:
parameterValues
- The parameter values (if any)candidateCmd
- Meta-data for the candidate class
-
compileQueryDelete
protected void compileQueryDelete(Map parameterValues, org.datanucleus.metadata.AbstractClassMetaData candidateCmd)
Method to compile the query for RDBMS for a bulk delete.- Parameters:
parameterValues
- The parameter values (if any)candidateCmd
- Meta-data for the candidate class
-
processesRangeInDatastoreQuery
public boolean processesRangeInDatastoreQuery()
- Overrides:
processesRangeInDatastoreQuery
in classorg.datanucleus.store.query.Query
-
getSupportedExtensions
public Set<String> getSupportedExtensions()
Method to return the names of the extensions supported by this query. To be overridden by subclasses where they support additional extensions.- Overrides:
getSupportedExtensions
in classorg.datanucleus.store.query.AbstractJDOQLQuery
- Returns:
- The supported extension names
-
addExtension
public void addExtension(String key, Object value)
Add a vendor-specific extension this query. Intercepts any setting of in-memory evaluation, so we can throw away any datastore compilation.- Overrides:
addExtension
in classorg.datanucleus.store.query.Query
- Parameters:
key
- the extension keyvalue
- the extension value
-
setExtensions
public void setExtensions(Map extensions)
Set multiple extensions, or use null to clear extensions. Intercepts any settong of in-memory evaluation, so we can throw away any datastore compilation.- Overrides:
setExtensions
in classorg.datanucleus.store.query.Query
- Parameters:
extensions
- Query extensions
-
getDatastoreCompilation
public RDBMSQueryCompilation getDatastoreCompilation()
-
getNativeQuery
public Object getNativeQuery()
- Overrides:
getNativeQuery
in classorg.datanucleus.store.query.Query
-
-