how to catch updates just before commit

From: Bryan Lewis (brya..aine.rr.com)
Date: Fri Apr 28 2006 - 12:40:25 EDT

  • Next message: Mike Kienenberger: "Re: how to catch updates just before commit"

    We have a time-when-last-modified timestamp column in most of our tables
    to serve as an optimistic-locking attribute. At present we're setting
    it with a bit of inelegant code that imitates the way we used to do it
    in our old WebObjects days... we have a saveChanges() method that wraps
    dc.commitChanges(). Before the commit we can timesstamp the newObjects
    and modifiedObjects.

    The trouble is, this sets the timestamp on objects that haven't really
    been modified... an attribute was set to the same value it already had,
    or a to-many relationship was added to. Cayenne figures out later in
    the pipeline that those other changes aren't real and doesn't generate
    SQL for them. How can I hook into that later point, and set the
    timestamp only if the row is about to be updated? I looked at
    DataContextDelegate, but I guess that's for external changes. The event
    mechanism looks closer, although the docs say that dc.onSync() isn't
    intended for direct use. Worst case, I could compare the object's
    current values to the snapshot but that seems reinventing the plumbing.

    Thanks.



    This archive was generated by hypermail 2.0.0 : Fri Apr 28 2006 - 12:40:57 EDT