@Component
@RepositoryEventHandler
public class UserEventHandler {
@HandleBeforeSave
public void handleUserSave(User user) throws InterruptedException {
User oldUser = userRepository.findById(user.getId()); //already too late, gets the new password
}
}
I have a method that gets triggered before a User is saved by Spring Data Rest. I want to check the old and new password, for example to not let it to be the same.
But there is no way to query the old password by the time the handler is called, even though the database still has the value.
How to solve this?