public Optional<User> requestPasswordReset(String mail) {
return userRepository.findOneByEmail(mail)
.filter(User::getActivated)
.map(user -> {// updata
user.setResetKey(RandomUtil.generateResetKey());
user.setResetDate(Instant.now());
return user;
});
}
//Enter the breakpoint, check the print results through the backend, and find that the select statement is executed first, and then the update statement is executed. I don’t quite understand why after set
//You can update without the save method
After following the code, when I get to this method, I execute the update statement. I ask the master to see it and teach me. I am very grateful! I will definitely pay attention to you.
Judging from your screenshot, I didn’t see where the update statement was executed. According to my experience, it will be updated only when the save method is called
It should be that JPA discovered that your object is dirty and automatically executed it before Transaction commit.