private function checkHasOneRelation($entity, $relation)
    {
        $objectHashId     = $this->entityRegistry->getObjectHashId($entity);
        $varObjName       = $relation->varObjectName();
        $varReferenceName = $relation->varReferenceName();

        $currentRelation  = $this->getValue($entity, $varObjName);
        $originalRelation = $this->getValue($this->entityRegistry->getOriginal($entity), $varObjName);

        if (empty($currentRelation)) {
            // Current entity has no relation
            if (!empty($originalRelation)) {
                // Original had a relation, so relation was removed
                $this->scheduleForDeletion($originalRelation);
            }

            return;
        }

        // Current entity has a relation
        $currentRelationHash = $this->entityRegistry->getObjectHashId($currentRelation);

        if (isset($this->scheduledForDeletion[$objectHashId]) && $relation->cascadeDelete()) {
            $this->scheduleForDeletion($currentRelation);
        }

        if (empty($originalRelation)) {
            // Original had no relation, so relation was newly created
            $this->scheduleRelationForInsertion($entity, $currentRelation, $varReferenceName);

            return;
        }

        $originalRelationHash = $this->entityRegistry->getObjectHashId($originalRelation);

        if ($currentRelationHash != $originalRelationHash) {
            // Relation was exchanged
            $this->scheduleForDeletion($originalRelation);
            $this->scheduleRelationForInsertion($entity, $currentRelation, $varReferenceName);
        }
    }