I'm using Symfony2 with mongodb & doctrine-odm which have a strange behavior. I have an importFile document and a context document. The contexte document is referenced into the importFile one as below :
/**
* @MongoDB\Document
*/
class ImportFile
{
[...]
/**
* @MongoDB\ReferenceOne(targetDocument="Contexte")
*/
private $contexte;
(getter and setter are ok).
My contexte document already exist, and lives into the session. If i dump the context object, i do have all required object info, with his id, and all his properties.
In my controller, i want to save this contexte object into my importFile one :
$dm = $this->getDocumentManager();
$importFile->setContexte($contexte); // contexte object already exists and persisted
$dm->persist($importFile);
$dm->flush();
it looks very simple, and should works like that, but on the flush, i get a mongodb error :
Cannot create a DBRef without an identifier. UnitOfWork::getDocumentIdentifier() did not return an identifier for class Contexte
i don't know what i'm doing wrong. Any help ?
Haven't you done a var_dump($importFile) maybe when you are retrieving the object, is just null