|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jpox.store.query.Query
Abstract implementation of the JDO query interface. Provides a base for all query languages supported by JPOX.
Query
,
Serialized FormNested Class Summary | |
static interface |
Query.ResultObjectFactory
An object that reads result set rows and returns corresponding persistent objects from them. |
Field Summary | |
protected java.lang.Class |
candidateClass
The candidate class for this query. |
protected java.lang.String |
candidateClassName
Name of the candidate class (used when specified via Single-String). |
protected DatastoreAdapter |
dba
|
protected java.util.Map |
extensions
Any JPOX extensions |
protected javax.jdo.FetchPlan |
fetchPlan
Fetch Plan to use for the query. |
protected java.lang.String |
filter
The filter for the query. |
protected long |
fromInclNo
Query result range start position (included). |
protected java.lang.String |
grouping
Grouping clause for the query, for use with aggregate expressions. |
protected boolean |
ignoreCache
Whether to ignore dirty instances in the query. |
protected java.lang.String |
imports
Any import declarations for the types used in the query. |
protected boolean |
isCompiled
State variable for the compilation state |
protected boolean |
isPreCompile
State variable for whether the query hasnt yet passed the JDO "compile" step (preCompile=true). |
protected static Localiser |
LOCALISER
Localiser for messages. |
protected java.lang.String |
ordering
Ordering clause for the query, governing the order objects are returned. |
protected java.util.List |
parameterNames
The parameter names. |
protected java.lang.String |
parameters
Any explicit parameters defined for this query. |
protected java.util.Map |
parameterTypesByName
Look-up for the parameter types, keyed by the name. |
protected Imports |
parsedImports
The imports definition. |
protected PersistenceManager |
pm
|
protected java.util.HashSet |
queryResults
All query results obtained from this query. |
protected java.lang.String |
range
String form of the query result range. |
protected java.lang.String |
result
Specification of the result of the query e.g aggregates etc. |
protected java.lang.Class |
resultClass
User-defined class that best represents the results of a query. |
protected java.lang.String |
resultClassName
Name of user-defined class to use as the result class. |
protected boolean |
subclasses
Whether to allow subclasses of the candidate class be returned. |
protected long |
toExclNo
Query result range end position (excluded). |
protected boolean |
unique
Whether to return single value, or collection from the query. |
protected boolean |
unmodifiable
Whether the query can be modified |
protected java.util.List |
variableNames
The variables names. |
protected java.lang.String |
variables
Any explicit variables defined for this query. |
protected java.util.Map |
variableTypesByName
Look-up for the variables types, keyed by the name. |
Fields inherited from interface javax.jdo.Query |
JDOQL, SQL |
Constructor Summary | |
Query(PersistenceManager pm)
Constructs a new query instance that uses the given persistence manager. |
Method Summary | |
void |
addExtension(java.lang.String key,
java.lang.Object value)
Add a vendor-specific extension this query. |
protected void |
assertIsModifiable()
Method to throw a JDOUserException if the query is currently not modifiable. |
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. |
long |
deletePersistentAll()
Method to delete all objects found by this query, without instantiating them into memory. |
long |
deletePersistentAll(java.util.Map parameters)
Method to delete all objects found by this query, without instantiating them into memory. |
long |
deletePersistentAll(java.lang.Object[] parameters)
Method to delete all objects found by this query, without instantiating them into memory. |
protected void |
discardCompiled()
Utility to remove any previous compilation of this Query. |
boolean |
equals(java.lang.Object obj)
Equality operator. |
java.lang.Object |
execute()
Execute the query and return the filtered List. |
java.lang.Object |
execute(java.lang.Object p1)
Execute the query and return the filtered List. |
java.lang.Object |
execute(java.lang.Object p1,
java.lang.Object p2)
Execute the query and return the filtered List. |
java.lang.Object |
execute(java.lang.Object p1,
java.lang.Object p2,
java.lang.Object p3)
Execute the query and return the filtered List. |
protected java.sql.ResultSet |
executeQuery(java.lang.String statement,
java.sql.PreparedStatement ps)
Convenience wrapper to executing JDBC queries. |
java.lang.Object |
executeWithArray(java.lang.Object[] parameterValues)
Execute the query and return the filtered List. |
java.lang.Object |
executeWithMap(java.util.Map parameters)
Execute the query and return the filtered result(s). |
java.lang.Class |
getCandidateClass()
Accessor for the class of the candidate instances of the query. |
protected java.lang.ClassLoader |
getCandidateLoader()
Returns the class loader of the candidade class |
java.lang.Object |
getExtension(java.lang.String key)
Accessor for the value of an extension for this query. |
javax.jdo.FetchPlan |
getFetchPlan()
This method retrieves the fetch plan associated with the Query. |
boolean |
getIgnoreCache()
Accessor for the ignoreCache option setting. |
javax.jdo.PersistenceManager |
getPersistenceManager()
Accessor for the PersistenceManager associated with this Query. |
protected java.lang.String |
getResultSetConcurrency()
Accessor for the result set concurrency. |
protected java.lang.String |
getResultSetType()
Accessor for the result set type. |
protected java.sql.PreparedStatement |
getStatement(java.sql.Connection conn,
StatementText stmtText)
Method to create a PreparedStatement for use with the query. |
protected java.sql.PreparedStatement |
getStatement(java.sql.Connection conn,
java.lang.String queryStmt)
Method to create a PreparedStatement for use with the query. |
StoreManager |
getStoreManager()
Accessor for the StoreManager associated with this Query. |
int |
hashCode()
Hashcode generator. |
boolean |
isSubclasses()
Accessor for whether this query includes subclasses |
boolean |
isUnmodifiable()
Accessor for unmodifiable. |
protected abstract long |
performDeletePersistentAll(java.util.Map parameters)
Method to actually execute the deletion of objects. |
protected abstract java.util.Collection |
performExecute(java.util.Map parameters)
Method to actually execute the query. |
protected void |
prepareStatementForExecution(java.sql.PreparedStatement ps)
Method to apply any query timeouts, and to add any restrictions to the created ResultSet. |
java.lang.Class |
resolveClassDeclaration(java.lang.String classDecl)
Utility to resolve the declaration to a particular class. |
void |
setCandidateClassName(java.lang.String candidateClassName)
Convenience method to set the name of the candidate class. |
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)
Mutator for the class of the candidate instances of the query. |
void |
setExtensions(java.util.Map extensions)
Set multiple extensions, or use null to clear extensions. |
void |
setFilter(java.lang.String filter)
Set the filter for the query. |
void |
setGrouping(java.lang.String grouping)
Set the grouping specification for the result Collection. |
void |
setIgnoreCache(boolean ignoreCache)
Set the ignoreCache option. |
void |
setOrdering(java.lang.String ordering)
Set the ordering specification for the result Collection. |
void |
setRange(long fromIncl,
long toExcl)
Set the range of the results. |
void |
setRange(java.lang.String range)
Set the range of the results. |
void |
setResult(java.lang.String result)
Set the result for the results. |
void |
setResultClass(java.lang.Class result_cls)
Set the result class for the results. |
void |
setResultClassName(java.lang.String resultClassName)
Convenience method to set the name of the result class. |
void |
setSubclasses(boolean subclasses)
Mutator for whether this query includes subclasses |
void |
setUnique(boolean unique)
Set the uniqueness of the results. |
void |
setUnmodifiable()
Mutator for unmodifiable. |
protected abstract boolean |
shouldReturnSingleRow()
Convenience method to return whether the query should return a single row. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final Localiser LOCALISER
protected final transient PersistenceManager pm
protected final transient DatastoreAdapter dba
protected java.lang.Class candidateClass
protected java.lang.String candidateClassName
protected boolean subclasses
protected boolean unique
protected java.lang.String result
protected java.lang.Class resultClass
protected java.lang.String resultClassName
protected java.lang.String filter
protected java.lang.String imports
protected java.lang.String variables
protected java.lang.String parameters
protected java.lang.String ordering
protected java.lang.String grouping
protected java.lang.String range
protected long fromInclNo
protected long toExclNo
protected boolean unmodifiable
protected boolean ignoreCache
protected final javax.jdo.FetchPlan fetchPlan
protected transient boolean isCompiled
protected transient Imports parsedImports
protected transient java.util.List parameterNames
protected transient java.util.Map parameterTypesByName
protected transient java.util.List variableNames
protected transient java.util.Map variableTypesByName
protected transient java.util.HashSet queryResults
protected transient boolean isPreCompile
protected java.util.Map extensions
Constructor Detail |
public Query(PersistenceManager pm)
pm
- The Persistence Manager for this query.Method Detail |
protected java.lang.ClassLoader getCandidateLoader()
protected void discardCompiled()
public boolean equals(java.lang.Object obj)
obj
- Object to compare against
public int hashCode()
public StoreManager getStoreManager()
public javax.jdo.PersistenceManager getPersistenceManager()
getPersistenceManager
in interface javax.jdo.Query
Query.getPersistenceManager()
public void addExtension(java.lang.String key, java.lang.Object value)
addExtension
in interface javax.jdo.Query
key
- the extension keyvalue
- the extension valuepublic void setExtensions(java.util.Map extensions)
setExtensions
in interface javax.jdo.Query
extensions
- addExtension(java.lang.String, java.lang.Object)
public java.lang.Object getExtension(java.lang.String key)
key
- The key
public javax.jdo.FetchPlan getFetchPlan()
getFetchPlan
in interface javax.jdo.Query
public java.lang.Class getCandidateClass()
Query.setClass(java.lang.Class)
public void setClass(java.lang.Class candidateClass)
setClass
in interface javax.jdo.Query
candidateClass
- the Class of the candidate instances.Query.setClass(java.lang.Class)
public void setCandidateClassName(java.lang.String candidateClassName)
candidateClassName
- Name of the candidate classpublic abstract void setCandidates(javax.jdo.Extent pcs)
setCandidates
in interface javax.jdo.Query
pcs
- the Candidate Extent.Query.setCandidates(javax.jdo.Extent)
public abstract void setCandidates(java.util.Collection pcs)
setCandidates
in interface javax.jdo.Query
pcs
- the Candidate collection.Query.setCandidates(java.util.Collection)
public void setFilter(java.lang.String filter)
setFilter
in interface javax.jdo.Query
filter
- the query filter.Query.setFilter(java.lang.String)
public void declareImports(java.lang.String imports)
declareImports
in interface javax.jdo.Query
imports
- import statements separated by semicolons.Query.declareImports(java.lang.String)
public void declareParameters(java.lang.String parameters)
declareParameters
in interface javax.jdo.Query
parameters
- the list of parameters separated by commas.Query.declareParameters(java.lang.String)
public void declareVariables(java.lang.String variables)
declareVariables
in interface javax.jdo.Query
variables
- the variables separated by semicolons.Query.declareVariables(java.lang.String)
public void setOrdering(java.lang.String ordering)
setOrdering
in interface javax.jdo.Query
ordering
- the ordering specification.Query.setOrdering(java.lang.String)
public void setGrouping(java.lang.String grouping)
setGrouping
in interface javax.jdo.Query
grouping
- the grouping specification.Query.setGrouping(java.lang.String)
public void setUnique(boolean unique)
setUnique
in interface javax.jdo.Query
unique
- whether the result is uniqueQuery.setUnique(boolean)
public void setRange(long fromIncl, long toExcl)
setRange
in interface javax.jdo.Query
fromIncl
- From element no (inclusive) to returntoExcl
- To element no (exclusive) to returnQuery.setRange(long, long)
public void setRange(java.lang.String range)
setRange
in interface javax.jdo.Query
range
- Range stringQuery.setRange(java.lang.String)
public void setResult(java.lang.String result)
setResult
in interface javax.jdo.Query
result
- The result parameter consists of the optional keyword
distinct followed by a commaseparated list of named result expressions or
a result class specification.Query.setResult(java.lang.String)
public void setResultClass(java.lang.Class result_cls)
setResultClass
in interface javax.jdo.Query
result_cls
- The result classQuery.setResultClass(java.lang.Class)
public void setResultClassName(java.lang.String resultClassName)
resultClassName
- Name of the result classpublic void setIgnoreCache(boolean ignoreCache)
setIgnoreCache
in interface javax.jdo.Query
ignoreCache
- the setting of the ignoreCache option.Query.setIgnoreCache(boolean)
,
PersistenceManager.setIgnoreCache(boolean)
public boolean getIgnoreCache()
getIgnoreCache
in interface javax.jdo.Query
setIgnoreCache(boolean)
,
Query.getIgnoreCache()
,
PersistenceManager.getIgnoreCache()
public boolean isSubclasses()
public void setSubclasses(boolean subclasses)
subclasses
- Where subclasses of the candidate class are to be included.public boolean isUnmodifiable()
isUnmodifiable
in interface javax.jdo.Query
protected void assertIsModifiable()
javax.jdo.JDOUserException
- Thrown when it is unmodifiablepublic void setUnmodifiable()
setUnmodifiable
in interface javax.jdo.Query
protected java.lang.String getResultSetType()
protected java.lang.String getResultSetConcurrency()
protected java.sql.PreparedStatement getStatement(java.sql.Connection conn, java.lang.String queryStmt) throws java.sql.SQLException
conn
- the ConnectionqueryStmt
- The statement text for the query
java.sql.SQLException
- Thrown if an error occurs creating the statementprotected java.sql.PreparedStatement getStatement(java.sql.Connection conn, StatementText stmtText) throws java.sql.SQLException
conn
- the ConnectionstmtText
- The statement text
java.sql.SQLException
- Thrown if an error occurs creating the statementprotected void prepareStatementForExecution(java.sql.PreparedStatement ps) throws java.sql.SQLException
ps
- The PreparedStatement
java.sql.SQLException
- Thrown when an error occurs applying the constraintspublic void compile()
compile
in interface javax.jdo.Query
Query.compile()
public java.lang.Class resolveClassDeclaration(java.lang.String classDecl)
classDecl
- The declaration
javax.jdo.JDOUserException
- Thrown if the class cannot be resolved.public java.lang.Object execute()
execute
in interface javax.jdo.Query
Query.execute()
,
executeWithArray(Object[] parameters)
public java.lang.Object execute(java.lang.Object p1)
execute
in interface javax.jdo.Query
p1
- the value of the first parameter declared.
Query.execute(Object)
,
executeWithArray(Object[] parameters)
public java.lang.Object execute(java.lang.Object p1, java.lang.Object p2)
execute
in interface javax.jdo.Query
p1
- the value of the first parameter declared.p2
- the value of the second parameter declared.
Query.execute(Object,Object)
,
executeWithArray(Object[] parameters)
public java.lang.Object execute(java.lang.Object p1, java.lang.Object p2, java.lang.Object p3)
execute
in interface javax.jdo.Query
p1
- the value of the first parameter declared.p2
- the value of the second parameter declared.p3
- the value of the third parameter declared.
Query.execute(Object,Object,Object)
,
executeWithArray(Object[] parameters)
public java.lang.Object executeWithArray(java.lang.Object[] parameterValues)
executeWithArray
in interface javax.jdo.Query
parameterValues
- the Object array with all of the parameters.
Query.executeWithArray(Object[])
protected abstract boolean shouldReturnSingleRow()
public java.lang.Object executeWithMap(java.util.Map parameters)
executeWithMap
in interface javax.jdo.Query
parameters
- the Map containing all of the parameters.
Query.executeWithMap(Map)
,
executeWithArray(Object[] parameters)
protected abstract java.util.Collection performExecute(java.util.Map parameters)
parameters
- Map containing the parameters.
protected java.sql.ResultSet executeQuery(java.lang.String statement, java.sql.PreparedStatement ps) throws java.sql.SQLException
statement
- The JDBC statement textps
- The PreparedStatement
java.sql.SQLException
- Thrown if an error occurs in the executionpublic long deletePersistentAll()
deletePersistentAll
in interface javax.jdo.Query
Query.deletePersistentAll()
public long deletePersistentAll(java.lang.Object[] parameters)
deletePersistentAll
in interface javax.jdo.Query
parameters
- the Object array with all of the parameters.
Query.deletePersistentAll(Object[])
public long deletePersistentAll(java.util.Map parameters)
deletePersistentAll
in interface javax.jdo.Query
parameters
- Map of parameters for the query
Query.deletePersistentAll(Map)
protected abstract long performDeletePersistentAll(java.util.Map parameters)
parameters
- Map containing the parameters.
public void close(java.lang.Object queryResult)
close
in interface javax.jdo.Query
queryResult
- the result of execute(...) on this Query instance.Query.close(java.lang.Object)
public void closeAll()
closeAll
in interface javax.jdo.Query
Query.closeAll()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |