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
- use a repository to fetch an entity object, load into memory
- call methods on that entity which updates properties, containing business logic for validation
- 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