On 02/12/2004, at 02:40, Mike Kienenberger wrote:
>> Sounds intriguing, I will have a look at home if this is not way over
>> my head. I do remember however that pessimistic locking is database
>> dependant, I presume this is detectable/done through the JDBC?
>> Of course I can't do any of this at work, and at home - not after
>> Xmas... hopefully by then I'll have Internet access form outside of
>> work.
>
> Did EOF handle pessimistic locking using EOEditingContext.lock() and
> unlock()?
>
> If so, there isn't anything equivalent in Cayenne. That's actually
> of the
> things I like BEST about Cayenne, as I had to implement tons of
> workarounds
> to defective lock() behavior in EOF WO5.0.
>
> On the other hand, the methods lock() and unlock() in the DataContext
> are
> unused, and, to me, it'd seem very reasonable to implement them to
> provide
> pessimistic locking. Every time lock() was called, you'd go through
> the
> context objects, and if they were marked for pessimistic locking, you'd
> generate the appropriate call, and vice-versa. What would be unclear
> is
> how to handle the case of the program crashing while the lock was held
> open,
> but maybe this can be done with the commit/rollback mechanism
> (unfortunately, I'm now into pure speculation as I don't know the
> limitations of transaction usage).
>
>
> -Mike
Pessimistic locking in WebObjects is a little bit hidden, it's in the
EODatabaseContext, look:
http://developer.apple.com/documentation/WebObjects/Reference/API/com/
webobjects/eoaccess/EODatabaseContext.html#setUpdateStrategy(int)
From the EODatabaseContext's JavaDocs:
<<<
setUpdateStrategy
public void setUpdateStrategy(int strategy)
Sets the update strategy used by the receiver to strategy, which
must be one of the following constants:
* UpdateWithOptimisticLocking
* UpdateWithPessimisticLocking
* UpdateWithNoLocking
Throws an exception if the receiver has any transactions in
progress, or if you try to set strategy to UpdateWithPessimisticLocking
and the receiver's EODatabase already has snapshots.
Parameters:
strategy - The update strategy used by the receiver.
Throws:
IllegalArgumentException - if strategy is
UpdateWithPessimisticLocking and the receiver's EODatabase contains
snapshots.
See Also:
updateStrategy()"
>>>
I have never personally tried it myself and I remember having quite a
bit of trouble finding any references and no examples to pessimistic
locking in WO.
Marek Wawrzyczny
software engineer
-------------------------->
ish group pty ltd
http://www.ish.com.au
7 Darghan St Glebe 2037 Australia
phone +61 2 9660 1400 fax +61 2 9660 7400
This archive was generated by hypermail 2.0.0 : Wed Dec 01 2004 - 17:55:31 EST