Re: locking with more coordinators causes an exception?
Re: locking with more coordinators causes an exception?
- Subject: Re: locking with more coordinators causes an exception?
- From: Chuck Hill <email@hidden>
- Date: Fri, 23 Jan 2015 23:30:26 +0000
- Thread-topic: locking with more coordinators causes an exception?
Hi,
On 2015-01-23, 3:20 PM, "OC" wrote:
Chuck,
Short answer: no, you should not be locking the object. I’ve never seen anyone take out a database lock like this.
OK, I'll try, thanks!
===
EOEditingContext ec=auction.editingContext()
EOObjectStore osc=ec.rootObjectStore()
osc.lock()
Why are you locking this? Nothing in the code below needs it.
Ah, that Miguel, always worrying! :-) OK, I see what you are after. IIRC, you can also handle this by catching notifications. That discussion was a long time ago, I forget the particulars and don’t have time to re-read all of it now.
Chuck
try {
EOEditingContext tempec=ERXEC.newEditingContext()
tempec.fetchTimestamp=System.currentTimeMillis()
def tempau=auction.localInstanceIn(tempec)
tempec.lockObject(tempau) // *
Don’t do this. It is not needed. Well, for most people. With you I am not so sure… :-P
Anyway I'll try :)
... yadda yadda yadda ...
tempec.saveChanges();
} catch (exc) {
PRINT_ERROR(exc,"Exception adding price offer FOR prc $poValue CU $sess.currentUser.login")
...
} finally {
osc.unlock()
}
===
Is the // * lock wrong? I've thought if two threads try to work with the same auction, the latter one would wait in the lock until the former saves.
The normal way to handle this is just to save and detail with any optimistic locking conflicts that happen.
Thanks a lot,
OC
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Help/Unsubscribe/Update your Subscription:
|
_______________________________________________
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