title: Doctrine2 Migration - single table inheritance - parent id does not exist
body: <p>I don't get a simple table inheritance to work in my blog.</p>
  
  <p>Here is what I have:</p>
  
  <p>3 simple classes</p>
  
  <ol>
  <li>A general abstract Comment Class </li>
  <li>Subclass for comments made to blog posts with a foreign key to one</li>
  <li>Subclass for comments on activities also with an foreign key</li>
  </ol>
  
  <p><strong>General Comment Entity</strong></p>
  
  <pre><code>/**
   * @ORM\MappedSuperClass
   * @ORM\Entity(repositoryClass="MY\BlogBundle\Entity\Repository\CommentRepository")
   * @ORM\Table(name="blog_comment")
   * @ORM\InheritanceType("SINGLE_TABLE")
   * @ORM\DiscriminatorColumn(name="type", type="string")
   * @ORM\DiscriminatorMap( {"blogentry" = "BlogComment", "activity" = "ActivityComment"} )
   * @ORM\HasLifecycleCallbacks
   */
  abstract class Comment
  {
      /**
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @ORM\Column(name="title", type="string", length=255, nullable=true)
       * @Assert\NotBlank()
       */
      private $title;
      ...
  </code></pre>
  
  <p><strong>Comment for Blog</strong></p>
  
  <pre><code>/**
   * BlogEntryComment
   * @ORM\Entity(repositoryClass="MY\BlogBundle\Entity\Repository\BlogEntryCommentRepository")
   */
  class BlogComment extends Comment
  {
  
  /**
   * @ORM\ManyToOne(targetEntity="MY\BlogBundle\Entity\BlogEntry", inversedBy="comments")
   * @ORM\JoinColumn(name="blog_entry_id", referencedColumnName="id", onDelete="CASCADE", nullable=true)
   */
   private $blogEntry;
   ...
  </code></pre>
  
  <p><strong>Comment for Activity</strong></p>
  
  <pre><code>/**
   * @ORM\Entity(repositoryClass="MY\BlogBundle\Entity\Repository\ActivityCommentRepository")
   */
  class ActivityComment extends Comment
  {
  /**
   * @ORM\ManyToOne(targetEntity="MY\BlogBundle\Entity\Activity", inversedBy="comments")
   * @ORM\JoinColumn(name="activity_id", referencedColumnName="id", onDelete="CASCADE", nullable=true)
   */
   private $activity;
   ...
  </code></pre>
  
  <p>Building all entities with </p>
  
  <pre><code>./app/console doctrine:generate:entities MY
  </code></pre>
  
  <p><em>works fine</em>, this means that super class methods like <code>getId()</code> will be automatically be inserted into <code>Comment</code> class. </p>
  
  <p>And the only functions inside sub-classes are setter and getter for their own properties like <code>getBlogEntry()</code> or <code>getActivity()</code></p>
  
  <p>When I finally try to create a migration to update the database I get:</p>
  
  <pre><code>    ./app/console doctrine:migrations:diff -vvv                                                        
  
    [ReflectionException]                                                    
    Property MY\BlogBundle\Entity\ActivityComment::$id does not exist  
  
  Exception trace:
   () at MY_PATH/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php:79
   ReflectionProperty-&gt;__construct() at MY_PATH/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php:79
   Doctrine\Common\Persistence\Mapping\RuntimeReflectionService-&gt;getAccessibleProperty() at MY_PATH/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:889
   Doctrine\ORM\Mapping\ClassMetadataInfo-&gt;wakeupReflection() at MY_PATH/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:537
   Doctrine\ORM\Mapping\ClassMetadataFactory-&gt;wakeupReflection() at MY_PATH/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:209
   Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;getMetadataFor() at MY_PATH/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:114
   Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory-&gt;getAllMetadata() at MY_PATH/vendor/doctrine/migrations/lib/Doctrine/DBAL/Migrations/Tools/Console/Command/DiffCommand.php:68
   Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand-&gt;execute() at MY_PATH/vendor/doctrine/doctrine-migrations-bundle/Doctrine/Bundle/MigrationsBundle/Command/MigrationsDiffDoctrineCommand.php:49
   Doctrine\Bundle\MigrationsBundle\Command\MigrationsDiffDoctrineCommand-&gt;execute() at MY_PATH/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:252
   Symfony\Component\Console\Command\Command-&gt;run() at MY_PATH/vendor/symfony/console/Symfony/Component/Console/Application.php:900
   Symfony\Component\Console\Application-&gt;doRunCommand() at MY_PATH/vendor/symfony/console/Symfony/Component/Console/Application.php:192
   Symfony\Component\Console\Application-&gt;doRun() at MY_PATH/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
   Symfony\Bundle\FrameworkBundle\Console\Application-&gt;doRun() at MY_PATH/vendor/symfony/console/Symfony/Component/Console/Application.php:123
   Symfony\Component\Console\Application-&gt;run() at MY_PATH/app/console:22
  </code></pre>
  
  <p>It will not find the id attribute of the sub class for some reasons. </p>
  
  <p>Changing access levels resulted in faulty code creation. If is set <code>$id</code> to <code>public</code> or <code>protected</code> will break the code generation using task <code>./app/console doctrine:generate:entities MY</code></p>
  
  <p>I know there have been numerous posts about this topic but nothing helped with my problem. I did:</p>
  
  <ul>
  <li>disabled all cache</li>
  <li>cleared cache every time OR even removed app/cache</li>
  <li>deleted all files and started from scratch</li>
  <li>included <code>@ORM\Table(name="blog_comment")</code> inside every sub-class</li>
  <li>tried different access level modifications</li>
  </ul>
  
  <p>Can someone point me to my problem or knows what could possibly causes this. I lost a whole workday on this disgusting problem.</p>