Edit User Data

Learn how to enable the editing of user data.

Adding version

In order to support the editing of our User entities, we will need to make some changes in the Java code. First of all, we will use io.github.wimdeblauwe.jpearl.AbstractVersionedEntity as the superclass of User instead of io.github.wimdeblauwe.jpearl.AbstractEntity.

This class adds a version field to the entity, which will allow us to use Optimistic LockingA strategy where we take note of the version number while reading a record. This is done to ensure that the version hasn’t changed before we write the record back.. Most importantly, this will guard the user from concurrent updates (either by another user or by himself in another tab, for example).

Updating SQL script

Let’s update our SQL creation script to have the new version field:

Get hands-on with 1400+ tech skills courses.