org.datanucleus.store.query
Class AbstractJPQLQuery

java.lang.Object
  extended by org.datanucleus.store.query.Query
      extended by org.datanucleus.store.query.AbstractJavaQuery
          extended by org.datanucleus.store.query.AbstractJPQLQuery
All Implemented Interfaces:
java.io.Serializable

public abstract class AbstractJPQLQuery
extends AbstractJavaQuery

Abstract representation of a JPQL query used by DataNucleus. The query can be specified via method calls, or via a single-string form.

See Also:
Query, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.datanucleus.store.query.Query
Query.SubqueryDefinition
 
Field Summary
 
Fields inherited from class org.datanucleus.store.query.AbstractJavaQuery
candidateCollection, candidateExtent, resultMetaData, singleString, userDefinedScalarExpressions
 
Fields inherited from class org.datanucleus.store.query.Query
BULK_DELETE, BULK_UPDATE, candidateClass, candidateClassName, compilation, explicitParameters, explicitVariables, extensions, filter, from, fromInclNo, grouping, having, ignoreCache, IMPLICIT_POSITIONAL_PARAM_PREFIX, implicitParameters, imports, LOCALISER, om, ordering, parameterNames, parsedImports, queryResults, range, result, resultClass, resultClassName, resultDistinct, SELECT, subclasses, subqueries, toExclNo, type, unique, unmodifiable, update
 
Constructor Summary
AbstractJPQLQuery(ObjectManager om)
          Constructor.
AbstractJPQLQuery(ObjectManager om, AbstractJPQLQuery q)
          Constructs a new query instance having the same criteria as the given query.
AbstractJPQLQuery(ObjectManager om, java.lang.String query)
          Constructor for a JPQL query where the query is specified using the "Single-String" format.
 
Method Summary
protected  void compileInternal(boolean forExecute, java.util.Map parameterValues)
          Method to compile the JPQL query.
 java.lang.String getSingleStringQuery()
          Method to take the defined parameters for the query and form a single string.
 java.lang.Class resolveClassDeclaration(java.lang.String classDecl)
          Utility to resolve the declaration to a particular class.
 void setResult(java.lang.String result)
          Set the result for the results.
 
Methods inherited from class org.datanucleus.store.query.AbstractJavaQuery
discardCompiled, evaluateInMemory, getCandidateCollection, getCandidateExtent, getParsedImports, getResultSetMetaData, getUserDefinedScalarExpressions, performDeletePersistentAll, registerScalarExpression, registerScalarExpressions, setCandidates, setCandidates, toString
 
Methods inherited from class org.datanucleus.store.query.Query
addExtension, addSubquery, applyRangeChecks, assertIsModifiable, close, closeAll, compile, declareExplicitParameters, declareExplicitVariables, declareImports, deletePersistentAll, deletePersistentAll, deletePersistentAll, equals, execute, execute, execute, execute, executeQuery, executeWithArray, executeWithMap, getCandidateClass, getCandidateClassName, getExplicitParameters, getExplicitVariables, getExtension, getExtensions, getFetchPlan, getFilter, getFrom, getGrouping, getHaving, getIgnoreCache, getImplicitParameters, getImports, getInputParameters, getObjectManager, getOrdering, getParameterMapForValues, getRange, getRangeFromIncl, getRangeToExcl, getResult, getResultClass, getResultClassName, getResultDistinct, getStoreManager, getSubqueryForVariable, getType, getUpdate, hashCode, hasSubqueryForVariable, isCompiled, isSubclasses, isUnique, isUnmodifiable, performExecute, prepareDatastore, resultHasOnlyAggregates, setCandidateClassName, setClass, setExtensions, setFetchPlan, setFilter, setFrom, setGrouping, setHaving, setIgnoreCache, setImplicitParameter, setImplicitParameter, setOrdering, setRange, setRange, setResultClass, setResultClassName, setResultDistinct, setResultMetaData, setSubclasses, setType, setUnique, setUnmodifiable, setUpdate, shouldReturnSingleRow
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractJPQLQuery

public AbstractJPQLQuery(ObjectManager om)
Constructor.

Parameters:
om - ObjectManager

AbstractJPQLQuery

public AbstractJPQLQuery(ObjectManager om,
                         AbstractJPQLQuery q)
Constructs a new query instance having the same criteria as the given query.

Parameters:
om - The ObjectManager
q - The query from which to copy criteria.

AbstractJPQLQuery

public AbstractJPQLQuery(ObjectManager om,
                         java.lang.String query)
Constructor for a JPQL query where the query is specified using the "Single-String" format.

Parameters:
om - The ObjectManager
query - The query string
Method Detail

setResult

public void setResult(java.lang.String result)
Set the result for the results.

Overrides:
setResult in class Query
Parameters:
result - Optional keyword "distinct" followed by comma-separated list of result expressions or a result class

getSingleStringQuery

public java.lang.String getSingleStringQuery()
Method to take the defined parameters for the query and form a single string. This is used to print out the query for logging.

Specified by:
getSingleStringQuery in class AbstractJavaQuery
Returns:
The single string

compileInternal

protected void compileInternal(boolean forExecute,
                               java.util.Map parameterValues)
Method to compile the JPQL query. This implementation assumes that we are using the "generic" JPQL compiler in org.datanucleus.query.compiler. If not then override this method. Will populate the "compilation" class variable.

Specified by:
compileInternal in class Query
Parameters:
forExecute - Whether compiling for execution NOT USED HERE. TODO Remove this when possible
parameterValues - Map of param values keyed by param name. TODO Remove this when possible

resolveClassDeclaration

public java.lang.Class resolveClassDeclaration(java.lang.String classDecl)
Utility to resolve the declaration to a particular class. Takes the passed in name, together with the defined import declarations and returns the class represented by the declaration.

Overrides:
resolveClassDeclaration in class Query
Parameters:
classDecl - The declaration
Returns:
The class it resolves to (if any)
Throws:
NucleusUserException - Thrown if the class cannot be resolved.


Copyright © 2009. All Rights Reserved.