diff --git a/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php b/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php
index c9354b6..9958b60 100644
--- a/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php
+++ b/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php
@@ -259,7 +259,9 @@ class EntityReferenceRevisionsItem extends EntityReferenceItem implements Option
     if ($this->entity instanceof EntityNeedsSaveInterface && $this->entity->needsSave()) {
       $this->entity->save();
     }
-    $this->target_revision_id = $this->entity->getRevisionId();
+    if ($this->entity) {
+      $this->target_revision_id = $this->entity->getRevisionId();
+    }
   }
 
   /**
diff --git a/tests/src/Kernel/EntityReferenceRevisionsSaveTest.php b/tests/src/Kernel/EntityReferenceRevisionsSaveTest.php
index 40792d6..7f0de95 100644
--- a/tests/src/Kernel/EntityReferenceRevisionsSaveTest.php
+++ b/tests/src/Kernel/EntityReferenceRevisionsSaveTest.php
@@ -116,6 +116,12 @@ class EntityReferenceRevisionsSaveTest extends KernelTestBase {
     // Check the name is not updated.
     $entity_test_after = EntityTestCompositeRelationship::load($entity_test->id());
     static::assertEquals($entity_test_after->name->value, $text);
+
+    // Test if after delete the referenced entity there are no problems setting
+    // the referencing values to the parent.
+    $entity_test->delete();
+    $node = Node::load($node->id());
+    $node->save();
   }
 
   /**
