Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3641

Updating database records in DDD is susceptible to lost update problem

$
0
0

I'm learning DDD for the first time, and all over the internet I see a very clean pattern for updating values in the database. It looks something like so

  1. use a repository to fetch an entity object, load into memory
  2. call methods on that entity which updates properties, containing business logic for validation
  3. use a repository to save that entity back to the database

Now the only problem that I see with this approach is having a lost update when concurrent users are attempting to update the same database record.

I know that there are techniques to lock database records such as SQL "SELECT FOR UPDATE" statements, enabling pessimistic locking. I just want to get a better understanding for how most applications get around this problem, as I have attempted to research it and have not found any direct answers to the question


Viewing all articles
Browse latest Browse all 3641

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>