Validation Errors During Master Data Migration

I am encountering a very annoying error using Core Data on Mac OS X 10.5.

All objects have classes in my application that have the same names.

Up to this point I have done 5 migrations with no problem.

I am using XML data store. I have a V5 of my data model with 13 objects, 4 of which are abstract. It looks like this: alt text http://synapticmishap.co.uk/ObjectModel.jpg

What am I doing

  • Create a new version of my data model - this is V6.

  • Add a new object (JGToolbarWindow) and set the parent to JGWindowBase.

  • Added a display model that goes from V5 to V6. Saved.

  • Install the current version as V6.

  • Build and Debug.

I have automatic migration enabled in the persistent storage coordinator parameter dictionary.

Problem

  • Get the error message "Multiple validation errors occurred."

  • I set a breakpoint and looked at validation errors. There's a long list of validation errors - there seems to be one for each data entry.

  • It seems to delete ALL relationships and with one of my properties - application - set to required, this counts as a validation error.

  • So the problem is that migration cannot migrate relationships ... although apparently nothing has changed as the relationships go.

  • When I look in ~ / Library / Application Support / My Application Name / I see an XML Data Store with the same name appended .xml.new When looking at this file in a text editor, all relationships were indeed stripped.

What i tried

  • Create a new XML data store and put some items in it, then try again. I am getting the same errors for every item.

  • Cleaning and restoration.

  • Make sure the old .xml.new from the previous check has been removed.

  • Deleting the new version of the model and repeating my steps to make sure I am not at fault.

  • Add display entries for each of the abstract classes, which are ignored by default. Added all attributes and relationships. Still the exact same error.

  • Tried adding a new entity that doesn't have a class based only on NSManagedObject which JGWindowBase is like parent. Once again, failed.

The only thing I can think of that has changed is some of my internal logic in the classes underlying the model. But these are minor changes and I can't figure out how it carries over normally, and now it's not when nothing has changed.

I have tried a new migration from the renamed last datastore and have the same problems. This means that I have to solve this problem in order to transfer any data.

Errors

When I put a breakpoint on the current line the workaround is below

if (![persistentStoreCoordinator addPersistentStoreWithType:NSXMLStoreType
                                                  configuration:nil 
                                                            URL:url 
                                                        options:options 
                                                          error:&error]){
          [[NSApplication sharedApplication] presentError:error];
}

      

and consider the userInfo error, I am getting many errors like this:

Error Domain=NSCocoaErrorDomain Code=1570 UserInfo=0x67ebfd0 "item is a required value."

      

po (NSArray *)0x67ebfd0

gives:

NSLocalizedDescription = "item is a required value.";
NSValidationErrorKey = item;
NSValidationErrorObject = <NSManagedObject: 0x45d5830> (entity: JGLogEntry; id: 0x4baccb0 <x-coredata://B597E13E-BE74-402E-BF00-5E1D57898406/JGLogEntry/p13942> ; data: {
duration = nil;
item = nil;                   // <<< Here the problem.
processBundleID = nil;
processID = nil;
processName = nil;
startTime = 2009-10-09 16:41:44 +0100;
stopTime = 2009-10-09 16:42:17 +0100;
windowDocumentPathOrURL = nil;
windowID = nil;
windowTitle = nil;

      

All of this is really telling me that it removed the relationship associated with the element that is a required property, so it tells me that there are validation errors. There is also a full load for the application, which is another required property.

As I see it, the problem is not validation errors per se, but rather that it does not carry over any relationship at all .

I pull my hair with this. I am really very grateful for the help. And finally, a quote from Star Wars:

"Help me, stack overflow. You are my only hope."

+2


source to share


1 answer


Upgrading to Snow Leopard

Snow Leopard seems to solve this problem - I haven't had any data migration issues since the upgrade.



Alternatively, I suppose it might disappear because I switched to SQLite datastore, although I think it is more likely that migrations with abstract objects are slightly broken on Leopard.

0


source







All Articles