Re: Trying to update meta data on objects which are saved

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sat Aug 27 2005 - 10:52:37 EDT

  • Next message: Andrus Adamchik: "Re: Lazily column retrieval"

    Hi,

    On Aug 27, 2005, at 4:58 AM, Jerome Chan wrote:

    > I'm trying to update some data about my objects when they are
    > saved. I have several different classes of objects which are saved.
    > My solution is to use DataContextDelegate's finishedMergeChanges
    > but it appears never to be called. When I call DataContext's
    > commitChanges, does this trigger the delegate's finishedMergeChanges?

    "finishedMergeChanges" is intended for things unrelated to commit. It
    provides a hook to react to changes resulted from update in a peer
    DataContext, i.e. when some other user committed changes that affect
    objects in your DataContext.

    > My other solution is to call my update method in ValidateForSave
    > but this would mean I would have to manually add in this call for
    > each class. (Or I could subclass CayenneDataObject but this seems
    > inelegant to me.)

    You are on the right track. Just override "validateForSave".
    Subclassing CayenneDataObject is very elegant and OO solution. And
    fully supported by Cayenne for that matter. Common superclass can be
    specified in the Modeler. Either for the whole DataMap (DataMap
    "DataObject Superclass" field) or per entity (ObjEntity "Superclass").

    Andrus



    This archive was generated by hypermail 2.0.0 : Sat Aug 27 2005 - 10:52:40 EDT