Aargh!!! That is just so totally broken, if it can't handle a scenario like 
that. 

I'm not sure that this is my problem though. I do have a parent/child 
relationship, and I am seeing the problem on a number of relationships on the 
parent entity and one relationship on the child entity, but also on one 
relationship that involves two entities that do not have any parents/children. 

The only thing in common is that all the broken relationships are one to one 
and have an inverse, and as far as I can see, the validation failures are 
happening for *every* two way one-to-one relationship in my model. One way 
to-one relationships are OK. To-many relationships are OK. Just about all the 
relationships that are now having problems used to be one way, and I used to be 
able to Save As before (I wish there was a way to do a diff on models so I 
could easily see what had changed in the various checkins).

Removing Save As really isn't an option. This is a document based application, 
and needs to have the basic document handling functions like save as. Reworking 
the model to not have parent entities would make things pretty messy, but given 
the investment I have already made in trying to tame Core Data, if I need to do 
that, I guess I could give it a go.

The next thing I'm dreading with Core Data is trying to get autosave to work. I 
got some tips from Ben Trumbull, but it looks like a scary amount of work that 
I don't fully understand...but that's for another day...

If there are any further suggestions as to how to debug this, I'm all ears.

Regards

Gideon

On 02/10/2010, at 3:44 AM, Quincey Morris wrote:

> On Oct 1, 2010, at 09:03, Gideon King wrote:
> 
>> Hi, I'm still trying to sort out what is happening to my to-one 
>> relationships during a Save As operation (see Core data: Inverse 
>> relationships with subclasses thread for context if necessary, but this 
>> really is a standalone thread now) - it turns out that the 
>> subclasses/subentities questions were a bit of a red herring and it applies 
>> to all to-one relationships with inverse relationships. I have narrowed it 
>> down to the following:
>> 
>> 1. Prior to saving I manually go through all the registered objects and make 
>> sure they pass the validateForInsert and validateForUpdate checks. This 
>> confirms that everything is OK before saving.
>> 2. The Save As operation creates a new atomic store, and loads from an empty 
>> temporary file.
>> 3. It then does a migration to the new atomic store. I really don't 
>> understand this process, but somewhere along the way, it calls 
>> awakeFromFetch on all my existing managed objects (even though as far as I 
>> can tell, no fetches have been done, and certainly no new atomic store cache 
>> nodes have been created).
>> 4. It then validates my managed objects, and this time the insert validation 
>> checks fail for all my to-one relationships that have inverse relationships.
> 
> Well, I'm not sure I understand all the factors in your scenario, but it's 
> known that Core Data implements Save As as a migration process using a 
> mapping model that it constructs on the fly, and that this fails for models 
> that have parent entities -- specifically when the parent entities contain 
> relationships. It sounds a bit like this is what's happening to you.
> 
> The last time I tried doing this was under Leopard, and in the end I gave up 
> trying to get Save As to work reliably. Whether the situation is improved in 
> Snow Leopard, I don't know. Whether there's a general solution or workaround, 
> I don't know.
> 
> Here are some alternatives you might like to consider:
> 
> 1. Take the "Save As" item off your "File" menu. (Seriously.)
> 
> 2. Re-work your data model to not use parent entities. To get the kind of 
> object graph you want, you may still need to use an auxiliary entity to 
> represent the relationships, but just not a parent entity.
> 
> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to