Symfony Single id is not allowed on composite primary key in entity

1

I have a view, where I mapped 3 fields as the primary key and 2 of those fields are foreign keys

As below:

/**
     * @var NotaFiscal
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="NotaFiscal", inversedBy="itens")
     * @ORM\JoinColumn(name="CODIGO", referencedColumnName="CODIGO")
     */
    private $notaFiscal;

    /**
     * @var Produto
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="Produto")
     * @ORM\JoinColumn(name="CD_PRODUTO", referencedColumnName="CD_PRODUTO")
     */
    private $produto;

    /**
     * @var string
     * @ORM\Id
     * @ORM\Column(name="CD_LOTE")
     */
    private $lote;

I can not see where the error is ... Single id is not allowed on composite primary key in entity

    
asked by anonymous 24.10.2017 / 14:20

1 answer

0

Leave @ORM\Id in the primary key only.

For more reference on mapping Doctrine fields and annotations, see Basic Mapping

    
24.10.2017 / 14:41