Doctrine ODM MongoDB EmbedOne Document not loaded

為{幸葍}努か 提交于 2019-12-24 10:23:57

问题


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?

This is how my documents look like:

The Booking-Document:

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

The Customer-Document

<?php

namespace AppBundle\Document;

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

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

回答1:


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.



来源:https://stackoverflow.com/questions/43866068/doctrine-odm-mongodb-embedone-document-not-loaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!