【问题标题】:Doctrine ODM MongoDB EmbedOne Document not loadedDoctrine ODM MongoDB EmbedOne 文档未加载
【发布时间】:2017-05-09 20:20:03
【问题描述】:

我需要为我们的预订存储一些数据,其中包括客户数据,我希望将其作为预订文档中的嵌入文档。使用我当前的配置,所有数据都保存在 MongoDB 中,但是当我加载预订文档时,没有相关的客户对象。我是否忘记了某些配置或其他内容?

这是我的文档的样子:

预订文件:

<?php

namespace AppBundle\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

/**
 * @MongoDB\Document
 */
class Booking
{
    /**
     * @MongoDB\EmbedOne(targetDocument="\AppBundle\Document\Customer")
     */
    private $customer;

    // getter and setter...
}

客户文档

<?php

namespace AppBundle\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

/**
 * @MongoDB\EmbeddedDocument
 */
class Customer
{
    // fields, getter and setter
}

【问题讨论】:

标签: php symfony doctrine doctrine-odm odm


【解决方案1】:

清除缓存。映射是可以的,因为数据被正确保存,错误是Hydrator 已经到位并且没有使用新字段进行更新。为了避免这种情况,您可以考虑在开发过程中使用 AUTOGENERATE_EVAL 策略来自动生成 hydrators/proxy。

【讨论】:

  • 谢谢。这个问题是缓存造成的。
猜你喜欢
  • 1970-01-01
  • 2012-12-20
  • 1970-01-01
  • 2014-03-20
  • 2015-04-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多