[baseten-users] manual commit seems to not propagate changes of child objects to other client contexts
Michael Ruepp
michael at ruepp.at
Mon Mar 8 12:12:13 EET 2010
Hi there,
I have one table and within a one to many relationship parent and children.
I usually worked with autocommit which is perfectly working. Due to performance reasons, I tried to switch to manual commit, setting [context save:&error]; on various points in code.
I create objects like this on one client:
BXDatabaseObjectClass* parent = [context createObjectForEntity:tableEntity withFieldValues:[NSDictionary dictionaryWithObjectsAndKeys:parentname, @"name",nil] error:error];
BXDatabaseObjectClass* children1 = [context createObjectForEntity:tableEntity withFieldValues:[[NSDictionary dictionaryWithObjectsAndKeys:name1, @"name",nil] error:error];
BXDatabaseObjectClass* children2 = [context createObjectForEntity:tableEntity withFieldValues:[[NSDictionary dictionaryWithObjectsAndKeys:name2, @"name",nil] error:error];
...
[children1 setParent:parent];
[children2 setParent:parent]
...
Then:
[self contextSave];
Which looks like this:
-(void)contextSave {
NSError* error = nil;
if (!FRkautocommit) {
return;
}
BOOL success = [(BXDatabaseContext*)context save:&error];
ALog(@"The Context was Saved: %d",success);
}
On client2 I fetch the parent like this:
NSString *predString = [NSString stringWithFormat:@"%@ == %%@", @"name"];
NSPredicate *predItem = [NSPredicate predicateWithFormat:predString, @"parentname"];
id arrayItem = [context executeFetchForEntity:tableEntity withPredicate:predItem returningFaults:YES error:nil];
BXDatabaseObjectCustomClass* parent = [arrayItem objectAtIndex:0];
Now I want to see all the related items (children)
return [[[parent children] valueForKey:@"name"] allObjects];
The Array of the fetched relationship objects shows empty. It always shows just the values of the Items created on the same client as the fetch runs.
Eg. When I create children1 on client1 and children2 on client2 (of the same parent object) and want to see the children of the parent (which should give me a NSSet with children1 AND children2), I get a Set with children1 on client one, and a set with children2 on client2 but not both - but the rows are actually existing in the table.
I assume this is a bug.
Thanks for reply
Mike
_________________
michael ruepp
michael at ruepp.at
fon +41 76 593 04 49
skype michaelruepp
CONFIDENTIALITY NOTICE
This message (including any attachments transmitted with it) contains confidential information and is intended only for the individual named herein. If you are not the herein named addressee you should not disseminate, distribute, copy or otherwise make use of this message. Please notify the sender immediately by e-mail if you have received this message by mistake, and delete it from your systems.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basetenframework.org/pipermail/baseten-users/attachments/20100308/30c5b1c8/attachment.htm>
More information about the baseten-users
mailing list