|
SolarMetric Kodo JDO 3.2.4 generated on January 7 2005 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--kodo.datacache.CacheAwareQuery
A Query
implementation that caches the OIDs involved in
the query, and can determine whether or not the query has been
dirtied.
Fields inherited from interface kodo.query.KodoQuery |
FLUSH_FALSE, FLUSH_TRUE, FLUSH_WITH_CONNECTION |
Constructor Summary | |
CacheAwareQuery(KodoQuery query,
QueryCache cache)
Create a new CacheAwareQuery that delegates to
query if no cached results are available. |
Method Summary | |
void |
abortCaching()
Instructs this query to notify all CachingList objects
created by it to stop caching results. |
void |
addAggregateListener(AggregateListener listener)
Register an aggregate listener for the query. |
void |
addExtension(String key,
Object value)
JDO 2.0 Preview. |
void |
addFilterListener(FilterListener listener)
Register a filter listener for the query. |
protected Object |
checkCache(QueryKey qk)
Look in the query cache for a result for the given query key. |
void |
close(Object arg)
|
void |
closeAll()
|
void |
compile()
|
void |
declareImports(String arg)
|
void |
declareParameters(String arg)
|
void |
declareVariables(String arg)
|
Object |
execute()
|
Object |
execute(Object arg)
|
Object |
execute(Object arg0,
Object arg1)
|
Object |
execute(Object arg0,
Object arg1,
Object arg2)
|
Object |
executeWithArray(Object[] args)
|
Object |
executeWithMap(Map args)
|
ClassMetaData[] |
getAccessPathMetaDatas()
Return the classes that affect this query. |
Collection |
getAggregateListeners()
Return the aggregate listeners added to this query, or empty collection if none. |
String |
getAlias()
When we're returning standard candidate instances rather than a projection or aggregate, return the alias for the instances in case a result class is set. |
String[] |
getAliases()
Return the aliases for the result expressions. |
boolean[] |
getAscending()
Return wheher each ordering is ascending. |
QueryCache |
getCache()
Return the QueryCache that this object is associated
with. |
Class |
getCandidateClass()
Return the class of the objects that this query will return, or null if this information is not available /
not relevant. |
Collection |
getCandidateCollection()
Return the candidate collection, or null if an
extent was specified instead of a collection. |
KodoExtent |
getCandidateExtent()
Return the candidate extent, or null if a
collection was specified instead of an extent. |
String[] |
getDataStoreActions(Map params)
Returns a description of the commands that will be sent to the datastore in order to execute this query. |
KodoQuery |
getDelegate()
Returns the query that is being cached. |
long |
getEndIndex()
Return the 0-based exclusive end index for the returned results, or Long.MAX_VALUE for no limit. |
FetchConfiguration |
getFetchConfiguration()
Return the (mutable) fetch configuration for this query. |
String |
getFilter()
Return the filter that this query has been configured with. |
Collection |
getFilterListeners()
Return the filter listeners added to this query, or empty collection if none. |
String |
getGrouping()
Return the grouping expression for this query. |
String[] |
getGroupingClauses()
Return the grouping expressions. |
String |
getHaving()
Return the having clause. |
boolean |
getIgnoreCache()
|
String[] |
getImportPackages()
Return the import packages. |
String |
getImports()
Return the import declaration. |
String |
getLanguage()
Return the language of this query. |
String |
getOrdering()
Return the ordering expression that this query was configured with. |
String[] |
getOrderingClauses()
Return the ordering criteria. |
String |
getParameters()
Return the declared parameters. |
org.apache.commons.collections.map.LinkedMap |
getParameterTypes()
Return a map of parameter name to type for this query. |
PersistenceManager |
getPersistenceManager()
|
String |
getQueryString()
Return a single-string representation of the query, if applicable. |
String |
getResult()
Return the result expression set for this query. |
Class |
getResultClass()
Returns the result class that has been set through setResultClass(java.lang.Class) , or null if none. |
String[] |
getResultClauses()
Return the result expressions. |
Class[] |
getResultTypes()
Return the type of each result clause. |
long |
getStartIndex()
Return the 0-based start index for the returned results. |
String |
getVariables()
Return the declared variables. |
Map |
getVariableTypes()
Return a map of variable name to type for this query. |
boolean |
hasSubclasses()
Whether query results will include subclasses of the candidate class. |
boolean |
isAggregate()
Return true if the query is an aggregate. |
boolean |
isDistinct()
Whether the result specifies that this is a distinct query. |
boolean |
isQueryStringPreferred()
Return true if the preferred style of query representation is with a single query string. |
boolean |
isUnique()
The unique flag. |
void |
lock()
Synchronize on the query's internal lock. |
void |
removeAggregateListener(AggregateListener listener)
Remove an aggregate listener from the query. |
void |
removeFilterListener(FilterListener listener)
Remove a filter listener from the query. |
void |
setCandidates(Collection arg)
|
void |
setCandidates(Extent arg)
|
void |
setClass(Class arg)
|
void |
setExtensions(Map map)
JDO 2.0 Preview. |
void |
setFilter(String arg)
|
void |
setGrouping(String group)
JDO 2.0 Preview. |
void |
setIgnoreCache(boolean arg)
|
void |
setOrdering(String arg)
|
void |
setQuery(Object query)
Fill in query state from a query string or template. |
void |
setRange(long start,
long end)
JDO 2.0 Preview. |
void |
setResult(String result)
JDO 2.0 Preview. |
void |
setResultClass(Class cls)
JDO 2.0 Preview. |
void |
setUnique(boolean unique)
JDO 2.0 Preview. |
void |
unlock()
Unlock the query's internal lock. |
protected Object |
wrapResult(Object o,
QueryKey qk)
Wrap the query result in a list that will cache the values upon completion of the traversal of the underlying list. |
Object |
writeReplace()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CacheAwareQuery(KodoQuery query, QueryCache cache)
CacheAwareQuery
that delegates to
query
if no cached results are available.Method Detail |
protected Object checkCache(QueryKey qk)
Look in the query cache for a result for the given query key. Only look if this query is being executed outside a transaction or in a transaction with IgnoreCache set to true or in a transaction with IgnoreCache set to false but in which none of the classes involved in this query have been touched.
Caching is not used when using pessimistic transactions. This is because we must obtain locks on the data, and it is likely that making n trips to the database to make the locks will be slower than running the query against the database.
If KodoQuery#getQueryCacheEnabled
returns
false
, this method returns null
.
Return the list if we meet the above criteria and if a list
is found for qk
. Else, return
null
.
This implementation means that queries against the cache are of READ_COMMITTED isolation level. It'd be nice to support READ_SERIALIZABLE -- to do so, we'd just return false when in a transaction.
protected Object wrapResult(Object o, QueryKey qk)
Wrap the query result in a list that will cache the values upon completion of the traversal of the underlying list.
This list must not register its results with the cache if one of the classes involved in this query is touched during the traversal of the query.
This method may decide not to do any caching of the query identified. For example, it might just return the supplied list if the query involves classes that are not cacheable.
public QueryCache getCache()
QueryCache
that this object is associated
with.public void abortCaching()
CachingList
objects
created by it to stop caching results. Upon invoking this
method, all caching efforts are aborted, and any partial
results are dropped.public KodoQuery getDelegate()
public Object writeReplace() throws ObjectStreamException
public void setClass(Class arg)
setClass
in interface Query
public void setCandidates(Extent arg)
setCandidates
in interface Query
public void setCandidates(Collection arg)
setCandidates
in interface Query
public void setFilter(String arg)
setFilter
in interface Query
public void declareImports(String arg)
declareImports
in interface Query
public void declareParameters(String arg)
declareParameters
in interface Query
public void declareVariables(String arg)
declareVariables
in interface Query
public void setOrdering(String arg)
setOrdering
in interface Query
public void setIgnoreCache(boolean arg)
setIgnoreCache
in interface Query
public boolean getIgnoreCache()
getIgnoreCache
in interface Query
public void compile()
compile
in interface Query
public Object execute()
execute
in interface Query
public Object execute(Object arg)
execute
in interface Query
public Object execute(Object arg0, Object arg1)
execute
in interface Query
public Object execute(Object arg0, Object arg1, Object arg2)
execute
in interface Query
public Object executeWithMap(Map args)
executeWithMap
in interface Query
public Object executeWithArray(Object[] args)
executeWithArray
in interface Query
public PersistenceManager getPersistenceManager()
getPersistenceManager
in interface Query
public void close(Object arg)
close
in interface Query
public void closeAll()
closeAll
in interface Query
public String getLanguage()
KodoQuery
getLanguage
in interface KodoQuery
public FetchConfiguration getFetchConfiguration()
KodoQuery
getFetchConfiguration
in interface KodoQuery
public Collection getFilterListeners()
KodoQuery
getFilterListeners
in interface KodoQuery
public void addFilterListener(FilterListener listener)
KodoQuery
addFilterListener
in interface KodoQuery
public void removeFilterListener(FilterListener listener)
KodoQuery
removeFilterListener
in interface KodoQuery
public Collection getAggregateListeners()
KodoQuery
getAggregateListeners
in interface KodoQuery
public void addAggregateListener(AggregateListener listener)
KodoQuery
addAggregateListener
in interface KodoQuery
public void removeAggregateListener(AggregateListener listener)
KodoQuery
removeAggregateListener
in interface KodoQuery
public KodoExtent getCandidateExtent()
KodoQuery
null
if a
collection was specified instead of an extent.getCandidateExtent
in interface KodoQuery
public Collection getCandidateCollection()
KodoQuery
null
if an
extent was specified instead of a collection.getCandidateCollection
in interface KodoQuery
public Class getCandidateClass()
KodoQuery
null
if this information is not available /
not relevant.getCandidateClass
in interface KodoQuery
public boolean hasSubclasses()
KodoQuery
hasSubclasses
in interface KodoQuery
public void setQuery(Object query)
KodoQuerySPI
setQuery
in interface KodoQuerySPI
public boolean isQueryStringPreferred()
KodoQuerySPI
isQueryStringPreferred
in interface KodoQuerySPI
public String getQueryString()
KodoQuery
getQueryString
in interface KodoQuery
public String getFilter()
KodoQuery
getFilter
in interface KodoQuery
public String getOrdering()
KodoQuery
getOrdering
in interface KodoQuery
public String getImports()
KodoQuery
getImports
in interface KodoQuery
public String getParameters()
KodoQuery
getParameters
in interface KodoQuery
public String getVariables()
KodoQuery
getVariables
in interface KodoQuery
public void setUnique(boolean unique)
KodoQuery
setUnique
in interface KodoQuery
public boolean isUnique()
KodoQuery
isUnique
in interface KodoQuery
public void setResult(String result)
KodoQuery
null
, this
query will return a list of the query's candidate class. Otherwise,
this query will return aggregate function results and / or
individual field values (projections).setResult
in interface KodoQuery
kodo.query.KodoQuery
result
- optional "distinct" keyword, followed by a
comma-delimited list of fields, functions on fields,
or aggregate functions to return from this querypublic String getResult()
KodoQuery
getResult
in interface KodoQuery
public void setResultClass(Class cls)
KodoQuery
Query.execute()
or one of its siblings. The
behavior of this method depends the nature of the query being executed.
In particular, if used in conjunction with KodoQuery.setResult(java.lang.String)
,
the argument to this method should be
Object[].class
, a class with bean-like setters
for each of the items listed in the result specification, or
a class with a method called put
with two
Object
arguments.setResultClass
in interface KodoQuery
public Class getResultClass()
KodoQuery
KodoQuery.setResultClass(java.lang.Class)
, or null if none.getResultClass
in interface KodoQuery
public void setGrouping(String group)
KodoQuery
setGrouping
in interface KodoQuery
kodo.query.KodoQuery
group
- a comma-delimited list of expressions, optionally
followed by the "having" keyword and a boolean
expressionpublic String getGrouping()
KodoQuery
getGrouping
in interface KodoQuery
public void setRange(long start, long end)
KodoQuery
setRange
in interface KodoQuery
kodo.query.KodoQuery
start
- 0-based inclusive start indexend
- 0-based exclusive end index, or
Long.MAX_VALUE
for no limitpublic long getStartIndex()
KodoQuery
getStartIndex
in interface KodoQuery
public long getEndIndex()
KodoQuery
Long.MAX_VALUE
for no limit.getEndIndex
in interface KodoQuery
public void addExtension(String key, Object value)
KodoQuery
kodo.FilterListener
: Register a filter listener for
this query; analogous to invoking KodoQuery.addFilterListener(kodo.query.FilterListener)
.kodo.AggregateListener
: Register an aggregate listener
for this query; analogous to invoking
KodoQuery.addAggregateListener(kodo.query.AggregateListener)
.kodo.FetchPlan.<property>
: Set the
bean property
of this query's fetch plan to the
supplied value.addExtension
in interface KodoQuery
public void setExtensions(Map map)
KodoQuery
setExtensions
in interface KodoQuery
kodo.query.KodoQuery
KodoQuery.addExtension(java.lang.String, java.lang.Object)
public boolean isAggregate()
KodoQuerySPI
isAggregate
in interface KodoQuerySPI
public String[] getDataStoreActions(Map params)
KodoQuery
getDataStoreActions
in interface KodoQuery
kodo.query.KodoQuery
params
- the named parameter map for the query invocationpublic ClassMetaData[] getAccessPathMetaDatas()
KodoQuerySPI
getAccessPathMetaDatas
in interface KodoQuerySPI
public String[] getImportPackages()
KodoQuerySPI
getImportPackages
in interface KodoQuerySPI
public org.apache.commons.collections.map.LinkedMap getParameterTypes()
KodoQuerySPI
getParameterTypes
in interface KodoQuerySPI
public Map getVariableTypes()
KodoQuerySPI
getVariableTypes
in interface KodoQuerySPI
public String[] getOrderingClauses()
KodoQuerySPI
getOrderingClauses
in interface KodoQuerySPI
public boolean[] getAscending()
KodoQuerySPI
getAscending
in interface KodoQuerySPI
public String[] getResultClauses()
KodoQuerySPI
getResultClauses
in interface KodoQuerySPI
public Class[] getResultTypes()
KodoQuerySPI
getResultTypes
in interface KodoQuerySPI
public String[] getAliases()
KodoQuerySPI
getAliases
in interface KodoQuerySPI
public String getAlias()
KodoQuerySPI
getAlias
in interface KodoQuerySPI
public boolean isDistinct()
KodoQuerySPI
isDistinct
in interface KodoQuerySPI
public String[] getGroupingClauses()
KodoQuerySPI
getGroupingClauses
in interface KodoQuerySPI
public String getHaving()
KodoQuerySPI
getHaving
in interface KodoQuerySPI
public void lock()
KodoQuerySPI
lock
in interface KodoQuerySPI
public void unlock()
KodoQuerySPI
unlock
in interface KodoQuerySPI
|
SolarMetric Kodo JDO 3.2.4 generated on January 7 2005 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |