Handling Optimistic Locking Failure

Learn how to properly handle Optimistic Locking for the version field in User.

Testing the version

We added a version field to our User entity in order to use Optimistic Locking. We can quickly test if this works with the following steps:

  • Open the application in two different tabs (or browsers).
  • Click the “Edit” link for a user in the first tab and do the same (for the same user) in the other tab.
  • Change something in the first tab and save.
  • Without refreshing the second tab, change something else there and save.

You will get something like this:

Get hands-on with 1200+ tech skills courses.