[英]Jms serializer @JMS\Inline() annotation overrides an actual id
I have product
and product_detail
tables in database. 我在数据库中有
product
和product_detail
表。
Every product has a product detail. 每个产品都有产品详细信息。
class Product
{
/**
* @var ProductDetail
* @JMS\ReadOnly()
* @ORM\OneToOne(targetEntity="ApiBundle\Entity\ProductDetail", mappedBy="product", cascade={"persist"})
* @JMS\Inline()
*/
private $detail;
}
I use @JMS\\Inline() annotation to show only detail information of product_detail table. 我使用@JMS \\ Inline()批注仅显示product_detail表的详细信息。 But when I serialize a product I get wrong id.
但是,当我序列化产品时,我得到了错误的ID。 It must be product id but id returns an product detail id.
它必须是产品ID,但ID返回产品详细信息ID。 Is it bug or I am doing something wrong?
是错误还是我做错了什么?
You should not expose the id from the detail when using inline.
使用内联时,您不应从详细信息中公开ID。
Source: https://github.com/schmittjoh/JMSSerializerBundle/issues/460#issuecomment-113440743 来源: https : //github.com/schmittjoh/JMSSerializerBundle/issues/460#issuecomment-113440743
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.