Re: caching of query results

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Jan 27 2005 - 23:34:08 EST

  • Next message: Andrus Adamchik: "Re: Problems with CommitChanges and object PersistenceState"

    Hi Bryan,

    You probably saw this chapter in the user guide, but just in case -
    http://objectstyle.org/cayenne/userguide/fetch/result-caching.html

    The exception is thrown when the query doesn't have a name, here is
    this piece of code:

    String name = query.getName();
    if (useCache && name == null) {
        throw new CayenneRuntimeException(
           "Caching of unnamed queries is not supported.");
    }

     From the code you showed this should never happen, so maybe the best
    way is to use Eclipse debugger to look at the objects state just before
    the error occurs? Otherwise it is hard to guess what's wrong.

    Andrus

    On Jan 27, 2005, at 12:25 AM, Bryan Lewis wrote:
    > Doh. Of course. Thanks. However, when I fix that, I get this
    > exception:
    >
    > Caching of unnamed queries is not supported.
    >
    > at the performQuery() line.
    >
    > The query does have a name... I double-checked with getName().
    >
    >
    > ----- Original Message -----
    > From: "Robert Zeigler" <rdzeigl...arizona.edu>
    > To: <cayenne-use..bjectstyle.org>
    > Sent: Wednesday, January 26, 2005 11:35 PM
    > Subject: Re: caching of query results
    >
    >
    >>>
    >>> if (firstTime) {
    >>> // Create the query.
    >>> query.setName(uniqueName);
    >>> myDataMap.addQuery(query);
    >>> }
    >>
    >> The default policy for caching is no cache.
    >> Try adding:
    >> query.setCachePolicy(/*appropriate cache policy*/);
    >> If the cache is supposed to be shared by all clients, do
    >> query.setCachePolicy(GenericSelectQuery.SHARED_CACHE);
    >> If the cache should be locale to the data context associated with the
    >> current user, do:
    >> query.setCachePolicy(GenericSelectQuery.LOCAL_CACHE);
    >>
    >> Robert
    >



    This archive was generated by hypermail 2.0.0 : Thu Jan 27 2005 - 23:34:14 EST