Well, these are all peer contexts and rely heavily on the old behavior of the prototype values being copied over ...
On Tue, Apr 11, 2017 at 2:49 PM, Andrus Adamchik <and...@objectstyle.org> wrote: > > Anyone know why making a local object copy of a NEW object will set the > > copy to HOLLOW which will try to trigger faults later? > > This is a valid situation in case of nested contexts. If you use > 'localObject' on an object from a parent context, copying it to a child > context, it will resolve from HOLLOW by checking the parent. > > Andrus > > > > On Apr 10, 2017, at 7:38 AM, Michael Gentry <blackn...@gmail.com> wrote: > > > > I'm converting an application from 3.0 to 3.1 and was fixing all the > > localObject() calls to be the simpler version introduced in 3.1. One > thing > > I encountered was a utility method: > > > > public static <T extends CayenneDataObject> T copyToContext(T > > cayenneObject, DataContext dataContext) > > { > > T copiedObject = > > dataContext.localObject(cayenneObject.getObjectId(), cayenneObject); > > > > // The returned copy is HOLLOW, make the copy NEW if the original > > is NEW. > > if (cayenneObject.getPersistenceState() == PersistenceState.NEW) > > copiedObject.setPersistenceState(PersistenceState.NEW); > > > > return copiedObject; > > } > > > > I tried removing this utility method and just use the new localObject(), > > but exceptions (such as FaultFailureException) started being thrown. (I > > won't even try to explain why so many local object copies of > non-persisted > > objects are being used.) > > > > Anyone know why making a local object copy of a NEW object will set the > > copy to HOLLOW which will try to trigger faults later? > > > > Thanks, > > > > mrg > >