Handling simultaneous (concurrent) updates
If two users are updating the same record at the same time a conflict will occur. There are normally three different ways to handle this conflict. The first method is to let the last update win so no controlling mechanism is needed. The second one is to use a pessimistic lock, in which case, before updating a record, a user will first lock the record and then process and update the record. At the same time all other users will have to wait for the lock to be released in order to start the updating process.
The third and most common mechanism in an enterprise product is the optimistic locking. A user doesn't lock a record for update when the data is retrieved but when the application is ready to commit the changes it will first check to see if any other user has updated the same record since that data was retrieved. If nobody else has changed the same record the update will be committed. If any other user has changed the same record the update will...