• 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: Optimistic Lock
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Optimistic Lock


  • Subject: Re: Optimistic Lock
  • From: Kieran Kelleher <email@hidden>
  • Date: Mon, 23 May 2005 09:31:25 -0400

Here is the easiest way to trigger it.

1) Pull an object into an edit page in WO.

2) Now go in the back door to the database using command line or some other tool independent of WebObjects and directly edit some attributes (that have the little lock ON in EOModel) of the databases record that represents the object.

3) Now submit your object editing page

4) An optimistic locking exception will now get thrown because the original snapshot that was read in from the database before you edited the object is different to the values in the database now.

Let's say we have a table with a primary key 'oid' and one optimistically locked attribute named 'field1'.
Now we fetch the object with primary key 273 and its DB value is "original".


Now let's say you change the field1 to be "new" in WO in a form and BEFORE you submit, let's say you changed the DB field1 value directly to "changed", then when you submit, EOF generates SQL something like:
UPDATE table T1 set field1 = "new" where oid = 273 and field1 = "original";


.... and this update will FAIL because there is NO record having oid = 273 and field1 = "original". There IS a record with oid = 273 and field1 = "changed", but WO does not know that because some other application has changed it.

If you log out the SQL while changing you will see that optimistic locking effects the WHERE part of all the UPDATE statements that are generated.

-Kieran
________________________________________________________________
Blog: http://webobjects.webhop.org/


On May 23, 2005, at 8:54 AM, Dmitri wrote:

I've read all info at this links already :) the problem is i just cant get this locking to happen, so i see that my things i wrote in catch all work.

Let me explain you how i think locking must work and u say if i m wrong.

User1 gets bject to edit. And than he goes to eat for 1 hour. Session timeout is 8 hours. In 30min User2 takes object. Edit em. And sayving it. After User1 gets back he chages some fields(which was locked) and press save. Than EOF must actually say "Hopla, object hav been changed already, and get him new Values for fields(i programmed it this way).

So in this case i used Otimistic Lock with Recovering and Refaulting. Do i understand this right?

Dmitri


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Prev by Date: Re: Packaging webobjects apps and frameworks
  • Next by Date: Re: Arabic input via WebObjects?
  • Previous by thread: Re: Optimistic Locking Example
  • Next by thread: Active Directory
  • Index(es):
    • Date
    • Thread