Edit User Data
Learn how to enable the editing of user data.
We'll cover the following...
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 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:
On line 4, we have added the version field.
Edit user method
Next, we’ll create a new UserService method to allow user properties to be eidted:
Since we will allow the editing of all parameters used at creation, we can extend from CreateUserParameters and add the version field:
Now we’ll update UserServiceImpl by adding the following code:
- Get the user for the given
UserIdfrom the database. If there is no matching user, throw a