org.jpox.store.query
Class JDOQLQuery

java.lang.Object
  extended byorg.jpox.store.query.Query
      extended byorg.jpox.store.query.JDOQLQuery
All Implemented Interfaces:
javax.jdo.Query, java.io.Serializable

public class JDOQLQuery
extends Query

A JDO query that uses the JQOQL language. The query can be specified via method calls, or via a single-string form.

Version:
$Revision: 1.103 $
See Also:
Query, Serialized Form

Nested Class Summary
 class JDOQLQuery.Compiler
          Inner class to compile the query for execution.
static class JDOQLQuery.ExecutedCompileCache
          Cache a compiled query
 
Nested classes inherited from class org.jpox.store.query.Query
Query.ResultObjectFactory
 
Field Summary
protected  java.util.Collection candidateCollection
           
protected  javax.jdo.Extent candidateExtent
           
protected  Queryable candidates
           
static java.lang.String[] SINGLE_STRING_KEYWORDS
          Keywords used in single-string JDOQL.
protected static java.lang.String[] SINGLE_STRING_KEYWORDS_LOWERCASE
          Keywords in lowercase (we avoid calling toLowerCase() multiple times, which is expensive operation)
 
Fields inherited from class org.jpox.store.query.Query
candidateClass, candidateClassName, dba, extensions, fetchPlan, filter, fromInclNo, grouping, ignoreCache, imports, isCompiled, isPreCompile, LOCALISER, ordering, parameterNames, parameters, parameterTypesByName, parsedImports, pm, queryResults, range, result, resultClass, resultClassName, subclasses, toExclNo, unique, unmodifiable, variableNames, variables, variableTypesByName
 
Fields inherited from interface javax.jdo.Query
JDOQL, SQL
 
Constructor Summary
JDOQLQuery(PersistenceManager pm)
          Constructs a new query instance that uses the given persistence manager.
JDOQLQuery(PersistenceManager pm, JDOQLQuery q)
          Constructs a new query instance having the same criteria as the given query.
JDOQLQuery(PersistenceManager pm, java.lang.String query)
          Constructor for a JDOQL query where the query is specified using the "Single-String" format.
 
Method Summary
 void compile()
          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 JDOQL.
 JDOQLResultSetMetaData getResultSetMetaData()
          Retrieve the metadata for the results
protected  long performDeletePersistentAll(java.util.Map parameters)
          Execute the query to delete persistent objects.
protected  java.util.Collection performExecute(java.util.Map parameters)
          Execute the query and return the filtered QueryResult.
static void registerScalarExpression(java.lang.Class literal, java.lang.Class scalarExpressionClass, java.lang.String name)
          Register ScalarExpressions for the given cls.
 void setCandidates(java.util.Collection pcs)
          Set the candidate Collection to query.
 void setCandidates(javax.jdo.Extent pcs)
          Set the candidate Extent to query.
protected  boolean shouldReturnSingleRow()
          Convenience method to return whether the query should return a single row.
 java.lang.String toString()
          Stringifier method
 
Methods inherited from class org.jpox.store.query.Query
addExtension, assertIsModifiable, close, closeAll, declareImports, declareParameters, declareVariables, deletePersistentAll, deletePersistentAll, deletePersistentAll, execute, execute, execute, execute, executeQuery, executeWithArray, executeWithMap, getCandidateClass, getCandidateLoader, getExtension, getFetchPlan, getIgnoreCache, getPersistenceManager, getResultSetConcurrency, getResultSetType, getStatement, getStatement, getStoreManager, hashCode, isSubclasses, isUnmodifiable, prepareStatementForExecution, resolveClassDeclaration, setCandidateClassName, setClass, setExtensions, setFilter, setGrouping, setIgnoreCache, setOrdering, setRange, setRange, setResult, setResultClass, setResultClassName, setSubclasses, setUnique, setUnmodifiable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SINGLE_STRING_KEYWORDS

public static final java.lang.String[] SINGLE_STRING_KEYWORDS
Keywords used in single-string JDOQL. Uppercase variants specified here, but we allow the lowercase form.


SINGLE_STRING_KEYWORDS_LOWERCASE

protected static final java.lang.String[] SINGLE_STRING_KEYWORDS_LOWERCASE
Keywords in lowercase (we avoid calling toLowerCase() multiple times, which is expensive operation)


candidateExtent

protected transient javax.jdo.Extent candidateExtent

candidateCollection

protected transient java.util.Collection candidateCollection

candidates

protected transient Queryable candidates
Constructor Detail

JDOQLQuery

public JDOQLQuery(PersistenceManager pm)
Constructs a new query instance that uses the given persistence manager.

Parameters:
pm - the associated persistence manager for this query.

JDOQLQuery

public JDOQLQuery(PersistenceManager pm,
                  JDOQLQuery q)
Constructs a new query instance having the same criteria as the given query.

Parameters:
pm - The PersistenceManager
q - The query from which to copy criteria.

JDOQLQuery

public JDOQLQuery(PersistenceManager pm,
                  java.lang.String query)
Constructor for a JDOQL query where the query is specified using the "Single-String" format.

Parameters:
pm - The persistence manager
query - The query string
Method Detail

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.jpox.store.expression.MathExpression.class
name - alternative name of the given literal class

equals

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

Overrides:
equals in class Query
Parameters:
obj - Object to compare against
Returns:
Whether this and the other object are equal.
See Also:
Object.equals(java.lang.Object)

setCandidates

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

Specified by:
setCandidates in interface javax.jdo.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 interface javax.jdo.Query
Specified by:
setCandidates in class Query
Parameters:
pcs - the Candidate collection.
See Also:
Query.setCandidates(java.util.Collection)

compile

public void compile()
Verify the elements of the query and provide a hint to the query to prepare and optimize an execution plan.

Specified by:
compile in interface javax.jdo.Query
Overrides:
compile in class Query
See Also:
Query.compile()

discardCompiled

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

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

shouldReturnSingleRow

protected boolean shouldReturnSingleRow()
Convenience method to return whether the query should return a single row.

Specified by:
shouldReturnSingleRow in class Query
Returns:
Whether a single row should result

performExecute

protected java.util.Collection performExecute(java.util.Map parameters)
Execute the query and return the filtered QueryResult.

Specified by:
performExecute in class 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.

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

getResultSetMetaData

public JDOQLResultSetMetaData getResultSetMetaData()
Retrieve the metadata for the results

Returns:
the ResultSetMetaData

toString

public java.lang.String toString()
Stringifier method

Returns:
Single-string form of this JDOQL query.


Copyright © -2007 . All Rights Reserved.