On Feb 16, 2010, at 5:31 PM, David LeBer wrote:

> It definitely doesn't work trying to pull an EO in a child ec into it's 
> parent's. i.e:
> 
>       EOEditingContext rootEc = ERXEC.newEditingContext();
>       EOEditingContext childEc = ERXEC.newEditingContext(rootEc);
>       Movie m = Movie.createMovie(rootEc, "Test", null);
>       Studio s = Studio.createStudio(childEc, new BigDecimal(100.00), "Test");
>       Studio localS = s.localInstanceIn(m.editingContext());
> 
> BOOM: "You attempted to localInstance 
> <org.wocommunity.movies.model.server.Studio pk:"null">, which has not yet 
> committed."
> 
> I thought I'd gotten a similar message when I tried the other way around, but 
> I probably got distracted and... OOH! SHINY!... 

As helpful as Anjo's comment was, I'm going to try to add to it (crazy, I know).

In this example, why not just call childEc.saveChanges() after creating the 
Studio? That won't actually save it to the DB/ObjectStore, just to the rootEc. 
Then you can easily just do m.setStudio(s), and I don't think you even need to 
do the localInstance, do you? (It's been a while since I did nested ECs)

Dave _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to