The main question is, how to update just a few chosen fields from our form. I would like to give user choice which fields they want to update. For example, I have the form class:
public class UserRegistrationform {
private Integer userId;
@NotNull
private String name;
@NotNull
private String surname;
@Email
@NotNull
private String email;
@NotNull
private Integer genderId;
@NotNull
private Integer groupId;
@NotNull
private List<ContactInfoDto> contactsInfo;
@NotNull
private String userSecretkey;
@NotNull
private String password;
@NotNull
private boolean enabled;
@NotNull
private boolean resetPassword;
After that I'm setting fields in @Entity
class User
, and for example, if user want to change just their name and surname, I want to take the rest of the fields from the existing User
, by findById()
method and after that change a few fields and save the changed object to the database.