Re: EOF Design Questions

Francis Labrie <[email protected]> Thu, 8 Apr 2004 11:58:35 -0400
Newsgroups gmane.comp.web.webobjects.eof
Message-ID <[email protected]>
Hi Ashley,


Ashley Aitken wrote:
>> 	[...]
>
> That's a clear and straight-forward way of doing it.
>
> I was hoping, however, that there maybe a more efficient way of doing 
> it (that may need to be provided by the frameworks using underlying 
> data structures).


You can perform cloning by using the entity snapshot to update the 
clone instead of looping through all property keys.  But this will 
clone the primary key: you'll then need to add code assign a new unique 
primary key.


>>> 2.  How best to revert some EOs (but not all) in the EC?
>>> Using the original snapshot ... but could that change (is that a 
>>> problem)?
>>
>> You can use the editing context revert() method.  Setting up the 
>> original snapshot shouldn't be a problem though.
>
> Ok, but that will revert all objects in the editing context.
>
> I want to revert only those objects that have been changed (and thus 
> cloned).
>
> For example, I don't want to revert the cloned objects.


Then you individually revert change using snapshots, or you can migrate 
all the clones to another editing context using one of these method:

	EOUtilities.localInstanceOfObject(EOEditingContext, EOEnterpriseObject)

	EOUtilities.localInstancesOfObjects(EOEditingContext, NSArray)


Kind regards,