簡體   English   中英

Doctrine ODM MongoDB未加載EmbedOne文檔

[英]Doctrine ODM MongoDB EmbedOne Document not loaded

我需要為我們的預訂存儲一些數據,其中包括客戶數據,我希望將其作為預訂文檔中的嵌入文檔。 使用我當前的配置,所有數據都保存在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
}

清除緩存。 映射是正常的,因為數據是正確持久的,錯誤的是Hydrator已經到位並且沒有使用新字段進行更新。 為了避免這種情況,您可以考慮在開發過程中使用AUTOGENERATE_EVAL策略進行水合器/代理自動生成。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM