struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hubert Rabago <hrab...@gmail.com>
Subject Re: Record locking
Date Tue, 01 Nov 2005 22:05:32 GMT
For web applications, I tend to think that the more appropriate
approach is (what I know to be called) optimistic locking.  When a
user edits a record, I keep track of the update timestamp (or even
better, an update sequence number) of the record selected.  This value
gets sent back when the user attempts to save the changes.  Before
persisting the changes to the DB, I check if the timestamp (or seqnbr)
still matches the one on the DB.  If so, then no one else has modified
the data and the update can proceed.  If not, then it's up to you -
you can show the user the new record values and the changes that s/he
made, or ask that the user re-enter changes, etc.

In your example, User B will be shown an error message saying the
record has changed since he began and can start over or go ahead and
proceed with his changes anyway.

Hubert

On 11/1/05, Murray Collingwood <murray@focus-computing.com.au> wrote:
> Hi all
>
> As long as I have been on this list I have never heard anybody discuss record locking.
> The scenario is very simple:
>
> 1. User A clicks an "edit" option to edit a record.
> 2. While user A is editing the record user B clicks the same "edit" option
> 3. Both users are now editing the same record (or so they think)
> 4. User A clicks "save" and the record is updated and displays the changes made by
> user A - user A is happy
> 5. User B clicks "save" and these changes overwirte the changes made by user A,
> however user B doesn't know this and the changes made by user B appear.
>
> Sometime later user A realises that the changes made have disappeared and gets
> angry and begins throwing large objects around the room and making lots of loudish
> gutteral noises in an attempt to disperse inner emotional anxiety.
>
> Well, you get the picture.
>
> Q. Does Struts assume that the developer will code in the appropriate record locks in
> the database?
>
> Q. Does anybody actually do this?
>
> Q. How?  What type of record locking do you use?
>
> TIA
> mc
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message