com.triactive.jdo.store.query
Class Query

java.lang.Object
  extended bycom.triactive.jdo.store.query.Query
All Implemented Interfaces:
javax.jdo.Query, Query, java.io.Serializable
Direct Known Subclasses:
JdoqlQuery, TjdoSqlQuery

public abstract class Query
extends java.lang.Object
implements Query

The Query interface allows applications to obtain persistent instances from the data store.

Author:
Mike Martin
See Also:
Query, Serialized Form

Field Summary
protected  java.lang.Class candidateClass
           
protected  DatabaseAdapter dba
           
protected  java.util.Map extensions
           
protected  java.lang.String filter
           
protected  java.lang.String grouping
           
protected  java.lang.String imports
           
protected  boolean isPart1Compiled
           
protected  java.lang.String ordering
           
protected  java.util.List parameterNames
           
protected  java.lang.String parameters
           
protected  java.util.Map parameterTypesByName
           
protected  Imports parsedImports
           
protected  PersistenceManager pm
           
protected  java.util.Collection queryResults
           
protected  java.lang.String result
           
protected  java.lang.Class resultClass
           
protected  StoreManager storeMgr
           
protected  java.lang.Boolean unique
           
protected  java.util.List variableNames
           
protected  java.lang.String variables
           
protected  java.util.Map variableTypesByName
           
 
Constructor Summary
Query(PersistenceManager pm, Query existingQuery)
          Constructs a new query instance from an existing instance.
 
Method Summary
 void addExtension(java.lang.String key, java.lang.Object value)
          Adds a vendor-specific extension to this query.
 void close(java.lang.Object queryResult)
          Close a query result and release any resources associated with it.
 void closeAll()
          Close all query results associated with this Query instance, and release all resources associated with them.
 void compile()
          Verify the elements of the query and provide a hint to the query to prepare and optimize an execution plan.
 void declareImports(java.lang.String imports)
          Set the import statements to be used to identify the fully qualified name of variables or parameters.
 void declareParameters(java.lang.String parameters)
          Declare the list of parameters query execution.
 void declareVariables(java.lang.String variables)
          Declare the unbound variables to be used in the query.
protected  void discardCompiled()
           
protected  int effectiveFetchSize()
           
protected  int effectiveResultSetType()
           
protected abstract  boolean effectiveUniqueSetting()
           
 boolean equals(java.lang.Object obj)
           
 java.lang.Object execute()
          Execute the query and return the filtered Collection.
 java.lang.Object execute(java.lang.Object p1)
          Execute the query and return the filtered Collection.
 java.lang.Object execute(java.lang.Object p1, java.lang.Object p2)
          Execute the query and return the filtered Collection.
 java.lang.Object execute(java.lang.Object p1, java.lang.Object p2, java.lang.Object p3)
          Execute the query and return the filtered Collection.
 java.lang.Object executeWithArray(java.lang.Object[] parameters)
          Execute the query and return the filtered Collection.
abstract  java.lang.Object executeWithMap(java.util.Map parameters)
          Execute the query and return the filtered Collection.
 java.lang.Class getCandidateClass()
          Get the class of the candidate instances of the query.
 boolean getIgnoreCache()
          Get the ignoreCache option setting.
 javax.jdo.PersistenceManager getPersistenceManager()
          Get the PersistenceManager associated with this Query.
protected abstract  ResultExpression getResultExpression(java.sql.ResultSetMetaData rsmd)
           
protected abstract  StatementText getStatementText()
           
 StoreManager getStoreManager()
          Get the StoreManager associated with this Query.
 int hashCode()
           
protected  boolean isKnownExtensionKey(java.lang.String key)
           
protected static boolean isValidJavaIdentifier(java.lang.String s)
           
 java.lang.Class resolveClassDeclaration(java.lang.String classDecl)
           
abstract  void setCandidates(java.util.Collection pcs)
          Set the candidate Collection to query.
abstract  void setCandidates(javax.jdo.Extent pcs)
          Set the candidate Extent to query.
 void setClass(java.lang.Class candidateClass)
          Set the class of the candidate instances of the query.
 void setExtensions(java.util.Map extensions)
          Sets multiple extensions, or use null to clear all extensions.
 void setFilter(java.lang.String filter)
          Set the filter for the query.
 void setGrouping(java.lang.String grouping)
          Set the grouping expressions, optionally including a "having" clause.
 void setIgnoreCache(boolean ignoreCache)
          Set the ignoreCache option.
 void setOrdering(java.lang.String ordering)
          Set the ordering specification for the result Collection.
 void setResult(java.lang.String result)
          Specifies what type of data this query should return.
 void setResultClass(java.lang.Class resultClass)
          Specifies the type of object in which to return each element of the result of invoking Query.execute() or one of its siblings.
 void setUnique(boolean unique)
          Specify that only the first result of the query should be returned, rather than a collection.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pm

protected final transient PersistenceManager pm

storeMgr

protected final transient StoreManager storeMgr

dba

protected final transient DatabaseAdapter dba

unique

protected java.lang.Boolean unique

result

protected java.lang.String result

resultClass

protected java.lang.Class resultClass

candidateClass

protected java.lang.Class candidateClass

filter

protected java.lang.String filter

variables

protected java.lang.String variables

parameters

protected java.lang.String parameters

imports

protected java.lang.String imports

grouping

protected java.lang.String grouping

ordering

protected java.lang.String ordering

extensions

protected java.util.Map extensions

isPart1Compiled

protected transient boolean isPart1Compiled

parsedImports

protected transient Imports parsedImports

parameterNames

protected transient java.util.List parameterNames

parameterTypesByName

protected transient java.util.Map parameterTypesByName

variableNames

protected transient java.util.List variableNames

variableTypesByName

protected transient java.util.Map variableTypesByName

queryResults

protected transient java.util.Collection queryResults
Constructor Detail

Query

public Query(PersistenceManager pm,
             Query existingQuery)
Constructs a new query instance from an existing instance.

Parameters:
pm - the associated persistence manager for this query.
existingQuery - a query from which to copy criteria, or null for an empty query.
Method Detail

discardCompiled

protected void discardCompiled()

hashCode

public int hashCode()

equals

public boolean equals(java.lang.Object obj)

getStoreManager

public StoreManager getStoreManager()
Get the StoreManager associated with this Query.

Returns:
the StoreManager associated with this Query.

getPersistenceManager

public javax.jdo.PersistenceManager getPersistenceManager()
Get the PersistenceManager associated with this Query.

Specified by:
getPersistenceManager in interface javax.jdo.Query
Returns:
the PersistenceManager associated with this Query.
See Also:
Query.getPersistenceManager()

getCandidateClass

public java.lang.Class getCandidateClass()
Get the class of the candidate instances of the query.

Returns:
the Class of the candidate instances.
See Also:
Query.setClass(java.lang.Class)

setClass

public void setClass(java.lang.Class candidateClass)
Set the class of the candidate instances of the query.

Specified by:
setClass in interface javax.jdo.Query
Parameters:
candidateClass - the Class of the candidate instances.
See Also:
Query.setClass(java.lang.Class)

setCandidates

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

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

setCandidates

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

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

setFilter

public void setFilter(java.lang.String filter)
Set the filter for the query.

Specified by:
setFilter in interface javax.jdo.Query
Parameters:
filter - the query filter.
See Also:
Query.setFilter(java.lang.String)

declareImports

public void declareImports(java.lang.String imports)
Set the import statements to be used to identify the fully qualified name of variables or parameters.

Specified by:
declareImports in interface javax.jdo.Query
Parameters:
imports - import statements separated by semicolons.
See Also:
Query.declareImports(java.lang.String)

declareParameters

public void declareParameters(java.lang.String parameters)
Declare the list of parameters query execution.

Specified by:
declareParameters in interface javax.jdo.Query
Parameters:
parameters - the list of parameters separated by commas.
See Also:
Query.declareParameters(java.lang.String)

declareVariables

public void declareVariables(java.lang.String variables)
Declare the unbound variables to be used in the query.

Specified by:
declareVariables in interface javax.jdo.Query
Parameters:
variables - the variables separated by semicolons.
See Also:
Query.declareVariables(java.lang.String)

setOrdering

public void setOrdering(java.lang.String ordering)
Set the ordering specification for the result Collection.

Specified by:
setOrdering in interface javax.jdo.Query
Parameters:
ordering - the ordering specification.
See Also:
Query.setOrdering(java.lang.String)

setResult

public void setResult(java.lang.String result)
Specifies what type of data this query should return.

Specified by:
setResult in interface Query
Parameters:
result - a comma-delimited list of expressions (fields, functions on fields, or aggregate functions) to return from this query.
See Also:
Query.setResult(java.lang.String)

setResultClass

public void setResultClass(java.lang.Class resultClass)
Specifies the type of object in which to return each element of the result of invoking Query.execute() or one of its siblings.

Specified by:
setResultClass in interface Query
Parameters:
resultClass - the result class
See Also:
Query.setResultClass(java.lang.Class)

setGrouping

public void setGrouping(java.lang.String grouping)
Set the grouping expressions, optionally including a "having" clause.

Specified by:
setGrouping in interface Query
Parameters:
grouping - a comma-delimited list of expressions, optionally followed by the "having" keyword and a boolean expression.
See Also:
Query.setGrouping(java.lang.String)

setUnique

public void setUnique(boolean unique)
Specify that only the first result of the query should be returned, rather than a collection.

Specified by:
setUnique in interface Query
Parameters:
unique - if true, only one element is returned.
See Also:
Query.setUnique(boolean)

setIgnoreCache

public void setIgnoreCache(boolean ignoreCache)
Set the ignoreCache option.

This implementation does not support the ignore cache option, so this method does nothing.

Specified by:
setIgnoreCache in interface javax.jdo.Query
Parameters:
ignoreCache - the setting of the ignoreCache option.
See Also:
Query.setIgnoreCache(boolean)

getIgnoreCache

public boolean getIgnoreCache()
Get the ignoreCache option setting.

This implementation does not support the ignore cache option, so this method always returns false.

Specified by:
getIgnoreCache in interface javax.jdo.Query
Returns:
the ignoreCache option setting, always false.
See Also:
Query.getIgnoreCache(), setIgnoreCache(boolean)

addExtension

public void addExtension(java.lang.String key,
                         java.lang.Object value)
Adds a vendor-specific extension to this query.

Specified by:
addExtension in interface Query
Parameters:
key - the key of the extension
value - the value of the extension
See Also:
Query.addExtension(java.lang.String, java.lang.Object)

setExtensions

public void setExtensions(java.util.Map extensions)
Sets multiple extensions, or use null to clear all extensions.

Specified by:
setExtensions in interface Query
Parameters:
extensions - the map of extensions
See Also:
Query.setExtensions(java.util.Map)

isKnownExtensionKey

protected boolean isKnownExtensionKey(java.lang.String key)

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
See Also:
Query.compile()

isValidJavaIdentifier

protected static boolean isValidJavaIdentifier(java.lang.String s)

resolveClassDeclaration

public java.lang.Class resolveClassDeclaration(java.lang.String classDecl)

execute

public java.lang.Object execute()
Execute the query and return the filtered Collection.

Specified by:
execute in interface javax.jdo.Query
Returns:
the filtered Collection.
See Also:
Query.execute(), executeWithArray(Object[] parameters)

execute

public java.lang.Object execute(java.lang.Object p1)
Execute the query and return the filtered Collection.

Specified by:
execute in interface javax.jdo.Query
Parameters:
p1 - the value of the first parameter declared.
Returns:
the filtered Collection.
See Also:
Query.execute(Object), executeWithArray(Object[] parameters)

execute

public java.lang.Object execute(java.lang.Object p1,
                                java.lang.Object p2)
Execute the query and return the filtered Collection.

Specified by:
execute in interface javax.jdo.Query
Parameters:
p1 - the value of the first parameter declared.
p2 - the value of the second parameter declared.
Returns:
the filtered Collection.
See Also:
Query.execute(Object,Object), executeWithArray(Object[] parameters)

execute

public java.lang.Object execute(java.lang.Object p1,
                                java.lang.Object p2,
                                java.lang.Object p3)
Execute the query and return the filtered Collection.

Specified by:
execute in interface javax.jdo.Query
Parameters:
p1 - the value of the first parameter declared.
p2 - the value of the second parameter declared.
p3 - the value of the third parameter declared.
Returns:
the filtered Collection.
See Also:
Query.execute(Object,Object,Object), executeWithArray(Object[] parameters)

executeWithArray

public java.lang.Object executeWithArray(java.lang.Object[] parameters)
Execute the query and return the filtered Collection.

Specified by:
executeWithArray in interface javax.jdo.Query
Parameters:
parameters - the Object array with all of the parameters.
Returns:
the filtered Collection.
See Also:
Query.executeWithArray(Object[])

executeWithMap

public abstract java.lang.Object executeWithMap(java.util.Map parameters)
Execute the query and return the filtered Collection.

Specified by:
executeWithMap in interface javax.jdo.Query
Parameters:
parameters - the Map containing all of the parameters.
Returns:
the filtered Collection.
See Also:
Query.executeWithMap(Map), executeWithArray(Object[] parameters)

getStatementText

protected abstract StatementText getStatementText()

getResultExpression

protected abstract ResultExpression getResultExpression(java.sql.ResultSetMetaData rsmd)
                                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

effectiveUniqueSetting

protected abstract boolean effectiveUniqueSetting()

effectiveResultSetType

protected int effectiveResultSetType()

effectiveFetchSize

protected int effectiveFetchSize()

close

public void close(java.lang.Object queryResult)
Close a query result and release any resources associated with it.

Specified by:
close in interface javax.jdo.Query
Parameters:
queryResult - the result of execute(...) on this Query instance.
See Also:
Query.close(java.lang.Object)

closeAll

public void closeAll()
Close all query results associated with this Query instance, and release all resources associated with them.

Specified by:
closeAll in interface javax.jdo.Query
See Also:
Query.closeAll()


Copyright © 2001-2007 The TJDO Project All Rights Reserved.