Jms serializer @JMS\Inline() annotation overrides an actual id

1.5k views Asked by At

I have product and product_detail tables in database.

enter image description here

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. But when I serialize a product I get wrong id. It must be product id but id returns an product detail id. Is it bug or I am doing something wrong?

1

There are 1 answers

0
Farid Movsumov On BEST ANSWER

You should not expose the id from the detail when using inline.

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