org.datanucleus.store.query
Class AbstractJavaQuery

java.lang.Object
  extended by org.datanucleus.store.query.Query
      extended by org.datanucleus.store.query.AbstractJavaQuery
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AbstractJDOQLQuery, AbstractJPQLQuery

public abstract class AbstractJavaQuery
extends Query

Abstract representation of a Java-based query. To be extended by Java-based query languages.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.datanucleus.store.query.Query
Query.SubqueryDefinition
 
Field Summary
protected  java.util.Collection candidateCollection
          Collection of candidates for this query.
protected  Extent candidateExtent
          Extent of candidates for this query.
protected  QueryResultsMetaData resultMetaData
          Result metadata (extension, allowing access to more info about results).
protected  java.lang.String singleString
          Cached form of the single string form of the query.
protected static java.util.Map userDefinedScalarExpressions
          Register of user-defined ScalarExpression, provided via plugins.
 
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
AbstractJavaQuery(ObjectManager om)
          Constructor for a Java-based query.
 
Method Summary
protected  void discardCompiled()
          Method to discard our current compiled query due to changes.
protected  boolean evaluateInMemory()
          Convenience method to return whether the query should be evaluated in-memory.
 java.util.Collection getCandidateCollection()
          Accessor for the candidate collection (if specified using a collection).
 Extent getCandidateExtent()
          Accessor for the candidate Extent (if specified using an Extent).
 Imports getParsedImports()
          Accessor for the parsed imports.
 QueryResultsMetaData getResultSetMetaData()
          Retrieve the metadata for the results
abstract  java.lang.String getSingleStringQuery()
          Accessor for a single string form of the query.
static java.util.Map getUserDefinedScalarExpressions()
          Accessor for the user-defined scalar expressions.
protected  long performDeletePersistentAll(java.util.Map parameters)
          Execute the query to delete persistent objects.
static void registerScalarExpression(java.lang.Class literal, java.lang.Class scalarExpressionClass, java.lang.String name)
          Register ScalarExpressions for the given cls.
protected  void registerScalarExpressions(PluginManager pluginMgr, ClassLoaderResolver clr)
          Register ScalarExpression classes delcared as plug-ins extensions TODO currently register only the first time this class is instantiated.
 void setCandidates(java.util.Collection pcs)
          Set the candidate Collection to query.
 void setCandidates(Extent pcs)
          Set the candidate Extent to query.
 java.lang.String toString()
          Stringifier method
 
Methods inherited from class org.datanucleus.store.query.Query
addExtension, addSubquery, applyRangeChecks, assertIsModifiable, close, closeAll, compile, compileInternal, 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, resolveClassDeclaration, resultHasOnlyAggregates, setCandidateClassName, setClass, setExtensions, setFetchPlan, setFilter, setFrom, setGrouping, setHaving, setIgnoreCache, setImplicitParameter, setImplicitParameter, setOrdering, setRange, setRange, setResult, 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
 

Field Detail

candidateExtent

protected transient Extent candidateExtent
Extent of candidates for this query.


candidateCollection

protected transient java.util.Collection candidateCollection
Collection of candidates for this query.


singleString

protected java.lang.String singleString
Cached form of the single string form of the query.


resultMetaData

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


userDefinedScalarExpressions

protected static transient java.util.Map userDefinedScalarExpressions
Register of user-defined ScalarExpression, provided via plugins.

Constructor Detail

AbstractJavaQuery

public AbstractJavaQuery(ObjectManager om)
Constructor for a Java-based query.

Parameters:
om - The ObjectManager
Method Detail

setCandidates

public void setCandidates(Extent pcs)
Set the candidate Extent to query.

Specified by:
setCandidates in class Query
Parameters:
pcs - the Candidate Extent.
See Also:
Query.setCandidates(javax.jdo.Extent)

setCandidates

public void setCandidates(java.util.Collection pcs)
Set the candidate Collection to query.

Specified by:
setCandidates in class Query
Parameters:
pcs - the Candidate collection.
See Also:
Query.setCandidates(java.util.Collection)

getCandidateExtent

public Extent getCandidateExtent()
Accessor for the candidate Extent (if specified using an Extent).

Returns:
Candidate Extent

getCandidateCollection

public java.util.Collection getCandidateCollection()
Accessor for the candidate collection (if specified using a collection).

Returns:
Candidate collection

discardCompiled

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

Overrides:
discardCompiled in class Query
See Also:
Query.discardCompiled()

getParsedImports

public 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 Query
Returns:
Parsed imports

getResultSetMetaData

public QueryResultsMetaData getResultSetMetaData()
Retrieve the metadata for the results

Returns:
the ResultSetMetaData

performDeletePersistentAll

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

Specified by:
performDeletePersistentAll in class Query
Parameters:
parameters - the Map containing all of the parameters.
Returns:
the number of deleted objects.

getSingleStringQuery

public abstract java.lang.String getSingleStringQuery()
Accessor for a single string form of the query.

Returns:
Single string form of the query.

toString

public java.lang.String toString()
Stringifier method

Overrides:
toString in class java.lang.Object
Returns:
Single-string form of this JDOQL query.

registerScalarExpression

public static void registerScalarExpression(java.lang.Class literal,
                                            java.lang.Class scalarExpressionClass,
                                            java.lang.String name)
Register ScalarExpressions for the given cls. It allows to perform operations in the query on cls.method([arglist]).

Parameters:
literal - the class providing the operations; e.g. java.lang.Math.class
scalarExpressionClass - the class with the corresponding ScalarExpression. eg. org.datanucleus.store.expression.MathExpression.class
name - alternative name of the given literal class

registerScalarExpressions

protected void registerScalarExpressions(PluginManager pluginMgr,
                                         ClassLoaderResolver clr)
Register ScalarExpression classes delcared as plug-ins extensions TODO currently register only the first time this class is instantiated. Should be registered per PMF?

Parameters:
pluginMgr - The PluginManager
clr - The ClassLoaderResolver to load the literal and ScalarExpression classes

getUserDefinedScalarExpressions

public static java.util.Map getUserDefinedScalarExpressions()
Accessor for the user-defined scalar expressions.

Returns:
Map of user-defined scalar expressions

evaluateInMemory

protected boolean evaluateInMemory()
Convenience method to return whether the query should be evaluated in-memory.

Returns:
Use in-memory evaluation?


Copyright © 2009. All Rights Reserved.