doctrine/mongodb-odm — Issue #248: Setting Null to a @EmbedOne property is throwing an exception
Author: warseph
Created: 2012-02-06 21:54:03+00:00
State: open

Here's what my code is doing (had to replace some of the names for placeholders, but it should work the same)

```php
/**
* @MongoDB\Document(db="database", collection="Collection")
*/
class MyDoc
{

/** @MongoDB\Id(strategy="NONE") */
protected $id;

/**
* @MongoDB\Date
*/
protected $interval;

/**
* @MongoDb\EmbedOne(targetDocument="FQCN\EmbDoc", nullable="true")
*/
protected $embObj;

.....
}

----

**
* @MongoDB\EmbeddedDocument
*/
class EmbDoc
{
/**
* @MongoDB\String
*/
protected $aField;

/**
* @MongoDB\String
*/
protected $anotherField;
...
}

----

$doc = new MyDoc();
$doc->setId($id);
$doc->setInterval($interval);
$doc->setEmbObj(null);
$dm->persist($doc);
$dm->flush();
```
This code throws this exception:

[Doctrine\ODM\MongoDB\MongoDBException]
Class Doctrine\ODM\MongoDB\Persisters\PersistenceBuilder is not a valid document or mapped super class.

PHP Stack trace:
...
PHP 11. Doctrine\ODM\MongoDB\DocumentManager->flush()
PHP 12. Doctrine\ODM\MongoDB\UnitOfWork->commit() /var/www/Project/vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/DocumentManager.php:515
PHP 13. Doctrine\ODM\MongoDB\UnitOfWork->executeInserts() /var/www/Project/vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/UnitOfWork.php:431
PHP 14. Doctrine\ODM\MongoDB\Persisters\DocumentPersister->executeInserts() /var/www/Project/vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/UnitOfWork.php:941
PHP 15. Doctrine\ODM\MongoDB\Persisters\PersistenceBuilder->prepareUpsertData() /var/www/Project/vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php:205
PHP 16. Doctrine\ODM\MongoDB\Persisters\PersistenceBuilder->prepareUpsertData() /var/www/Project/vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php:289
PHP 17. spl_object_hash() /var/www/Project/vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php:252