title: Symfony primary key error on form submission: Integrity constraint violation: 1062 Duplicate entry '0'
body: <p>The below route in the controller works with my <code>Film</code> entity for creating the first object in the table - however, the primary key doesn't seem to be incrementing if I try to create a second entry:</p>
  <blockquote>
  <p>An exception occurred while executing 'INSERT INTO Films (film_title, year, set_id, rating) VALUES (?, ?, ?, ?)' with params [&quot;The Matrix&quot;, null, null, null]:</p>
  <p>SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY'</p>
  </blockquote>
  <p>The route from my controller is:</p>
  <pre><code>/**
   * @Route(&quot;/newfilm&quot;, name=&quot;new_film&quot;)
   */
  public function newFilmAction(Request $request)
  {
      $film = new Films();
  
      $form = $this-&gt;CreateFormBuilder($film)
          -&gt;add('film_title','text',array('label'=&gt;'Film Title'))
          -&gt;add('Save','submit',array('label'=&gt;'Add Film'))
          -&gt;getForm();
  
      $form-&gt;handleRequest($request);
  
      if ($form-&gt;isValid()) {
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $em-&gt;persist($film);
          $em-&gt;flush();
          return $this-&gt;redirectToRoute('success_filmadded');
      }
  
      return $this-&gt;render('AppBundle:Default:new.film.form.html.twig', array(
          'form' =&gt; $form-&gt;createView(),
      ));
  }
  </code></pre>
  <p>The relevant code from my Films entity is:</p>
  <pre><code>namespace AppBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * Films
   *
   * @ORM\Table(name=&quot;Films&quot;, indexes={@ORM\Index(name=&quot;fk_Films_sets1_idx&quot;, columns={&quot;set_id&quot;})})
   * @ORM\Entity
   */
  class Films
  {
  
      /**
       * @var integer
       *
       * @ORM\Column(name=&quot;filmid&quot;, type=&quot;integer&quot;)
       * @ORM\Id
       * @ORM\GeneratedValue(strategy=&quot;AUTO&quot;)
       */
      private $filmid;
  
  
      /**
       * @var string
       *
       * @ORM\Column(name=&quot;film_title&quot;, type=&quot;text&quot;, length=65535, nullable=false)
       */
      private $film_title;
  
      /**
       * @var string
       *
       * @ORM\Column(name=&quot;year&quot;, type=&quot;integer&quot;, nullable=true)
       */
      private $year;
  
  
      /**
       * @var \AppBundle\Entity\Sets
       *
       * @ORM\ManyToOne(targetEntity=&quot;AppBundle\Entity\Sets&quot;)
       * @ORM\JoinColumns({
       *   @ORM\JoinColumn(name=&quot;set_id&quot;, referencedColumnName=&quot;setid&quot;)
       * })
       */
      private $set;
  
  
      /**
       * @var integer
       *
       * @ORM\Column(name=&quot;rating&quot;, type=&quot;integer&quot;, nullable=true)
       */
      private $rating;
  }
  </code></pre>
  <p>I want to be able to add new objects that have NULL for these other parameters still.</p>