• 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
Locking exceptions and more
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Locking exceptions and more


  • Subject: Locking exceptions and more
  • From: Merul Patel <email@hidden>
  • Date: Tue, 22 Jul 2003 10:05:42 +0100

Hi,

I'm new to Webobjects and am having some problems with implementing optimistic locking and editing objects within shared Editing contexts and wondered if anyone could help.

I'm playing around with some modifications to the message board example in Ravi Mendis' book, where all posts are fetched into a SharedEditingContext. The "message" content of each post is locked in EOModeller to ensure optimistic locking is used.

In order to edit a particular message, I've implemented a directAction where the message is localised using EOUtilities.localInstanceOfObject() into the session().defaultEditingContext() and then passed to an editing WOComponent by invoking takeValueForKey on the localised post:

Number postID = request().numericFormValueForKey("postID", new NSNumberFormatter());
EOSharedEditingContext SEC = EOSharedEditingContext.defaultSharedEditingContext();
EOEnterpriseObject _post = EOUtilities.objectWithPrimaryKeyValue(SEC, "Post", postID);
EOEnterpriseObject post = EOUtilities.localInstanceOfObject(session().defaultEditingContext(), _post);
nextPage.takeValueForKey(post, "post");



Changes to the post are submitted in a form, and the editing component invokes saveChanges() on the session().defaultEditingContext() to save changes. For debugging purposes I print the submitted post to System.out to ensure the amended values have been captured correctly:


        System.out.println("Post edit was " + post);
        session().defaultEditingContext().saveChanges();

The post displays correctly in the editing page, but sometimes the changes are not captured when I click on save?! Bizarrely, simply rebuilding the application and running it again fixes this problem, but then I end up running into locking exceptions as follows.

Once I've edited a post and saved changes, I return to a listing of messages which is fetched from the sharedEditingContext() using the message topicID. If I try to edit a previously edited message again,. then I get a "Application: com.webobjects.eoaccess.EOGeneralAdaptorException: lockRowComparingAttributes -- com.webobjects.jdbcadaptor.JDBCChannel: lock operation fetched row with different values than snapshot" error.

However I had presumed that, since the edited message was displayed correctly in the message listing, the sharedEditingContext() had been notified of the change to the relevant post and would invalidate and refault the post and it's snapshot.

What am I missing?

Thanks in advance,

Merul
_______________________________________________
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.

  • Follow-Ups:
    • Re: Locking exceptions and more
      • From: Art Isbell <email@hidden>
  • Prev by Date: Re: Deploying on UNIX (RedHat)
  • Next by Date: re:concurrency and sessions
  • Previous by thread: Re: Deploying on UNIX (RedHat)
  • Next by thread: Re: Locking exceptions and more
  • Index(es):
    • Date
    • Thread