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

From: Jerome Chan (eviltof..ac.com)
Date: Sat Aug 27 2005 - 12:35:17 EDT

  • Next message: Andrus Adamchik: "Re: Trying to update meta data on objects which are saved"

    On 27 Aug 2005, at 10:52 PM, Andrus Adamchik wrote:

    Would it be a good idea to put in hooks for when an object changes
    state?

    My other other solution is to subclass DataContext and perform my
    method call in commit changes instead. Less code for me to write. :P

    > 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 - 12:36:02 EDT