[rules-dev] persistence and optimistic locking
Some Guy
youknowwho at heroicefforts.net
Thu Nov 12 23:06:56 EST 2009
All that should be required is to define a version or timestamp
property for the entity in question. Hbn will constrain against that
field when it performs the update. If the db returns 0 updated rows,
then Hbn will throw the stale exception.
I recall there's a way to pessimistically lock using db locks (select
for update, etc.), but I assume that's only valid for the duration of
your transaction. I never had call to use it.
If you use timestamps, make sure your db columns have millisecond
resolution.
On Nov 12, 2009, at 10:18 PM, Mark Proctor <mproctor at codehaus.org>
wrote:
> Michael Neale wrote:
>>
>> I am not aware of peasimistic locking use being very common. When
>> people want it, it's generally cause the GUI suggests it (eg bob
>> wants
>> to view a file, but Alice has it locked)
>>
>>
> With optimistic locking we can just submit our update and it fails
> if something else updted the recorded in the mean time - doing a
> counter comparison. With pessemistic we have to download the record
> first, compare them, and then upload. As what we are comparing in a
> binary blob, we want to avoid pulling that from the db.
>
> Mark
>> Sent from my phone.
>>
>> On 13/11/2009, at 10:27 AM, Salaboy <salaboy at gmail.com> wrote:
>>
>>
>>> I suppose that the versión field its being used. So, the default
>>> must
>>> be optimistic
>>>
>>> - Ing. Mauricio Salatino -
>>>
>>> On Nov 12, 2009, at 9:43 PM, Michael Neale <michael.neale at gmail.com>
>>> wrote:
>>>
>>>
>>>> I thought optimistic locking was the default ? Or do you mean you
>>>> know
>>>> how to switch, just that it doesn't work?
>>>>
>>>>
>>>> Sent from my phone.
>>>>
>>>> On 13/11/2009, at 8:16 AM, Salaboy <salaboy at gmail.com> wrote:
>>>>
>>>>
>>>>> I Will take a look on that
>>>>> Sent from my iPhone
>>>>>
>>>>> On Nov 12, 2009, at 7:33 PM, Mark Proctor <mproctor at codehaus.org>
>>>>> wrote:
>>>>>
>>>>>
>>>>>> Any hibernate guru's out there? Currently the persistence stuff
>>>>>> uses
>>>>>> pessematic locking, which is slow, in theory we should be using
>>>>>> optimistic locking, but I couldn't get it to work. Anyone want to
>>>>>> give
>>>>>> that a go?
>>>>>>
>>>>>> Mark
>>>>>>
>>>>>> _______________________________________________
>>>>>> rules-dev mailing list
>>>>>> rules-dev at lists.jboss.org
>>>>>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>>>>>
>>>>> _______________________________________________
>>>>> rules-dev mailing list
>>>>> rules-dev at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>>>>
>>>> _______________________________________________
>>>> rules-dev mailing list
>>>> rules-dev at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>>>
>>> _______________________________________________
>>> rules-dev mailing list
>>> rules-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>>
>> _______________________________________________
>> rules-dev mailing list
>> rules-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>
>
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20091112/9ba40aaa/attachment-0001.html
More information about the rules-dev
mailing list