@Override
 @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
 public void updateUserPassword(User user) {
   PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
   String hashedPassword = passwordEncoder.encode(user.getPassword());
   user.setPassword(hashedPassword);
   userDao.updateUser(user);
 }
 @Override
 @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
 public Integer addUser(User user) throws UserAlreadyExistsException {
   if (userDao.findUserByUserName(user.getUsername()) != null)
     throw new UserAlreadyExistsException(user.getUsername());
   else {
     PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
     String hashedPassword = passwordEncoder.encode(user.getPassword());
     user.setPassword(hashedPassword);
     return userDao.addUser(user);
   }
 }