如何在extbase模型中重置具有1:1关系的属性

I've got a problem regarding a model in extbase with a 1:1 relation. My model "Beast" has a link to another Model "MissingBeast" which is realized through a 1:1 relation. I can successfully add add the MissingBeast object to the Beast object. But I don't know how the reset it.

The following code shows the property definition in the Model Beast

/**
 * missingBeast
 *
 * @var Tx_Hobeast_Domain_Model_MissingBeast
 * @lazy 
 */
 protected $missingBeast;

/**
 * Returns the missingBeast
 *
 * @return Tx_Hobeast_Domain_Model_MissingBeast $missingBeast
 */
public function getMissingBeast() {
    return $this->missingBeast;
}

/**
 * Sets the missingBeast
 *
 * @param Tx_Hobeast_Domain_Model_MissingBeast $missingBeast
 * @return void
 */
public function setMissingBeast(Tx_Hobeast_Domain_Model_MissingBeast $missingBeast) {
    $this->missingBeast = $missingBeast;
}

the value for missingBeast in the database table of the Model Beast is just the id of the missingBeast. Which by default is 0.

Ho can I reset this id to 0 after a MissingBeast has been set? I've tried to just delete the missing beast like so:

   $missingBeast = $this->service->missingBeastRepository->findByBeast($beast);
   $this->service->missingBeastRepository->remove($missingBeast);

But when I do that the following query gets stuck in an infinite loop.

$query = $this->createQuery();
return $query->matching($query->equals("uid", $beast->getMissingBeast()))->execute()->count();

I'm using Typo version 4.7.8

Simply set it to NULL, this will remove the relation and don't forget to update the Model in the repository.

$beast = $this->beastRepository->findByUid(345)->setMissingBeast(NULL);
$this->beastRepository->update($beast);

In order to be able to set the property to NULL, you must adjust your model by setting the property to NULL by default and remove the type hint in the setter:

/**
 * missingBeast
 *
 * @var Tx_Hobeast_Domain_Model_MissingBeast
 * @lazy 
 */
 protected $missingBeast = NULL;

/**
 * Sets the missingBeast
 *
 * @param Tx_Hobeast_Domain_Model_MissingBeast $missingBeast
 * @return void
 */
public function setMissingBeast($missingBeast) {
    $this->missingBeast = $missingBeast;
}