Two questions about CoreData migration
Two questions about CoreData migration
- Subject: Two questions about CoreData migration
- From: Timothy Larkin <email@hidden>
- Date: Fri, 22 Aug 2008 15:14:39 -0400
The first question is a simple one. After migration, the old
persistent store is renamed sourceURL~.xml, and the document is
supposed to open with a new persistent store with the old url,
sourceURL.xml,. However, the document window that appears after
migration has the title sourceURL~.xml, and saving this replaces the
original, unmigrated document. Why doesn't the document open with
sourceURL? I have examined the document at various stages during the
open document process, and it consistently reports the URL without the
tilde. And that is how the window initially appears. However, it
switches to the form with the tilde as soon as the window is activated.
The second question is a bit more complicated. I have two entities
with a one-to-many parent-child relationship. Say the parent is an
entity named Parent. This is an abstract class; only Parent subclasses
are instantiated. In the data model, the destination of the child to
parent relationship is the abstract Parent class.
When I create a mapping model, there is no entity mapping for the
Parent class automatically, I suppose because it is abstract. I can't
compile the mapping model if there is no property mapping for the
child to parent relationship. So I create an entity mapping for the
abstract class Parent, and make a property mapping for the
relationship using this mapping.
But when the model is migrated, the Parent mapping is never used, I
suppose because there are no Parent entities. So that
destinationInstancesForEntityMappingNamed:@"Parent" is empty for any
child instance when the relations are being recreated. But it gets
even stranger. I created a new migration policy class, MyPolicy, and
assigned it as the custom policy for the child entity mapping. This
class overrides only createRelationshipsForDestinationInstance. When
this is called for a child instance, the child initially has a parent;
but after executing super's createRelationshipsForDestinationInstance,
the parent relationship is gone, which is consistent with there being
no destination instances.
So what I've done is to save the parent, call the super method, and
then restore the parent. This fixes the problem, but seems rather
desperate. What is the correct method for dealing with a property
mapping that involves an abstract class?
--
Timothy Larkin
Abstract Tools
Caroline, NY
Attachment:
PGP.sig
Description: This is a digitally signed message part
_______________________________________________
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