The approach you describe is known as optimisitic locking. 

The alternative approach is pessimistic locking, where you mark the records
to be updated as locked at the time you get the records from the datasource.
No other process will be allowed to lock the records at the same time - so
no two users can update the same record at the same time.

One problem with using pessimistic locking is how to deal with a user who
locks a record, but never releases it. In a web based application this is
very likely to happen - it's difficult to stop a user just killing their
browser. 

Optimisitic locking is generally easier to implement & less dependant on the
datasources involved. So, unless you have a problem which can't be solved
this way I'd go with optimistic locking.

Paul

> -----Original Message-----
> From: Bjørn T Johansen [mailto:[EMAIL PROTECTED]
> Sent: 24 November 2004 11:03
> To: 'Struts Users Mailing List'
> Subject: Best practice updating data in webapps?
> 
> 
> When designing webapps where different users can edit the 
> same record at the same time, 
> what is the best way to solve this situation?
> One way is to use an update field, that gets selected with 
> rest of the data and when 
> updating the data, check this update field with the one in 
> the db; if they don't match, 
> someone else has updated the record before you..
> But is this the best way?
> 
> 
> Regards,
> 
> BTJ
> 
> -- 
> --------------------------------------------------------------
> ---------------------------------
> Bjørn T Johansen
> 
> [EMAIL PROTECTED]
> --------------------------------------------------------------
> ---------------------------------
> Someone wrote:
> "I understand that if you play a Windows CD backwards you 
> hear strange Satanic messages"
> To which someone replied:
> "It's even worse than that; play it forwards and it installs Windows"
> --------------------------------------------------------------
> ---------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

Axios Email Confidentiality Footer
Privileged/Confidential Information may be contained in this message. If you 
are not the addressee indicated in this message (or responsible for delivery of 
the message to such person), you may not copy or deliver this message to 
anyone. In such case, you should destroy this message, and notify us 
immediately. If you or your employer does not consent to Internet email 
messages of this kind, please advise us immediately. Opinions, conclusions and 
other information expressed in this message are not given or endorsed by my 
Company or employer unless otherwise indicated by an authorised representative 
independent of this message.
 
WARNING:
While Axios Systems Ltd takes steps to prevent computer viruses from being 
transmitted via electronic mail attachments we cannot guarantee that 
attachments do not contain computer virus code.  You are therefore strongly 
advised to undertake anti virus checks prior to accessing the attachment to 
this electronic mail.  Axios Systems Ltd grants no warranties regarding 
performance use or quality of any attachment and undertakes no liability for 
loss or damage howsoever caused.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to