Re: avoid caching on fetching by primary key

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Mar 06 2006 - 13:31:51 EST

  • Next message: Andrus Adamchik: "Re: Session persistence and initialization"

    I think a possible source of confusion is that ObjectIdQuery is a new
    name for SingleObjectQuery that exists in Cayenne 1.2M11. So in M11
    terms you can do this:

    object = DataObjectUtils.objectForQuery
                (dataContext,
                 new SingleObjectQuery(primaryKey, false, true));

    The "true" parameter is exactly the refreshing flag you are looking for.

    Andrus

    On Mar 6, 2006, at 8:45 PM, Mahmut Izci wrote:
    > Hi Michael,
    >
    > thank you much. This did not work, because cayenne is still caching.
    > I changed the row in the database by another application and
    > cayenne did not recognize it.
    >
    > It is possible to turn on refreshing of query results
    > ( query.setRefreshingObjects(true) ),
    > but cayenne does not generate getters/setters for primary keys by
    > default, so that queries are not possible.
    > Nevertheless maybe there is a way to use a SelectQuery with primary
    > keys.
    >
    > Mahmut
    >>
    >> Gentry, Michael (Contractor) schrieb:
    >>> Oh yeah, to get an ObjectId, use
    >>>
    >>> new ObjectId("EntityName", "pkAttributeName", pk)
    >>>
    >>> for "primaryKey" below. Look at the constructors for ObjectId if
    >>> you
    >>> have compound keys/etc. Like I said, I didn't test it. :-)
    >>>
    >>> /dev/mrg
    >>>
    >>>
    >>> -----Original Message-----
    >>> From: Gentry, Michael (Contractor)
    >>> [mailto:michael_gentr..anniemae.com]
    >>>
    >>> Sent: Monday, March 06, 2006 10:18 AM
    >>> To: cayenne-use..bjectstyle.org
    >>> Subject: RE: avoid caching on fetching by primary key
    >>>
    >>>
    >>> I haven't tested this, but try:
    >>>
    >>> object = DataObjectUtils.objectForQuery
    >>> (dataContext,
    >>> new ObjectIdQuery(primaryKey));
    >>>
    >>> /dev/mrg
    >>>
    >>>
    >>> -----Original Message-----
    >>> From: Mahmut Izci [mailto:mahmut.izc..reenet.de] Sent: Monday,
    >>> March 06, 2006 7:00 AM
    >>> To: cayenne-use..bjectstyle.org
    >>> Subject: avoid caching on fetching by primary key
    >>>
    >>>
    >>> Hi,
    >>>
    >>> I'm using DataObjectUtils.objectForPK to find entries. But this
    >>> method
    >>>
    >>> is caching the query results.
    >>> Alternatively I tried to use select queries, but cayenne did not
    >>> generate getters and setters for primary keys.
    >>>
    >>> How can i fetch by primary keys and avoid caching?
    >>>
    >>> Thanks
    >>> Mahmut
    >>>
    >>>
    >>
    >>
    >
    >



    This archive was generated by hypermail 2.0.0 : Mon Mar 06 2006 - 13:31:53 EST