0
我有一些问题与主义MongoDB的ODM和Symfony的2主义的MongoDB - 对文档的查询与嵌入文档的多级
嵌入文档要揭露问题,我有记录产品embedOne productInformation和productInformation embedOne productInformationAddress。
要查询,我用类似的东西:
/**
* @ODM\Document
**/
class product {
/**
* @ODM\EmbedOne(targetDocument="productInformation")
**/
protected $informations;
}
/**
* @ODM\EmbeddedDocument
**/
class productInformations {
/**
* @ODM\EmbedOne(targetDocument="productInformationAddress")
**/
protected $address;
/**
* @ODM\Collection
**/
protected $attr1 = array();
/**
* @ODM\String
**/
protected $attr2
}
/**
* @ODM\EmbeddedDocument
**/
class productInformationAddress {
/** ... suff ... /*
}
当我查询:
class productRepository {
public function fetchOne($id) {
return $this->createQueryBuilder()
->field('id')->equals($id)
->getQuery()
->getSingleResult();
}
}
但是,我不明白为什么我不能得到$product->getInformations()->getAddress()
,总是返回null
.. 。
有什么想法?
谢谢你的回答,事实上,问题很简单......缓存...但是,你是对的,并感谢你的测试链接。 – Spike008t 2012-08-06 15:09:37