title: Symfony Not null violation: 7 ERROR: null value in column "id"
body: <p>I get this error when trying to create new entity called &quot;Nuclei&quot;
  This is the entity class:</p>
  <pre><code>/**
   * Nuclei
   *
   * @ORM\Table(name=&quot;datinuclei&quot;)
   * @ORM\Entity(repositoryClass=&quot;App\Repository\NucleiRepository&quot;)
   */
  class Nuclei
  {
      /**
       * @var int
       *
       * @ORM\Id
       * @ORM\Column(name=&quot;id&quot;, type=&quot;integer&quot;, nullable=false)
       * @ORM\GeneratedValue(strategy=&quot;SEQUENCE&quot;)
       * @ORM\SequenceGenerator(sequenceName=&quot;datinuclei_id_seq&quot;, allocationSize=1, initialValue=1)
       */
      private $id;
  
      /**
      * @var NucleiStatistiche
      *
      * @ORM\OneToOne(targetEntity=&quot;NucleiStatistiche&quot;)
      * @ORM\JoinColumn(name=&quot;id&quot;, referencedColumnName=&quot;id&quot;)
      */
      private $statistiche;
  </code></pre>
  <p><strong>Edit:</strong> NucleiStatistiche is a materialized view (cannot insert rows) defined on entity NucleiStatistiche</p>
  <pre><code>    class NucleiStatistiche
      {
          /**
           * @var int
           *
           * @ORM\Id
           * @ORM\Column(name=&quot;id&quot;, type=&quot;integer&quot;)
           * @ORM\GeneratedValue(strategy=&quot;NONE&quot;)
           */
          private $id;
  
  
          /**
           * @var string
           *
           * @ORM\Column(name=&quot;totale_conferimenti&quot;, type=&quot;integer&quot;, nullable=false)
           */
          private $totale_conferimenti;
  </code></pre>
  <p>PostgreSQL table schema definition</p>
  <pre><code>CREATE TABLE public.datinuclei
  (
      id integer NOT NULL DEFAULT nextval('datinuclei_id_seq'::regclass),
      idcomune integer NOT NULL,
      cognome character varying COLLATE pg_catalog.&quot;default&quot;,
      nome character varying COLLATE pg_catalog.&quot;default&quot;,
      CONSTRAINT datinuclei_pkey PRIMARY KEY (id),
      CONSTRAINT datinuclei_codicenucleo UNIQUE (codicenucleo)
  )
  </code></pre>
  <p>throw error</p>
  <pre><code>An exception occurred while executing 'INSERT INTO datinuclei (id, tiponucleo, codicenucleo, nome, cognome, codicefiscale, ncomponenti, indirizzoutenza, civico, mail, telefono, cellulare, proprietario, foglio, particella, sub, categoria, idcomune) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [null, 1, &quot;abcdefgi123&quot;, &quot;wefqwe&quot;, &quot;fqweff&quot;, &quot;qwefqew&quot;, 23, &quot;awefq&quot;, &quot;2&quot;, &quot;qweff@\u00e6we.it&quot;, &quot;1234123&quot;, &quot;1234123&quot;, null, &quot;63&quot;, &quot;3&quot;, null, null, 3]:
  
  SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column &quot;id&quot; violates not-null constraint
  DETAIL: Failing row contains (null, 3, fqweff, wefqwe, 23, 1234123, 1234123, qweff@æwe.it, qwefqew, abcdefgi123, 1, f, f, null, awefq, 2, 0, null, 63, 3, null, null). 
  </code></pre>
  <p>controller where i save data</p>
  <pre><code>    if ($form-&gt;isSubmitted()) {
          if ($form-&gt;isValid()) {
  
              $nucleo = $form-&gt;getData();
              $nucleo-&gt;setCodiceNucleo('abcdefgi123');
  
              dump($nucleo);
              $em-&gt;persist($nucleo);
              $em-&gt;flush();
  
              $this-&gt;addFlash('success', 'Nucleo modificato correttamente');
  
              //return $this-&gt;redirectToRoute('admin_article_list');
          }else {
              $this-&gt;addFlash('danger', 'Dati non validi');
          }
      }
  </code></pre>
  <p>I try to user <code>@ORM\GeneratedValue(strategy=&quot;SEQUENCE&quot;)</code> and <code>IDENTITY</code> on the column <code>ID</code> but same error persist, anyone?</p>
  <p><strong>Edit:</strong> <strong>After some tests i understand the problem is related to Nucleistatistiche OneToOne relationship but i don't know how to solve</strong></p>