title: DoctrineORM -> OutOfBoundsException -> Missing value for primary key id
body: <p>I am using <code>Doctrine</code> ORM with <code>CodeIgniter</code>. Error looks like this;</p>
  <blockquote>
  <p>An uncaught Exception was encountered</p>
  <p>Type: Doctrine\Common\Proxy\Exception\OutOfBoundsException</p>
  Message: Missing value for primary key id on TestDoor</p>
  Filename: &gt;/home/qualesof/hotel.qualesoft.com/application/libraries/Doctrine/Common/Proxy/Exception/OutOfBoundsException.php</p>
  Line Number: 40</p></p>
  </blockquote>
  <p><strong>Class TestRoom</strong></p>
  <pre><code>&lt;?php
  
  require_once(APPPATH . &quot;models/Entities/TestDoor.php&quot;);
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * TestRoom
   *
   * @ORM\Table(name=&quot;test_room&quot;, indexes={@ORM\Index(name=&quot;test_door_code&quot;, columns={&quot;test_door_code&quot;})})
   * @ORM\Entity
   */
  class TestRoom implements JsonSerializable
  {
      public function jsonSerialize()
      {
          return get_object_vars($this);
      }
      /**
       * @var integer
       *
       * @ORM\Column(name=&quot;id&quot;, type=&quot;integer&quot;, nullable=false)
       * @ORM\Id
       * @ORM\GeneratedValue(strategy=&quot;IDENTITY&quot;)
       */
      private $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name=&quot;name&quot;, type=&quot;string&quot;, length=255, nullable=false)
       */
      private $name;
  
      /**
       * @var \TestDoor
       *
       * @ORM\ManyToOne(targetEntity=&quot;TestDoor&quot;)
       * @ORM\JoinColumns({
       *   @ORM\JoinColumn(name=&quot;test_door_code&quot;, referencedColumnName=&quot;code&quot;)
       * })
       */
      private $testDoorCode;
  
  
      /**
       * Get id
       *
       * @return integer
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set name
       *
       * @param string $name
       *
       * @return TestRoom
       */
      public function setName($name)
      {
          $this-&gt;name = $name;
  
          return $this;
      }
  
      /**
       * Get name
       *
       * @return string
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  
      /**
       * Set testDoorCode
       *
       * @param \TestDoor $testDoorCode
       *
       * @return TestRoom
       */
      public function setTestDoorCode(\TestDoor $testDoorCode = null)
      {
          $this-&gt;testDoorCode = $testDoorCode;
  
          return $this;
      }
  
      /**
       * Get testDoorCode
       *
       * @return \TestDoor
       */
      public function getTestDoorCode()
      {
          return $this-&gt;testDoorCode;
      }
  }
  </code></pre>
  <p><strong>Class TestDoor</strong></p>
  <pre><code>&lt;?php
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * TestDoor
   *
   * @ORM\Table(name=&quot;test_door&quot;, uniqueConstraints={@ORM\UniqueConstraint(name=&quot;code&quot;, columns={&quot;code&quot;})})
   * @ORM\Entity
   */
  class TestDoor implements JsonSerializable
  {
      public function jsonSerialize()
      {
          return get_object_vars($this);
      }
      /**
       * @var integer
       *
       * @ORM\Column(name=&quot;id&quot;, type=&quot;integer&quot;, nullable=false)
       * @ORM\Id
       * @ORM\GeneratedValue(strategy=&quot;IDENTITY&quot;)
       */
      private $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name=&quot;code&quot;, type=&quot;string&quot;, length=3, nullable=false)
       */
      private $code;
  
      /**
       * @var boolean
       *
       * @ORM\Column(name=&quot;all_included&quot;, type=&quot;boolean&quot;, nullable=false)
       */
      private $allIncluded;
  
  
      /**
       * Get id
       *
       * @return integer
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set code
       *
       * @param string $code
       *
       * @return TestDoor
       */
      public function setCode($code)
      {
          $this-&gt;code = $code;
  
          return $this;
      }
  
      /**
       * Get code
       *
       * @return string
       */
      public function getCode()
      {
          return $this-&gt;code;
      }
  
      /**
       * Set allIncluded
       *
       * @param boolean $allIncluded
       *
       * @return TestDoor
       */
      public function setAllIncluded($allIncluded)
      {
          $this-&gt;allIncluded = $allIncluded;
  
          return $this;
      }
  
      /**
       * Get allIncluded
       *
       * @return boolean
       */
      public function getAllIncluded()
      {
          return $this-&gt;allIncluded;
      }
  }
  </code></pre>