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

[SOLVED] Optimistic locking madness


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

Hi!

OK, my problem was not related to optimistic locking, but to data freshness. EO was getting the data from the cached raw data (I think) and not from the DB. Using the context.setFetchTimestamp ( System.currentTimeInMillis() ) did the trick.

  Yours

Miguel Arroz

On 2007/06/01, at 16:08, Miguel Arroz wrote:

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:
40guiamac.com


This email sent to email@hidden

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


References: 
 >Optimistic locking madness (From: Miguel Arroz <email@hidden>)

  • Prev by Date: Optimistic locking madness
  • Next by Date: Re: D2W and Direct Actions
  • Previous by thread: Optimistic locking madness
  • Next by thread: Re: Xcode runtime WOComponent editing bug
  • Index(es):
    • Date
    • Thread