SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

com.solarmetric.kodo.runtime.datacache.query
Class CacheAwareQuery

java.lang.Object
  |
  +--com.solarmetric.kodo.runtime.datacache.query.CacheAwareQuery
All Implemented Interfaces:
com.solarmetric.kodo.query.KodoQuery, Query, Serializable

public class CacheAwareQuery
extends Object
implements com.solarmetric.kodo.query.KodoQuery

A Query implementation that caches the OIDs involved in the query, and can determine whether or not the query has been dirtied.

Since:
2.5.0
See Also:
Serialized Form

Inner Class Summary
(package private) static class CacheAwareQuery.CachedResultList
           
 
Fields inherited from interface com.solarmetric.kodo.query.KodoQuery
FLUSH_ALWAYS, FLUSH_ALWAYS_MODE, FLUSH_NEVER, FLUSH_NEVER_MODE, FLUSH_WITH_CONNECTION, FLUSH_WITH_CONNECTION_MODE
 
Constructor Summary
CacheAwareQuery(com.solarmetric.kodo.query.KodoQuery query, DataCacheStoreManager store)
          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.
protected  ResultList 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)
           
 Set getAccessPathClasses()
           
 QueryCache getCache()
          Return the QueryCache that this object is associated with.
 Class getCandidateClass()
           
 Collection getCandidateCollection()
           
 Extent getCandidateExtent()
           
 com.solarmetric.kodo.query.KodoQuery getDelegate()
          Returns the query that is being cached.
 String getFilter()
           
 int getFlushBeforeQueries()
           
 boolean getIgnoreCache()
           
 String getOrdering()
           
 String[][] getParameterDeclarations()
           
 PersistenceManager getPersistenceManager()
           
 boolean getQueryCacheEnabled()
           
 void setCandidates(Collection arg)
           
 void setCandidates(Extent arg)
           
 void setClass(Class arg)
           
 void setFilter(String arg)
           
 void setFlushBeforeQueries(int flushBeforeQueries)
           
 void setIgnoreCache(boolean arg)
           
 void setOrdering(String arg)
           
 void setQueryCacheEnabled(boolean arg)
           
protected  ResultList wrapList(Object o, QueryKey qk)
          Wrap the query result list in a list that will cache the values upon completion of the traversal of the underlying list.
 Object writeReplace()
          Serialize the delegate query, not the cache-aware query.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheAwareQuery

public CacheAwareQuery(com.solarmetric.kodo.query.KodoQuery query,
                       DataCacheStoreManager store)
Create a new CacheAwareQuery that delegates to query if no cached results are available.
Method Detail

checkCache

protected ResultList 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.


wrapList

protected ResultList wrapList(Object o,
                              QueryKey qk)

Wrap the query result list 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.


getCache

public QueryCache getCache()
Return the QueryCache that this object is associated with.

abortCaching

public void abortCaching()
Instructs this query to notify all CachingList objects created by it to stop caching results. Upon invoking this method, all caching efforts are aborted, and any partial results are dropped.

getDelegate

public com.solarmetric.kodo.query.KodoQuery getDelegate()
Returns the query that is being cached. This should not be mutated directly.

setClass

public void setClass(Class arg)
Specified by:
setClass in interface Query

setCandidates

public void setCandidates(Extent arg)
Specified by:
setCandidates in interface Query

setCandidates

public void setCandidates(Collection arg)
Specified by:
setCandidates in interface Query

setFilter

public void setFilter(String arg)
Specified by:
setFilter in interface Query

declareImports

public void declareImports(String arg)
Specified by:
declareImports in interface Query

declareParameters

public void declareParameters(String arg)
Specified by:
declareParameters in interface Query

declareVariables

public void declareVariables(String arg)
Specified by:
declareVariables in interface Query

setOrdering

public void setOrdering(String arg)
Specified by:
setOrdering in interface Query

setIgnoreCache

public void setIgnoreCache(boolean arg)
Specified by:
setIgnoreCache in interface Query

getIgnoreCache

public boolean getIgnoreCache()
Specified by:
getIgnoreCache in interface Query

compile

public void compile()
Specified by:
compile in interface Query

execute

public Object execute()
Specified by:
execute in interface Query

execute

public Object execute(Object arg)
Specified by:
execute in interface Query

execute

public Object execute(Object arg0,
                      Object arg1)
Specified by:
execute in interface Query

execute

public Object execute(Object arg0,
                      Object arg1,
                      Object arg2)
Specified by:
execute in interface Query

executeWithMap

public Object executeWithMap(Map args)
Specified by:
executeWithMap in interface Query

executeWithArray

public Object executeWithArray(Object[] args)
Specified by:
executeWithArray in interface Query

getPersistenceManager

public PersistenceManager getPersistenceManager()
Specified by:
getPersistenceManager in interface Query

close

public void close(Object arg)
Specified by:
close in interface Query

closeAll

public void closeAll()
Specified by:
closeAll in interface Query

getParameterDeclarations

public String[][] getParameterDeclarations()
Specified by:
getParameterDeclarations in interface com.solarmetric.kodo.query.KodoQuery

getAccessPathClasses

public Set getAccessPathClasses()
Specified by:
getAccessPathClasses in interface com.solarmetric.kodo.query.KodoQuery

getCandidateExtent

public Extent getCandidateExtent()
Specified by:
getCandidateExtent in interface com.solarmetric.kodo.query.KodoQuery

getCandidateCollection

public Collection getCandidateCollection()
Specified by:
getCandidateCollection in interface com.solarmetric.kodo.query.KodoQuery

getCandidateClass

public Class getCandidateClass()
Specified by:
getCandidateClass in interface com.solarmetric.kodo.query.KodoQuery

getFilter

public String getFilter()
Specified by:
getFilter in interface com.solarmetric.kodo.query.KodoQuery

getOrdering

public String getOrdering()
Specified by:
getOrdering in interface com.solarmetric.kodo.query.KodoQuery

setQueryCacheEnabled

public void setQueryCacheEnabled(boolean arg)
Specified by:
setQueryCacheEnabled in interface com.solarmetric.kodo.query.KodoQuery

getQueryCacheEnabled

public boolean getQueryCacheEnabled()
Specified by:
getQueryCacheEnabled in interface com.solarmetric.kodo.query.KodoQuery

setFlushBeforeQueries

public void setFlushBeforeQueries(int flushBeforeQueries)
Specified by:
setFlushBeforeQueries in interface com.solarmetric.kodo.query.KodoQuery

getFlushBeforeQueries

public int getFlushBeforeQueries()
Specified by:
getFlushBeforeQueries in interface com.solarmetric.kodo.query.KodoQuery

writeReplace

public Object writeReplace()
                    throws ObjectStreamException
Serialize the delegate query, not the cache-aware query.

SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.