Re: Caching/Concurrency Questions

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Jun 09 2004 - 01:00:46 EDT

  • Next message: Marko Kocic: "Re: Cayenne Article on TheServerSide.com"

    Hi Paul,

    Good question, I should've mentioned that.

    Two DataObjects residing in peer DataContexts have no "hard" link with
    each other. What makes them "related" is their ObjectIds.

    Now, when an object is updated and then committed in one DataContext,
    what happens to the peers? Peer synchronization is done via events.
    Default behavior of the peer DataContext [see
    ObjectStore.snapshotsChanged(..) method for details] is to invalidate
    all COMMITTED objects, and merge changes to the MODIFIED and DELETED
    objects. But if the same property is already modified in the peer
    object, merge process will leave it alone.

    If you want fine grained control over merging behavior, implement a
    DataContextDelegate:
    http://objectstyle.org/cayenne/userguide/datactxt/data-context-
    delegate.html

    Andrus

    On Jun 8, 2004, at 10:41 PM, PaulC.177094..loglines.com wrote:
    > Andrus,
    >
    > Thanks for the explanation - I am strill trying to get the hang
    > of the concepts.
    >
    > Just to clarify my understanding - if a single database
    > record (DataRow) is instantiated into a object graph in two different
    > DataContexts
    > (through a query) are the corresponding DataObjects linked in any way,
    > and
    > is there any way a DataContext can be notified that a contained object
    > has
    > been modified & committed in another DataContext other than trying to
    > commit
    > with optimisitic locking enabled for the appropriate properties and
    > catching
    > the exception ?
    >
    > Thanks again.
    >
    > Paul
    >
    >
    > --- Andrus Adamchik <andru..bjectstyle.org
    > wrote:
    > Hi PaulC,
    >>
    >> Shared cache actually stores DataRows. DataRows are
    > maps of values
    >> representing object snapshots. Snapshots from the cache
    > are used for a
    >> number of things. Mainly to lazily build UPDATE queries
    > and to lazily
    >> resolve to-one relationships.
    >>
    >> On the other hand,
    > when you retrieve *lists* of objects (i.e. by
    >> running a query explicitly,
    > or when resolving a to-many relationship),
    >> Cayenne still has to hit the
    > database, as it needs to know *which*
    >> snapshots match the query criteria
    > (and it does not attempt to suck the
    >> whole DB in memory).
    >>
    >> BTW,
    > in the upcoming M7 milestone caching of query results is also
    >> supported
    >
    >> (http://objectstyle.org/cayenne/lists/cayenne-devel/2004/06/0002.html
    >
    >> ). But it will be explicit, while snapshots use is works behind the
    >> scenes whenever possible.
    >>
    >> Andrus
    >>



    This archive was generated by hypermail 2.0.0 : Wed Jun 09 2004 - 01:00:51 EDT