MongoDB optimistic locking

Introduction When moving from JPA to MongoDB you start to realize how many JPA features you’ve previously taken for granted. JPA prevents “lost updates” through both pessimistic and optimistic locking. Optimistic¬†locking doesn’t end up locking anything, and it would have been better named optimistic locking-free or optimistic concurrency control because that’s what it does anyway. Lost updates So, what does it mean to “lose updates”? A real-life example would be when multiple background tasks update different attributes of some common Entity. In our example, we have a Product¬†Entity with a quantity and… Read More