Re: Relationship caching

From: Mike Kienenberger (mkienen..mail.com)
Date: Tue Apr 15 2008 - 12:56:20 EDT

  • Next message: Laurent Marchal: "Re: Relationship caching"

    One way to guarantee it would be to change the code generation so that
    the getters perform an explicit query. You'll always be sure to get
    the latest database values, and you won't have to worry about
    invalidating anything.

    In Cayenne 1.2 code, it'd look something like this, although there's a
    bit more work involved in getting the generator to populate the
    upper-case values. If you need help with that, ask.

    public List<AccessCode> getRelatedAccessCodes()
    {
          return getDataContext().performQuery(
                new SelectQuery(RELATIONSHIP_TARGET_ENTITY_CLASS,

    ExpressionFactory.matchExp(REVERSE_RELATIONSHIP_PROPERTY_NAME,
    this)));
    }

    On 4/15/08, Laurent Marchal <lmarcha..maeur.com> wrote:
    > Hello,
    >
    > i have disabled caching in cayenne with :
    >
    > <property name="cayenne.DataDomain.sharedCache"
    > value="false"/>
    >
    > but when i want to use a flatened relationship like :
    >
    > List<AccessCode> userAccessCodes = user.getRelatedAccessCodes();
    >
    > the SQL request is only made the first time, after cayenne use his cache to
    > return the AccessCode list.
    > The only way i found to force cayenne to resend the query is to use :
    >
    > _context.performNonSelectingQuery(new
    > RefreshQuery(user));
    >
    > but this query invalidate all others relationships of the user object.
    >
    > - Why cayenne is caching, how can i disable all caches ?
    > - Is there a way to NOT cache relationships by default and re-ask
    > relationships each time ?
    >
    > thanks.
    >
    > Laurent Marchal
    >



    This archive was generated by hypermail 2.0.0 : Tue Apr 15 2008 - 12:56:55 EDT