public function assign(Role $role, $userId)
    {
        $userRole = new UserRole();

        $userRole->setUserId($userId);
        $userRole->setRole($role);

        try {
            $this->saveEntity($userRole);
        } catch (UniqueConstraintViolationException $e) {
            throw new NotUniqueException('Role ' . $role->getName() . 'is already assigned to user with identifier ' . $userId);
        }
    }