/** @ODM\Document(collection="Entities") */
class Entity extends Document {
/** @ODM\Id */
protected $_id;
/** @ODM\ReferenceOne(targetDocument="\Doctrine\Documents\Entities\Entity2", simple=true) */
protected $entity2;
}
/** @ODM\Document(collection="Entities2") */
class Entity2 extends Document {
/** @ODM\Id */
protected $_id;
/** @ODM\String */
protected $label;
}
My problem is when I call referenced entity $entity->getEntity2()
it returns the entity2
but with public $__isInitialized__ => bool(false)
. Then when I try to call $entity->getEntity2()->getId()
it throws Doctrine\ODM\MongoDB\DocumentNotFoundException The "Proxies\__CG__\Doctrine\Documents\Entities\Entity2" document with identifier "54de5341642c8769150041a7" could not be found.
Weird is that this happen when I call it before rendering in my framework. When I do the same during rendering method it works but it doesn't work for example in form submit-handling methods...
I have cleaned cache, proxies and hydrators. The document with this ObjectID
is in my database and it gets returned, only not initialized and can't get any of its properties except in the rendering method
This is returned by calling getEntity2()
(mind $__isInititalized = false
)
class Proxies__CG__\Doctrine\Documents\Entities\Entity2#178 (6) { public $initializer => class Closure#160 (3) { public $static => array(2) { 'documentPersister' => class Doctrine\ODM\MongoDB\Persisters\DocumentPersister#166 (11) { ... } 'reflectionId' => class ReflectionProperty#165 (2) { ... } } public $this => class Doctrine\ODM\MongoDB\Proxy\ProxyFactory#78 (7) { private $metadataFactory => class Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactory#74 (9) { ... } private $uow => class Doctrine\ODM\MongoDB\UnitOfWork#76 (23) { ... } private $proxyNamespace => string(7) "Proxies" private $proxyGenerator => class Doctrine\Common\Proxy\ProxyGenerator#79 (4) { ... } private $autoGenerate => int(1) private $definitions => array(1) { ... } private $metadataFactory => class Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactory#74 (9) { ... } } public $parameter => array(1) { '$proxy' => string(10) "" } } public $cloner => class Closure#170 (3) { public $static => array(3) { 'documentPersister' => class Doctrine\ODM\MongoDB\Persisters\DocumentPersister#166 (11) { ... } 'classMetadata' => class Doctrine\ODM\MongoDB\Mapping\ClassMetadata#155 (38) { ... } 'reflectionId' => class ReflectionProperty#165 (2) { ... } } public $this => class Doctrine\ODM\MongoDB\Proxy\ProxyFactory#78 (7) { private $metadataFactory => class Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactory#74 (9) { ... } private $uow => class Doctrine\ODM\MongoDB\UnitOfWork#76 (23) { ... } private $proxyNamespace => string(7) "Proxies" private $proxyGenerator => class Doctrine\Common\Proxy\ProxyGenerator#79 (4) { ... } private $autoGenerate => int(1) private $definitions => array(1) { ... } private $metadataFactory => class Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactory#74 (9) { ... } } public $parameter => array(1) { '$proxy' => string(10) "" } } public $isInitialized => bool(false) protected $_id => NULL protected $label => NULL protected $id => string(24) "54de5341642c8769150041a7" }