Java Reference
In-Depth Information
:FoodToGo
Application
:Database
User
Begin Acknowledge Order
SELECT *
FROM PLACED_ORDER
WHERE ORDER_ID = ?
Display Order Details
Accept Order
Display Summary Page
Confirm
UPDATE PLACED_ORDER
SET STATUS = 'ACCEPTED',
NOTES = '....'
WHERE ORDER_ID = ?
Display Order Details
Figure 13.1
Databases accesses during the Acknowledge Order use case
Using a single database transaction
In theory, the application could implement the Acknowledge Order use case
using a single database transaction that starts when the user begins the use case
and commits after he acknowledges the order. The application prevents concur-
rent updates by using a serializable transaction or either optimistic locking or pes-
simistic locking. The problem with this approach is that the database transaction
would be long-running because it encompasses multiple web requests and user
think time. In addition, the transaction might last until the web session timed out
if the user could simply walk away from the browser without completing the use
case. Most applications cannot use long-running transactions because they reduce
scalability and concurrency. They reduce scalability because database connec-
tions, which are a precious resource, would be held for the duration of the trans-
action and could not be used by other transactions. Long database transactions
reduce concurrency because rows in the database are locked for the entire time,
 
 
Search WWH ::




Custom Search