org.datanucleus.store.rdbms.query
Class JPQLQuery

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

public class JPQLQuery
extends org.datanucleus.store.query.AbstractJPQLQuery

RDBMS representation of a JPQL query for use 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
org.datanucleus.store.query.Query.SubqueryDefinition
 
Field Summary
protected  java.lang.String candidateAlias
           
protected  org.datanucleus.store.mapped.expression.Queryable candidates
          Candidates for this query.
protected  boolean isCompiled
          State variable for the compilation state
protected  org.datanucleus.store.mapped.expression.QueryExpression queryStmt
          The Query Statement.
protected  QueryResultsMetaData resultMetaData
          Result metadata (extension, allowing access to more info about results).
protected  org.datanucleus.store.query.ResultObjectFactory rof
          Factory for obtaining the results from the query result set.
 
Fields inherited from class org.datanucleus.store.query.AbstractJavaQuery
candidateCollection, candidateExtent, singleString
 
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, implicitParameters, imports, LOCALISER, om, ordering, parameterNames, parsedImports, queryResults, range, result, resultClass, resultClassName, resultDistinct, SELECT, subclasses, subqueries, tasks, toExclNo, type, unique, unmodifiable, update
 
Constructor Summary
JPQLQuery(org.datanucleus.ObjectManager om)
          Constructs a new query instance that uses the given persistence manager.
JPQLQuery(org.datanucleus.ObjectManager om, JPQLQuery q)
          Constructs a new query instance having the same criteria as the given query.
JPQLQuery(org.datanucleus.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)
          Verify the elements of the query and provide a hint to the query to prepare and optimize an execution plan.
protected  void discardCompiled()
          Method to discard our current compiled query due to changes.
 boolean equals(java.lang.Object obj)
          Equality operator for JPQL.
protected  java.lang.Object executeQuery(java.util.Map parameters)
          Method to execute the actual query.
 org.datanucleus.store.mapped.expression.Queryable getCandidates()
          Accessor for the candidates for the query.
 org.datanucleus.util.Imports getParsedImports()
          Accessor for the parsed imports.
 QueryResultsMetaData getResultSetMetaData()
          Retrieve the metadata for the results.
 java.util.Set<java.lang.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  long performDeletePersistentAll(java.util.Map parameters)
          Execute the query to delete persistent objects.
protected  java.lang.Object performExecute(java.util.Map executeParameters)
          Execute the query and return the filtered QueryResult.
 
Methods inherited from class org.datanucleus.store.query.AbstractJPQLQuery
getSingleStringQuery, resolveClassDeclaration, setResult
 
Methods inherited from class org.datanucleus.store.query.AbstractJavaQuery
evaluateInMemory, getCandidateCollection, getCandidateExtent, setCandidates, setCandidates, toString
 
Methods inherited from class org.datanucleus.store.query.Query
addExtension, addSubquery, applyImplicitParameterValueToCompilation, applyRangeChecks, assertIsModifiable, assertSupportsCancel, cancel, cancel, checkParameterTypesAgainstCompilation, close, closeAll, compile, declareExplicitParameters, declareExplicitVariables, declareImports, deletePersistentAll, deletePersistentAll, deletePersistentAll, execute, executeWithArray, executeWithMap, getBooleanExtensionProperty, getCandidateClass, getCandidateClassName, getCompilation, getExplicitParameters, getExplicitVariables, getExtension, getExtensions, getFetchPlan, getFilter, getFrom, getGrouping, getHaving, getIgnoreCache, getImplicitParameters, getImports, getInputParameters, getObjectManager, getOrdering, getParameterMapForValues, getPerformExecuteTask, getRange, getRangeFromIncl, getRangeToExcl, getResult, getResultClass, getResultClassName, getResultDistinct, getSerializeRead, getStoreManager, getSubqueryForVariable, getTimeoutMillis, getType, getUpdate, hashCode, hasSubqueryForVariable, isSubclasses, isUnique, isUnmodifiable, performExecuteInternal, performExecuteTask, prepareDatastore, setCandidateClassName, setClass, setExtensions, setFetchPlan, setFilter, setFrom, setGrouping, setHaving, setIgnoreCache, setImplicitParameter, setImplicitParameter, setOrdering, setRange, setRange, setResultClass, setResultClassName, setResultDistinct, setResultMetaData, setSerializeRead, setSubclasses, setTimeoutMillis, setType, setUnique, setUnmodifiable, setUpdate, shouldReturnSingleRow, useFetchPlan
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

queryStmt

protected transient org.datanucleus.store.mapped.expression.QueryExpression queryStmt
The Query Statement.


candidates

protected transient org.datanucleus.store.mapped.expression.Queryable candidates
Candidates for this query.


candidateAlias

protected transient java.lang.String candidateAlias

rof

protected transient org.datanucleus.store.query.ResultObjectFactory rof
Factory for obtaining the results from the query result set.


isCompiled

protected transient boolean isCompiled
State variable for the compilation state


resultMetaData

protected transient QueryResultsMetaData resultMetaData
Result metadata (extension, allowing access to more info about results).

Constructor Detail

JPQLQuery

public JPQLQuery(org.datanucleus.ObjectManager om)
Constructs a new query instance that uses the given persistence manager.

Parameters:
om - the associated ObjectManager for this query.

JPQLQuery

public JPQLQuery(org.datanucleus.ObjectManager om,
                 JPQLQuery 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.

JPQLQuery

public JPQLQuery(org.datanucleus.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

getCandidates

public org.datanucleus.store.mapped.expression.Queryable getCandidates()
Accessor for the candidates for the query. This is only valid after compiling the query.

Returns:
Candidates for the query

equals

public boolean equals(java.lang.Object obj)
Equality operator for JPQL.

Overrides:
equals in class org.datanucleus.store.query.Query
See Also:
Object.equals(java.lang.Object)

discardCompiled

protected void discardCompiled()
Method to discard our current compiled query due to changes.

Overrides:
discardCompiled in class org.datanucleus.store.query.AbstractJavaQuery
See Also:
Query.discardCompiled()

isCompiled

protected boolean isCompiled()
Method to return if the query is compiled.

Overrides:
isCompiled in class org.datanucleus.store.query.Query
Returns:
Whether it is compiled

compileInternal

protected void compileInternal(boolean forExecute,
                               java.util.Map parameterValues)
Verify the elements of the query and provide a hint to the query to prepare and optimize an execution plan.

Overrides:
compileInternal in class org.datanucleus.store.query.AbstractJPQLQuery

getResultSetMetaData

public QueryResultsMetaData getResultSetMetaData()
Retrieve the metadata for the results.

Returns:
the ResultSetMetaData

executeQuery

protected java.lang.Object executeQuery(java.util.Map parameters)
Method to execute the actual query. Discards any existing compilation forcing a recompile, and calls the superclass variant.

Overrides:
executeQuery in class org.datanucleus.store.query.Query
Parameters:
parameters - Map of parameter values keyed by parameter name
Returns:
Result
Throws:
org.datanucleus.store.query.NoQueryResultsException - Thrown if no results were returned from the query.
org.datanucleus.store.query.QueryNotUniqueException - Thrown if multiple results, yet expected one

performExecute

protected java.lang.Object performExecute(java.util.Map executeParameters)
Execute the query and return the filtered QueryResult.

Specified by:
performExecute in class org.datanucleus.store.query.Query
Parameters:
executeParameters - Map containing all of the parameters.
Returns:
the results of the query - a QueryResult (if SELECT) or a Long (if BULK_UPDATE/BULK_DELETE)

performDeletePersistentAll

protected long performDeletePersistentAll(java.util.Map parameters)
Execute the query to delete persistent objects.

Overrides:
performDeletePersistentAll in class org.datanucleus.store.query.AbstractJavaQuery
Parameters:
parameters - the Map containing all of the parameters.
Returns:
the number of deleted objects.

getSupportedExtensions

public java.util.Set<java.lang.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 class org.datanucleus.store.query.AbstractJavaQuery
Returns:
The supported extension names

getParsedImports

public org.datanucleus.util.Imports getParsedImports()
Accessor for the parsed imports. If no imports are set then adds candidate class, user imports, and any user-defined expression packages.

Overrides:
getParsedImports in class org.datanucleus.store.query.Query
Returns:
Parsed imports


Copyright © 2009. All Rights Reserved.