protected function doFlushFinalTransaction(ResourceListInterface $resources, $autoCommit, $hasError): void
    {
        if (!$autoCommit) {
            if ($hasError) {
                $this->cancelTransaction();
                DomainUtil::cancelAllSuccessResources($resources);
            } else {
                $errors = $this->flushTransaction();
                DomainUtil::moveFlushErrorsInResource($resources, $errors);
            }
        }
    }