Java Reference
In-Depth Information
:Presentation
Tier
:Business
Tier
:Database
Begin Modify Order
Begin Modify Order
Database Transaction 1
Lock Order
Read Order
Update Order Details
Database Transaction 2
Validate User Input
Read ...
...
Save Changes
Database Transaction N
Save Changes
Update Order
Unlock Order
Figure 13.4
Using the Pessimistic Offline Lock pattern
13.5.3
Benefits and drawbacks
Let's look at the benefits and drawbacks of the Pessimistic Offline Lock pattern.
Ensures that a user can save changes
The main benefit of the Pessimistic Offline Lock pattern is that it prevents con-
current updates by locking shared data when it is read. It ensures that users will be
able to save their changes and will not be required to start over. As a result, the
usability of the application is improved.
Impacts the application globally
An unfortunate drawback of this pattern is that if you decide to use it in your
application, then all of the business logic that updates the shared data must be
aware of the pattern. Unfortunately, this can be error-prone because it can be dif-
ficult to use the pattern consistently. When you start using this pattern in your
application, it is all too easy to miss existing code that must be modified. Similarly,
 
 
Search WWH ::




Custom Search