Re: Help inserting many-to-many (more info)

Sarwat Khan <[email protected]>
Newsgroups gmane.comp.web.webobjects.eof
Message-ID <[email protected]>
I rearranged the code a bit to see the results. I saved changes to the 
story and then tried adding the relationship to the categories,

//get the ec, insert story (EOGeneric) into it, save changes
EOEditingContext	ec = session().defaultEditingContext();
ec.insertObject(story);
story.takeValueForKey(((Session)session()).getUserId(), "userId");
story.takeValueForKey(new NSTimestamp(), "datePosted");
ec.saveChanges();

ec.invalidateObjectsWithGlobalIDs(new 
NSArray(ec.globalIDForObject(story)));

//for each category, add the story to both sides of the relationship
Enumeration		ite = selectedCategories.objectEnumerator();
while (ite.hasMoreElements())
{
	Category cat = (Category)ite.nextElement();
	cat.addObjectToBothSidesOfRelationshipWithKey(story, "stories");
}
ec.saveChanges();

This gives me a different-yet-still-baffling exception at the second 
saveChanges(), I'm hoping some will be able to shed some light on this 
:P Or can anyone share a snippet of a many-to-many snippet that works?

java.lang.NullPointerException
<snip>.EODatabaseContext._verifyNoChangesToReadonlyEntity
<snip>.EODatabaseContext.performChanges
<snip>.EOObjectStoreCoordinator.saveChangesInEditingContext
<snip>.EOEditingContext.saveChanges
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.