org.datanucleus.store.rdbms.query
Class JDOQLQuery

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

public class JDOQLQuery
extends org.datanucleus.store.query.AbstractJDOQLQuery

RDBMS representation of a JDOQL query. 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  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
JDOQLQuery(org.datanucleus.ObjectManager om)
          Constructs a new query instance that uses the given persistence manager.
JDOQLQuery(org.datanucleus.ObjectManager om, JDOQLQuery q)
          Constructs a new query instance having the same criteria as the given query.
JDOQLQuery(org.datanucleus.ObjectManager om, java.lang.String query)
          Constructor for a JDOQL query where the query is specified using the "Single-String" format.
 
Method Summary
protected  boolean applyRangeChecks()
          Method to return if the query results should have the range checked and unnecessary rows discarded.
protected  void compileInternal(boolean forExecute, java.util.Map parameterValues)
          Method to compile the query.
protected  void discardCompiled()
          Method to discard our current compiled query due to changes.
 boolean equals(java.lang.Object obj)
          Equality operator for JDOQL.
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 parameters)
          Execute the query and return the filtered QueryResult.
 
Methods inherited from class org.datanucleus.store.query.AbstractJDOQLQuery
getSingleStringQuery, setGrouping, 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, 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, resolveClassDeclaration, setCandidateClassName, setClass, setExtensions, setFetchPlan, setFilter, setFrom, 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.


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

JDOQLQuery

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

Parameters:
om - the associated ObjectManager for this query.

JDOQLQuery

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

JDOQLQuery

public JDOQLQuery(org.datanucleus.ObjectManager om,
                  java.lang.String query)
Constructor for a JDOQL query where the query is specified using the "Single-String" format.

Parameters:
om - The persistence manager
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 JDOQL.

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)
Method to compile the query.

Overrides:
compileInternal in class org.datanucleus.store.query.AbstractJDOQLQuery
Parameters:
forExecute - Whether to compile ready for execution

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, then 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 parameters)
Execute the query and return the filtered QueryResult.

Specified by:
performExecute in class org.datanucleus.store.query.Query
Parameters:
parameters - Map containing all of the parameters.
Returns:
the filtered QueryResult.

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.

applyRangeChecks

protected boolean applyRangeChecks()
Method to return if the query results should have the range checked and unnecessary rows discarded. This is for where the query language has specified a range but the datastore doesnt allow removal of unnecessary results in the query itself (so has to be done in post-processing). This implementation returns false and so should be overridden by query languages to match their capabilities.

Overrides:
applyRangeChecks in class org.datanucleus.store.query.Query
Returns:
Whether to apply range checks in post-processing of results.

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.