Hi Lachlan,
On Sep 11, 2006, at 10:08 PM, Lachlan Deck wrote:
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.
Hmm... This information on Wiki was posted in pre-remote-object-
persistence days, referring to DataContext. Comparing the code with
the same method in DataContext, the order of initialization is
different between DataContext and CayenneContext. I'd say this is a
bug in Cayenne - let's log it in Jira.
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());"
no, but aside from my comment above, you can always subclass a context.
Andrus