Re: Exception when caching a SelectQuery with prefetching [WAS: Caching]

From: Andrey Razumovsky (razumovsky.andre..mail.com)
Date: Thu May 20 2010 - 07:03:06 UTC

  • Next message: Andrus Adamchik: "Re: Building dataview jar for use with Cayenne 3.0 (or...is ANYONE using dataviews in 3.0?)"

    Looks like a bug. Could you please open a ticket?

    2010/5/20 Gary Jarrel <garyjarre..mail.com>

    > Hi,
    > I managed to get the cache issue described below resolved, my error
    > with the DataContextFilter that I was using and it was overwriting the
    > modeler configuration when initializing shared config.
    >
    > I've ran into another issue with the following code:
    >
    > SelectQuery q = proto.queryWithParameters(params);
    > q.addPrefetch(RichProduct.MANUFACTURER_PROPERTY);
    > q.addPrefetch(RichProduct.RAW_PRODUCT_PROPERTY);
    > q.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
    > q.setCacheGroups("products");
    >
    > Upon execution of this query I get the following exception:
    >
    > ERROR com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache
    > [oscache] Exception persisting RichProduct/subCategory =
    > <ObjectId:SubCategory, category_id=1,
    > id=1>/categoryName/subCategoryName/cost
    > com.opensymphony.oscache.base.persistence.CachePersistenceException:
    > Unable to write
    > '/tmp/cache/application/0/0/5/005126BC80FABAA4C582919EDF0B9304.cache'
    > in the cache. Exception: java.io.NotSerializableException, Message:
    > org.apache.cayenne.access.ListWithPrefetches
    > at
    > com.opensymphony.oscache.plugins.diskpersistence.AbstractDiskPersistenceListener.store(AbstractDiskPersistenceListener.java:376)
    > at
    > com.opensymphony.oscache.plugins.diskpersistence.AbstractDiskPersistenceListener.store(AbstractDiskPersistenceListener.java:238)
    >
    > <rest of stack trace removed>
    >
    > If I however remove the prefetches then the caching works fine.
    >
    > Looking at the source code for ListWithPrefetches it does not
    > implement Serializable, could this be the reason for it, or am I
    > missing something!
    >
    > Thank you
    >
    > Gary
    >
    > On Wed, May 19, 2010 at 6:17 PM, Gary Jarrel <garyjarre..mail.com> wrote:
    > >
    > > Hi Guys,
    > > I seem to full of questions today!
    > > In the modeler I've got org.apache.cayenne.cache.OSQueryCacheFactory for
    > Query Cache Factory, 5000 objects and using shared cache.
    > > I can see OSCache initializing in the logs and everything appears to be
    > fine.
    > > However when I try to get the cache from the ObjectContext like so:
    > > QueryCache cache = ((BaseContext) getObjectContext()).getQueryCache();
    > > The cache that is being returned is
    > the org.apache.cayenne.cache.MapQueryCache
    > > I've traced the calls and can see that the call got getQueryCache() goes
    > to MapQueryCacheFactory despite the fact that the modeler
    > specifies OSQueryCacheFactory
    > > Am I doing something wrong here?
    > > Thank you
    > > Gary
    >

    -- 
    Andrey
    



    This archive was generated by hypermail 2.0.0 : Thu May 20 2010 - 07:03:57 UTC