title: Weird Doctrine ODM exception when using references together with inheritance
body: <p>I've got three classes. The File-Class has a reference to Foobar and Game inherits from Foobar. There are some other Classes which also inherit from Foobar but i left them out as they aren't relevant here. I also left out some unrelevant fields and their getters and setters.</p>
  
  <p>The plan is that every Game has two images, the mainImage and the secondaryImage. I've put those fields into a seperate class from which Game inherits because i need them for a few other classes too.</p>
  
  <p>My problem is that if I load the games from the database as soon as i try to iterate over them I get the following exception:</p>
  
  <blockquote>
    <p>Notice: Undefined index:  in C:\xampp\htdocs\Symfony\vendor\doctrine\mongodb-odm\lib\Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo.php line 1293 </p>
  </blockquote>
  
  <p>For reference here are the lines of ClassMetadataInfo.php</p>
  
  <pre><code>public function getPHPIdentifierValue($id)
  {
      $idType = $this-&gt;fieldMappings[$this-&gt;identifier]['type'];
      return Type::getType($idType)-&gt;convertToPHPValue($id);
  } 
  </code></pre>
  
  <p><strong>Here are my classes</strong></p>
  
  <p>File-Class:</p>
  
  <pre><code>namespace Project\MainBundle\Document;
  
  use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
  
  /**
   * @MongoDB\Document
   */
  class File
  {
  
      /**
       * @MongoDB\Id(strategy="INCREMENT")
       */
      protected $id;
  
      /**
       * @MongoDB\ReferenceOne(targetDocument="Foobar", inversedBy="mainImage")
       */
      private $mainImage;
  
      /**
       * @MongoDB\ReferenceOne(targetDocument="Foobar", inversedBy="secondaryImage")
       */
      private $secondaryImage;
  
  
  
      /**
       * Get id
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
  
      public function setMainImage($mainImage)
      {
          $this-&gt;mainImage = $mainImage;
          return $this;
      }
      public function getMainImage()
      {
          return $this-&gt;mainImage;
      }
  
  
      public function setSecondaryImage($secondaryImage)
      {
          $this-&gt;secondaryImage = $secondaryImage;
          return $this;
      }
      public function getSecondaryImage()
      {
      return $this-&gt;secondaryImage;
      }
  
  
  }
  </code></pre>
  
  <p>Foobar-Class:</p>
  
  <pre><code>namespace Project\MainBundle\Document;
  
  use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
  
  /**
   * @MongoDB\MappedSuperclass
   */
  abstract class Foobar
  {
  
      /**
       * @MongoDB\Id(strategy="INCREMENT")
       */
      protected $id;
  
  
  
      /**
       * @MongoDB\ReferenceOne(targetDocument="File", mappedBy="mainImage")
       */
      protected $mainImage;
  
      /**
       * @MongoDB\ReferenceOne(targetDocument="File", mappedBy="secondaryImage")
       */
      protected $secondaryImage;
  
  
  
      /**
       * Get id
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
  
      /**
       * Set mainImage
       */
      public function setMainImage($file)
      {
          $file-&gt;setMainImage($this);
          $this-&gt;mainImage = $file;
          return $this;
      }
      /**
       * Get mainImage
       */
      public function getMainImage()
      {
          return $this-&gt;mainImage;
      }
  
  
      /**
       * Set secondaryImage
       */
      public function setSecondaryImage($file)
      {
          $file-&gt;setSecondaryImage($this);
          $this-&gt;secondaryImage = $file;
          return $this;
      }
      /**
       * Get secondaryImage
       */
      public function getSecondaryImage()
      {
          return $this-&gt;secondaryImage;
      }
  
  
  }
  </code></pre>
  
  <p>Game-Class:</p>
  
  <pre><code>namespace Project\MainBundle\Document;
  
  use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
  
  /**
   * @MongoDB\Document
   */
  class Game extends Foobar
  {
  
      /**
       * @MongoDB\String
       */
      private $name;
  
  
  
      /**
       * Set name
       */
      public function setName($name)
      {
          $this-&gt;name = $name;
          return $this;
      }
      /**
       * Get name
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  
  
  }
  </code></pre>
  
  <p>Though it doesn't really matter but here is my function i want to execute:</p>
  
  <pre><code>    $dm = $this-&gt;get('doctrine_mongodb')-&gt;getManager();
  
      $games_all = $dm-&gt;getRepository("ProjectMainBundle:Game")-&gt;createQueryBuilder()-&gt;sort('id', 'ASC')-&gt;getQuery()-&gt;execute();
  
      foreach ($games_all as $singlegame) { // it breaks here
          // Here i would do stuff
      }
  </code></pre>
  
  <p>Is this a bug in Doctrine ODM or am I doing something wrong? Are the classes correct? I have tried everything but it just wont work.</p>