• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: locking editing context when removing item
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: locking editing context when removing item


  • Subject: Re: locking editing context when removing item
  • From: Jonathan Rochkind <email@hidden>
  • Date: Mon, 16 Feb 2004 10:44:45 -0600

Yes, I think it would definitely be a good idea to lock the EC before calling deleteObject on it. In general, you should ensure an EC is locked before just about anything at all with it; an EC should pretty much always be locked before dealing with it.

Note that if 'ecTb' in the first block of code is not the same EC as 'ec' in the second block----then unless there's other code you're not showing us, this isn't going to do anything. Calling ecTb.deleteObject() just tells ecTb to register an EO as 'deleted'. ecTb now tracks that EO as deleted, fine. But unless you call saveChanges() on ecTb, nothing is going to happen. Once you call saveChanges on ecTb, the change is either committed to the db, or again registered with a parent EC if ecTb is a nested EC.

Hope this helps,
--Jonathan

At 2:39 PM +0000 2/16/04, Jonathan Fleming wrote:
Just checking really... do I need to put a lock on the ec when removing an item from its own ec? So would this code be wrong or cause problems?:


// the default ec is instatiated somewhere else earlier in the code EOEditingContext ec = session().defaultEditingContext(); ....................

// remove tbAddressAdminUser from queryResults
queryResults.removeObject(tbAddressAdminUser);
// get objects editing context
EOEditingContext ecTb = tbAddressAdminUser.editingContext();
// remove tbAddressAdminUser from object graph
ecTb.deleteObject(tbAddressAdminUser);
// save changes made in editing context to object store


....................
       // the save is done later with the default ec
                       ec.saveChanges();

Advanced Thanks
Jonathan :^)

_________________________________________________________________
Stay in touch with absent friends - get MSN Messenger http://www.msn.co.uk/messenger
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >locking editing context when removing item (From: "Jonathan Fleming" <email@hidden>)

  • Prev by Date: Personalizing Error Page
  • Next by Date: Re: Personalizing Error Page
  • Previous by thread: locking editing context when removing item
  • Next by thread: Re: locking editing context when removing item
  • Index(es):
    • Date
    • Thread