Class JPQLQuery
- java.lang.Object
-
- org.datanucleus.store.query.Query<T>
-
- org.datanucleus.store.query.AbstractJavaQuery
-
- org.datanucleus.store.query.AbstractJPQLQuery
-
- org.datanucleus.store.rdbms.query.JPQLQuery
-
- All Implemented Interfaces:
Serializable,org.datanucleus.ExecutionContextListener
public class JPQLQuery extends org.datanucleus.store.query.AbstractJPQLQueryRDBMS representation of a JPQL 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 RDBMSQueryCompilationdatastoreCompilationThe compilation of the query for this datastore.static StringEXTENSION_CANDIDATE_DONT_RESTRICT_DISCRIMINATORExtension to not apply a discriminator restriction on the candidate of the query.static StringEXTENSION_FOR_UPDATE_NOWAITExtension to add NOWAIT when using FOR UPDATE (when supported).static StringEXTENSION_INCLUDE_SOFT_DELETESExtension to include soft-deleted objects in any results.static StringEXTENSION_NAVIGATION_JOIN_TYPEExtension to define the JOIN TYPE to use when navigating single-valued relations.static StringEXTENSION_NAVIGATION_JOIN_TYPE_FILTERExtension to define the JOIN TYPE to use when navigating single-valued relations, when part of the filter.static StringEXTENSION_USE_IS_NULL_WHEN_EQUALS_NULL_PARAMExtension 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 JPQLQuery(org.datanucleus.store.StoreManager storeMgr, org.datanucleus.ExecutionContext ec)Constructs a new query instance that uses the given object manager.JPQLQuery(org.datanucleus.store.StoreManager storeMgr, org.datanucleus.ExecutionContext ec, String query)Constructor for a JPQL query where the query is specified using the "Single-String" format.JPQLQuery(org.datanucleus.store.StoreManager storeMgr, org.datanucleus.ExecutionContext ec, JPQLQuery 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 voidaddExtension(String key, Object value)Add a vendor-specific extension this query.protected voidassertSupportsCancel()Method that will throw anUnsupportedOperationExceptionif the query implementation doesn't support cancelling queries.protected booleancancelTaskObject(Object obj)protected voidcompileInternal(Map parameterValues)Method to compile the JPQL query.protected voidcompileQueryDelete(Map parameterValues, org.datanucleus.metadata.AbstractClassMetaData candidateCmd)Method to compile the query for RDBMS for a bulk delete.protected voidcompileQueryInsert(Map parameterValues, org.datanucleus.metadata.AbstractClassMetaData candidateCmd)Method to compile the query for RDBMS for a bulk INSERT.protected voidcompileQueryUpdate(Map parameterValues, org.datanucleus.metadata.AbstractClassMetaData candidateCmd)Method to compile the query for RDBMS for a bulk update.protected voiddiscardCompiled()Utility to remove any previous compilation of this Query.RDBMSQueryCompilationgetDatastoreCompilation()ObjectgetNativeQuery()protected StringgetQueryCacheKey()Method to get key for query cacheStringgetSQL()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 booleanisCompiled()Method to return if the query is compiled.protected ObjectperformExecute(Map parameters)booleanprocessesRangeInDatastoreQuery()voidsetExtensions(Map extensions)Set multiple extensions, or use null to clear extensions.voidsetImplicitParameter(int position, Object value)voidsetImplicitParameter(String name, Object value)protected booleansupportsTimeout()Convenience method for whether this query supports timeouts.-
Methods inherited from class org.datanucleus.store.query.AbstractJPQLQuery
compileGeneric, compileSubqueries, getLanguage, getSingleStringQuery, resolveClassDeclaration, setResult
-
Methods inherited from class org.datanucleus.store.query.AbstractJavaQuery
dereferenceFilter, evaluateInMemory, 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, setCacheResults, setCandidateClass, setCandidateClassName, setCompilation, setDatastoreReadTimeoutMillis, setDatastoreWriteTimeoutMillis, setFetchPlan, setFilter, setFrom, setGrouping, setHaving, setIgnoreCache, 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 false to comply with JPA spec 4.11.
-
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_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
-
JPQLQuery
public JPQLQuery(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
-
JPQLQuery
public JPQLQuery(org.datanucleus.store.StoreManager storeMgr, org.datanucleus.ExecutionContext ec, JPQLQuery 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.
-
JPQLQuery
public JPQLQuery(org.datanucleus.store.StoreManager storeMgr, org.datanucleus.ExecutionContext ec, String query)Constructor for a JPQL query where the query is specified using the "Single-String" format.- Parameters:
storeMgr- StoreManager for this queryec- The ExecutionContextquery- The single-string query form
-
-
Method Detail
-
setImplicitParameter
public void setImplicitParameter(int position, Object value)- Overrides:
setImplicitParameterin classorg.datanucleus.store.query.Query
-
setImplicitParameter
public void setImplicitParameter(String name, Object value)
- Overrides:
setImplicitParameterin classorg.datanucleus.store.query.Query
-
discardCompiled
protected void discardCompiled()
Utility to remove any previous compilation of this Query.- Overrides:
discardCompiledin classorg.datanucleus.store.query.AbstractJavaQuery
-
isCompiled
protected boolean isCompiled()
Method to return if the query is compiled.- Overrides:
isCompiledin classorg.datanucleus.store.query.Query- Returns:
- Whether it is compiled
-
getQueryCacheKey
protected String getQueryCacheKey()
Method to get key for query cache- Overrides:
getQueryCacheKeyin classorg.datanucleus.store.query.AbstractJPQLQuery- Returns:
- The cache key
-
compileInternal
protected void compileInternal(Map parameterValues)
Method to compile the JPQL query. Uses the superclass to compile the generic query populating the "compilation", and then generates the datastore-specific "datastoreCompilation".- Overrides:
compileInternalin classorg.datanucleus.store.query.AbstractJPQLQuery- 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:
performExecutein classorg.datanucleus.store.query.Query
-
assertSupportsCancel
protected void assertSupportsCancel()
Method that will throw anUnsupportedOperationExceptionif the query implementation doesn't support cancelling queries.- Overrides:
assertSupportsCancelin classorg.datanucleus.store.query.Query
-
cancelTaskObject
protected boolean cancelTaskObject(Object obj)
- Overrides:
cancelTaskObjectin classorg.datanucleus.store.query.Query
-
supportsTimeout
protected boolean supportsTimeout()
Convenience method for whether this query supports timeouts.- Overrides:
supportsTimeoutin classorg.datanucleus.store.query.Query- Returns:
- Whether timeouts are supported.
-
compileQueryInsert
protected void compileQueryInsert(Map parameterValues, org.datanucleus.metadata.AbstractClassMetaData candidateCmd)
Method to compile the query for RDBMS for a bulk INSERT.- Parameters:
parameterValues- The parameter values (if any)candidateCmd- Meta-data for the candidate class
-
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:
processesRangeInDatastoreQueryin 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:
getSupportedExtensionsin classorg.datanucleus.store.query.AbstractJPQLQuery- 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:
addExtensionin 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 setting of in-memory evaluation, so we can throw away any datastore compilation.- Overrides:
setExtensionsin classorg.datanucleus.store.query.Query- Parameters:
extensions- Query extensions
-
getDatastoreCompilation
public RDBMSQueryCompilation getDatastoreCompilation()
-
getNativeQuery
public Object getNativeQuery()
- Overrides:
getNativeQueryin classorg.datanucleus.store.query.Query
-
-