Re: localObject()

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sun Feb 26 2006 - 03:18:17 EST

  • Next message: Todd O'Bryan: "Generics"

    Pre-M11-compatible behavior would be to pass null as a second
    parameter (i.e. *mapping* an object from one context to another
    context).

    Second parameter is normally used when you also need to *synchronize*
    the state with a "prototype" object. This is used in Cayenne
    internally to pass the state of the modified and new objects between
    parent and child contexts that I am working on.

    In case you pass a non-null second parameter, you are responsible for
    setting correct persistence state of the local object, as generally
    there is no way for Cayenne to tell the right resulting local object
    state.

    Andrus

    On Feb 26, 2006, at 6:15 AM, Todd O'Bryan wrote:

    > Can someone explain the second parameter of the new localObject()
    > method? If I'm trying to get a committed object into the local
    > DataContext, can the second parameter always be null, or should I
    > have it be the object I'm bringing in.
    >
    > In short, do I have to do
    >
    > DataContext dc;
    > ...
    > MyObject myObj = (MyObject) dc.localObject
    > (myObjInOtherContext.getObjectId(), myObjInOtherContext)
    >
    > all over the place, or is the ObjectId sufficient without the extra
    > parameter?
    >
    > Thanks,
    > Todd
    >



    This archive was generated by hypermail 2.0.0 : Sun Feb 26 2006 - 03:18:28 EST