I tried to find this error, but the fact that I did not find anything leads me to believe that I am doing something stupid. I will include the appropriate code below, but I mainly use multiple table inheritance (or Class Inheritance ) and try to use the Doctrine ORM findBy () to query based on the discriminator column, resulting in the following ORMException: "Unrecognized field: type".
Here is the code that throws the exception:
// $this->em is an instance of \Doctrine\ORM\EntityManager $repository = $this->em->getRepository('JoeCommentBundle:Thread'); return $repository->findOneBy(array( 'type' => $this->type, 'related_id' => $id ));
Here is the appropriate code for the abstract entity "base":
<?php namespace Joe\Bundle\CommentBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use Doctrine\Common\Collections\ArrayCollection; abstract class Thread { protected $id; protected $relatedId;
And finally, here is the code for a specific thread object:
<?php namespace Joe\Bundle\StoryBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Joe\Bundle\CommentBundle\Entity\Thread as AbstractThread; class StoryThread extends AbstractThread { protected $story; }
I double checked my schema and the type
column definitely exists, so I'm not sure what could be causing this. Any ideas? Thanks.
source share