• 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: Handling exceptions in saveChanges() (Was: "Cannot obtain globalId for an object which...")
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handling exceptions in saveChanges() (Was: "Cannot obtain globalId for an object which...")


  • Subject: Re: Handling exceptions in saveChanges() (Was: "Cannot obtain globalId for an object which...")
  • From: Jonathan Rochkind <email@hidden>
  • Date: Wed, 11 Jun 2003 11:32:17 -0500

At 04:46 PM 6/10/2003 -0700, Chuck Hill wrote:
This could be interesting. How can this be done in a multi-threaded or multi-instance application? I think that the database is the only place where unique constraints (e.g. a user ID) can be checked without risking race conditions. Optimistic locking failures can be avoided with pessimistic locking at the database - something to be avoided IMHO. They can also be avoided by a "last write wins" strategy of forcing the update or by not checking for failures at all. Neither of those seem like a good, general purpose solution.

Not a good general purpose solution, true, but in my own apps, I decided that a 'last write wins' strategy is actually just fine. And implementing it is easy as pie---simply turn off the lock icon for all attributes but for primary key attributes, and you'll never have to deal with optimistic locking failures again. [Well, mostly. There are some cases where something that could conceptually be considered an optimistic locking failure can still occur---like adding a many-to-many relation that was just created by some other instance, causing a 'duplicate pk insertion' error for the join object. But you're 90% off the hook].


Understandably, this isn't an acceptable strategy for a great many apps. But many developers don't even seem to consider it, they seem to assume that they need optimistic locking. It's worth considering. If a 'last write wins' strategy is acceptable for your app, you can save yourself a whole lot of trouble.

--Jonathan



Cheers,
Chuck

--

Chuck Hill                                 email@hidden
Global Village Consulting Inc.             http://www.global-village.net

Progress is the mother of all problems.
- G. K. Chesterton
_______________________________________________
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: 
 >Re: "Cannot obtain globalId for an object which..." (From: Alan Ward <email@hidden>)
 >Handling exceptions in saveChanges() (Was: "Cannot obtain globalId for an object which...") (From: Chuck Hill <email@hidden>)

  • Prev by Date: Instance fails to start using Monitor
  • Next by Date: Run project on PC and Mac
  • Previous by thread: Handling exceptions in saveChanges() (Was: "Cannot obtain globalId for an object which...")
  • Next by thread: Re: Handling exceptions in saveChanges() (Was: "Cannot obtain globalId for an object which...")
  • Index(es):
    • Date
    • Thread