org.datanucleus.store.rdbms.query2
Class JPQLQuery2

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.query2.JPQLQuery2
All Implemented Interfaces:
java.io.Serializable

public class JPQLQuery2
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. This implementation uses the generic query compilation in "org.datanucleus.query" and will ultimately replace the version in "JPQLQuery". There are the following main ways of running a query here

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.datanucleus.store.query.Query
org.datanucleus.store.query.Query.SubqueryDefinition
 
Field Summary
 
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
JPQLQuery2(org.datanucleus.ObjectManager om)
          Constructs a new query instance that uses the given object manager.
JPQLQuery2(org.datanucleus.ObjectManager om, JPQLQuery2 q)
          Constructs a new query instance having the same criteria as the given query.
JPQLQuery2(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
 void applyParametersToStatement(java.util.Map parameterValuesByName, java.sql.PreparedStatement ps)
          Method to populate all parameters in the supplied PreparedStatement.
protected  boolean applyRangeChecks()
          Method to return if the query results should have the range checked and unnecessary rows discarded.
protected  void assertSupportsCancel()
          Method that will throw an UnsupportedOperationException if the query implementation doesn't support cancelling queries.
protected  void compileInternal(boolean forExecute, java.util.Map parameterValues)
          Method to compile the JPQL query.
protected  void discardCompiled()
          Utility to remove any previous compilation of this Query.
 java.lang.String getSQL()
          Convenience accessor for the SQL to invoke in the datastore for this query.
 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  java.lang.Object performExecute(java.util.Map parameters)
           
protected  java.lang.Object performExecuteInternal(java.lang.Object... args)
          Method executing the query in the destination environment.
 void setImplicitParameter(int position, java.lang.Object value)
           
 void setImplicitParameter(java.lang.String name, java.lang.Object value)
           
 
Methods inherited from class org.datanucleus.store.query.AbstractJPQLQuery
getSingleStringQuery, resolveClassDeclaration, setResult
 
Methods inherited from class org.datanucleus.store.query.AbstractJavaQuery
evaluateInMemory, getCandidateCollection, getCandidateExtent, performDeletePersistentAll, setCandidates, setCandidates, toString
 
Methods inherited from class org.datanucleus.store.query.Query
addExtension, addSubquery, applyImplicitParameterValueToCompilation, assertIsModifiable, cancel, cancel, checkParameterTypesAgainstCompilation, close, closeAll, compile, declareExplicitParameters, declareExplicitVariables, declareImports, deletePersistentAll, deletePersistentAll, deletePersistentAll, equals, execute, executeQuery, executeWithArray, executeWithMap, getBooleanExtensionProperty, getCandidateClass, getCandidateClassName, getCompilation, getExplicitParameters, getExplicitVariables, getExtension, getExtensions, getFetchPlan, getFilter, getFrom, getGrouping, getHaving, getIgnoreCache, getImplicitParameters, getImports, getInputParameters, getObjectManager, getOrdering, getParameterMapForValues, getParsedImports, getPerformExecuteTask, getRange, getRangeFromIncl, getRangeToExcl, getResult, getResultClass, getResultClassName, getResultDistinct, getSerializeRead, getStoreManager, getSubqueryForVariable, getTimeoutMillis, getType, getUpdate, hashCode, hasSubqueryForVariable, isSubclasses, isUnique, isUnmodifiable, performExecuteTask, prepareDatastore, setCandidateClassName, setClass, setExtensions, setFetchPlan, setFilter, setFrom, setGrouping, setHaving, setIgnoreCache, 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
 

Constructor Detail

JPQLQuery2

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

Parameters:
om - The ObjectManager

JPQLQuery2

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

JPQLQuery2

public JPQLQuery2(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 single-string query form
Method Detail

setImplicitParameter

public void setImplicitParameter(int position,
                                 java.lang.Object value)
Overrides:
setImplicitParameter in class org.datanucleus.store.query.Query

setImplicitParameter

public void setImplicitParameter(java.lang.String name,
                                 java.lang.Object value)
Overrides:
setImplicitParameter in class org.datanucleus.store.query.Query

discardCompiled

protected void discardCompiled()
Utility to remove any previous compilation of this Query.

Overrides:
discardCompiled in class org.datanucleus.store.query.AbstractJavaQuery

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 JPQL query. Uses the superclass to compile the generic query populating the "compilation", and then generates the datastore-specific "datastoreCompilation".

Overrides:
compileInternal in class org.datanucleus.store.query.AbstractJPQLQuery
Parameters:
forExecute - Whether compiling for execution NOT USED HERE. TODO Remove this when possible
parameterValues - Map of param values keyed by param name (if available at compile time)

getSQL

public java.lang.String getSQL()
Convenience accessor for the SQL to invoke in the datastore for this query.

Returns:
The SQL.

performExecute

protected java.lang.Object performExecute(java.util.Map parameters)
Specified by:
performExecute in class org.datanucleus.store.query.Query

assertSupportsCancel

protected void assertSupportsCancel()
Method that will throw an UnsupportedOperationException if the query implementation doesn't support cancelling queries.

Overrides:
assertSupportsCancel in class org.datanucleus.store.query.Query

performExecuteInternal

protected java.lang.Object performExecuteInternal(java.lang.Object... args)
Method executing the query in the destination environment. This performs the actual PreparedStatement.execute() and nothing else. Any SQLException from the execution is wrapped as a NucleusDataStoreException.

Overrides:
performExecuteInternal in class org.datanucleus.store.query.Query
Parameters:
args - Arguments to the execution (SQLController, ManagedConnection, PreparedStatement)
Returns:
The result

applyParametersToStatement

public void applyParametersToStatement(java.util.Map parameterValuesByName,
                                       java.sql.PreparedStatement ps)
                                throws java.sql.SQLException
Method to populate all parameters in the supplied PreparedStatement.

Parameters:
parameterValuesByName - Map of parameter values keyed by the name.
ps - PreparedStatement
Throws:
java.sql.SQLException - Thrown if an error occurs setting the parameters

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

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.


Copyright © 2009. All Rights Reserved.