Symfony 3 Doctrine Composite Key: single id is not allowed on composite primary key in entity
<p>I have an entity with an </p>

<blockquote>
  <p>integer column (compositeId)</p>
</blockquote>

<p>and a </p>

<blockquote>
  <p>string column (asin)</p>
</blockquote>

<p>I want both columns working as a composite key.
So I look here in the documentation:</p>

<p><a href="http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/composite-primary-keys.html" rel="nofollow">http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/composite-primary-keys.html</a></p>

<p>But when I try to load my repository</p>

<pre><code>$myEntity = $em-&gt;getRepository(MyEntity::class);
</code></pre>

<p>I got this error message:</p>

<blockquote>
  <p>single id is not allowed on composite primary key in entity
  AppBundle\Entity\MyEntity</p>
</blockquote>

<p>This is my Entity:</p>

<pre><code>&lt;?php

namespace AppBundle\Entity;


use Doctrine\ORM\Mapping as ORM;

/**
 * @Entity(repositoryClass="AppBundle\Repository\MyEntityRepository")
 * @Table(name="my_entity")
 */
class MyEntity {

    /**
     * @Column(type="integer")
     * @GeneratedValue()
     */
    protected $id;

    /**
     * @var integer
     * @Id
     * @Column(type="integer", name="composite_id")
     */
    protected $compositeId;

    /**
     * @var string
     * @Id
     * @Column(type="string", name="asin")
     */
    protected $asin;

    /**
     * @var string
     * @Column(type="string", name="sku")
     */
    protected $sku;

    /**
     * @var string
     * @Column(type="string", name="ean")
     */
    protected $ean;

    /**
     * @codeCoverageIgnore
     * @return mixed
     */
    public function getId() {

        return $this-&gt;id;
    }

    /**
     * @param mixed $id
     *
     * @return MyEntity;
     */
    public function setId($id) {

        $this-&gt;id = $id;

        return $this;
    }

    /**
     * @codeCoverageIgnore
     * @return int
     */
    public function getCompositeId() {

        return $this-&gt;compositeId;
    }

    /**
     * @param int $compositeId
     *
     * @return MyEntity;
     */
    public function setCompositeId($compositeId) {

        $this-&gt;compositeId = $compositeId;

        return $this;
    }

    /**
     * @codeCoverageIgnore
     * @return string
     */
    public function getAsin() {

        return $this-&gt;asin;
    }

    /**
     * @param string $asin
     *
     * @return MyEntity;
     */
    public function setAsin($asin) {

        $this-&gt;asin = $asin;

        return $this;
    }

    /**
     * @codeCoverageIgnore
     * @return string
     */
    public function getSku() {

        return $this-&gt;sku;
    }

    /**
     * @param string $sku
     *
     * @return MyEntity;
     */
    public function setSku($sku) {

        $this-&gt;sku = $sku;

        return $this;
    }

    /**
     * @codeCoverageIgnore
     * @return string
     */
    public function getEan() {

        return $this-&gt;ean;
    }

    /**
     * @param string $ean
     *
     * @return MyEntity;
     */
    public function setEan($ean) {

        $this-&gt;ean = $ean;

        return $this;
    }
}
</code></pre>

<p>What am I doing wrong?
When I remove @generatedValue at my ID table it works.
But I need auto generated values at my ID column.
I don't have any @Id annotation at my ID column, only @generatedValue, and on my both @Id columns I don't have any annotation with @generatedValue but I got this error ... </p>