@Override
 public void update(User user) {
   String password = user.getPassword();
   if (password != null && !password.isEmpty()) {
     user.setEncodedPassword(passwordEncoder.encode(user.getPassword()));
   }
   try (Connection connection = getConnection()) {
     try (PreparedStatement statement = connection.prepareStatement(UPDATE)) {
       statement.setString(1, user.getLogin());
       statement.setString(2, user.getEncodedPassword());
       statement.setInt(3, user.getPersonality().getId());
       statement.setInt(4, user.getId());
       statement.executeUpdate();
     }
   } catch (SQLException e) {
     processException(e);
   }
 }
 @Override
 public void create(User user) {
   try (Connection connection = getConnection()) {
     try (PreparedStatement statement = connection.prepareStatement(CREATE)) {
       statement.setString(1, user.getLogin());
       statement.setString(2, passwordEncoder.encode(user.getPassword()));
       statement.setInt(3, user.getPersonality().getId());
       statement.executeUpdate();
     }
     try (PreparedStatement statement = connection.prepareStatement(CREATE_USER_ROLE)) {
       for (Role role : user.getRoles()) {
         statement.setInt(1, user.getId());
         statement.setInt(2, role.getId());
         statement.executeUpdate();
       }
     }
   } catch (SQLException e) {
     processException(e);
   }
 }