Database Reference
In-Depth Information
Chapter 14
Concurrency
Most applications that use sophisticated database management systems, such as Microsoft's SQL Server, are used by
more than one person at a time. The concurrency concerns surrounding shared access to simple data files are often
the motivating reason why developers turn to relational database systems to support their applications. Many, but not
all, of the concurrency concerns evaporate when an application relies on a relational database for its data store. The
concerns that remain usually involve detecting and controlling when an object state is different in memory than in
the database. The recipes in this chapter provide an introduction to solving some of the problems typically faced by
developers when it comes to detecting concurrency violations and controlling which copy of the object is ultimately
persisted in the database.
14-1. Applying Optimistic Concurrency
Problem
You want to use optimistic concurrency with an entity in your model.
Solution
Let's suppose you have a model like the one shown in Figure 14-1 .
Figure 14-1. A Product entity describing products in your application
 
Search WWH ::




Custom Search