Re: Default/Initial values && post validation delegates etc

From: Lachlan Deck (lachla..sh.com.au)
Date: Mon Sep 11 2006 - 22:08:12 EDT

  • Next message: Ayhan Kondoz: "NullPointerException when using shared cache"

    Hi there,

    On 07/09/2006, at 4:22 PM, Andrus Adamchik wrote:

    > On Sep 7, 2006, at 7:27 AM, Lachlan Deck wrote:
    >
    >> On 06/09/2006, at 5:46 PM, Andrus Adamchik wrote:
    >>
    >>> Custom values set on the server during commit are not passed back
    >>> to the client (except for the PK). It would be nice if they
    >>> where, so that's something we may consider doing in 3.0.
    >>
    >> Yes please.
    >>
    >> But we're not talking about commit are we? I was talking about
    >> init... what happens when creating a new object on the client? Do
    >> any initial values set on the server get propagated back?
    >
    > Yes, I am talking commit, since commit is the first time when a new
    > object created on the client is sent to the server. Until then it
    > sits on the client and server has no chance of participating in its
    > lifecycle.
    >
    > What happens on commit is this:
    >
    > * Client transfers the information about an object as a bunch of
    > "diffs".
    > * Server instantiates a server-side object from those diffs.
    > * Server commits its DataContext.

    Okay - that's good to know.

    After looking at the source for CayenneContext.newObject (and non-
    public CayenneContext.createNewObject) it seems to me that overriding
    setPersistentState (as suggested: http://cwiki.apache.org/confluence/
    display/CAY/Setting+Initial+Values) is a bad idea, esp for new
    objects. i.e., at the point of being NEW the object's ValueHolder
    vars have not yet been initiated, it doesn't yet have a handle on the
    context, it's global id has not been set, and it's not been
    registered with the graph manager etc. Simply put, bad stuff happens
    when messing with the objects ValueHolder vars prior to all of this.

    Last effort question is: does the following call within
    createNewObject(ObjectId) create some sort of event that might
    provide a hook-in point for when the object has been properly created
    and inserted into a context? "graphManager.nodeCreated
    (object.getObjectId());"

    If not - maybe I can put a vote in for a delegate method being added
    which is called just prior to the object return. ala
    awakeFromInsertion(ObjectContext) :-)

    with regards,

    --
    

    Lachlan Deck



    This archive was generated by hypermail 2.0.0 : Mon Sep 11 2006 - 22:08:26 EDT