* @see ${package}.services.IUserService${symbol_pound}changePassword(${package}.domain.User, java.lang.String)
*/
@Override
@Transactional(readOnly = false)
public void changePassword(User user, String newPassword) {
PasswordEncoder encoder = new StandardPasswordEncoder();
String encodedPassword = encoder.encode(newPassword);
// load fresh user version from db to have managed version and avoid optimistic lock exception.
User userFromDb = findById(user.getId());
userFromDb.setPassword(encodedPassword);
update(userFromDb);
}