Doctrine ODM MongoDB未加载EmbedOne文档(Doctrine ODM MongoDB EmbedOne Document not loaded)

编程入门 行业动态 更新时间:2024-10-27 16:30:58
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 }

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 }

最满意答案

清除缓存。 映射是正常的,因为数据保持正确,错误的是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.

更多推荐

本文发布于:2023-08-07 11:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464181.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   文档   MongoDB   ODM   Doctrine

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!