0

我在数据库中有productproduct_detail表。

在此处输入图像描述

每个产品都有一个产品细节。

class Product
{
   /**
     * @var ProductDetail
     * @JMS\ReadOnly()
     * @ORM\OneToOne(targetEntity="ApiBundle\Entity\ProductDetail", mappedBy="product", cascade={"persist"})
     * @JMS\Inline()
     */
    private $detail;
}

我使用 @JMS\Inline() 注释只显示 product_detail 表的详细信息。但是当我序列化一个产品时,我得到了错误的 ID。它必须是产品 ID,但 id 返回产品详细信息 ID。是错误还是我做错了什么?

4

1 回答 1

1

使用内联时,不应从详细信息中公开 id。

来源:https ://github.com/schmittjoh/JMSSerializerBundle/issues/460#issuecomment-113440743

于 2015-06-19T13:32:57.273 回答