教义ODM MongoDB EmbedOne文档未加载 [英] Doctrine ODM MongoDB EmbedOne Document not loaded

查看:193
本文介绍了教义ODM MongoDB EmbedOne文档未加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要存储我们预订的一些数据,包括客户数据,我希望在我的预订文件中嵌入文档。使用我目前的配置,所有数据都保留在MongoDB中,但是当我加载预订文档时,没有相关的客户对象。我忘了一些配置还是别的什么?

I need to store some data for our booking and thats include the customer data, which I want as embedded document within my booking document. With my current configuration all data are persisted in MongoDB, but when I load the booking document, there is no related customer object. Did I forget some configuration or something else?

这是我的文档的样子:

预订文件:

<?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
}


推荐答案

清除缓存。映射是正确的,因为数据保持正确,错误的是 Hydrator 已经到位,并没有更新与新的字段。为避免这种情况,您可以考虑使用 AUTOGENERATE_EVAL 在开发过程中自动生成水龙头/代理的策略。

Clear your cache. Mapping is OK since the data is persisted correctly, what is wrong is that Hydrator was already in place and wasn't updated with the new field. To avoid such situations you can consider using AUTOGENERATE_EVAL strategy for hydrators/proxies auto-generation during the development.

这篇关于教义ODM MongoDB EmbedOne文档未加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆