Re: What does core data do during a Save As?
Re: What does core data do during a Save As?
- Subject: Re: What does core data do during a Save As?
- From: Quincey Morris <email@hidden>
- Date: Fri, 1 Oct 2010 10:44:19 -0700
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 (email@hidden)
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:
This email sent to email@hidden