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

Optimistic locking madness


  • Subject: Optimistic locking madness
  • From: Miguel Arroz <email@hidden>
  • Date: Fri, 1 Jun 2007 16:08:47 +0100

Hi!

I'm having some problems related to refaulting objects due to optimistic locking failures.

I have this situation where I update two objects, and some fields of those objects are "optimistic locking enabled". I know that if I get a failure, when saving, related to one object, the other will probably generate a new exception as well, so I refault both.

  Basically, I have this:

        int tries = 0;

	SomeClass object1;
	OtherClass object2;

        while( tries < MAX_TRIES ) {
            updateObject1( object1 );
	    updateObject2( object2 );

try {
Util.sleep(5); // Testing this thing
editingContext.saveChanges();
return true;
} catch (EOGeneralAdaptorException saveException) {
NSLog.out.appendln("Optimistic locking failure");
++tries;
if( Util.isOptimisticLockingFailure(saveException) ) {
EOEnterpriseObject object = Util.handleOptimisticLockingFailureByRefaulting( saveException, respondent.editingContext() );
if( object == object1 || object == object2) {
editingContext.refaultObject( object1 );
editingContext.refaultObject( object2 );
} else {
throw new RuntimeException("An unexpected object caused an optimistic locking failure.");
}
} else {
throw saveException;
}
}
}


        return false;

The problem is that only object1 is refaulted! I was consulting the PSQL log, and there is a SELECT statement to get object1 back from the DB, but nothing happens related to object2. And naturally, when I try to save again, I will get a new exception, over and over, because object2 is not being refaulted.

I don't know it that helps, but object1 has a to-one relationship to object2.

Any idea of what might be causing this? What does EXACTLY refaultObject do?

  Yours

Miguel Arroz

Miguel Arroz
http://www.terminalapp.net
http://www.ipragma.com



_______________________________________________
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


  • Follow-Ups:
    • [SOLVED] Optimistic locking madness
      • From: Miguel Arroz <email@hidden>
  • Prev by Date: Re: [HOWTO] Profiling WO apps with Netbeans
  • Next by Date: [SOLVED] Optimistic locking madness
  • Previous by thread: Re: Xcode runtime WOComponent editing bug (rapid turnaround)
  • Next by thread: [SOLVED] Optimistic locking madness
  • Index(es):
    • Date
    • Thread