EntityNotFoundException in doctrine 2 proxy classes

What are the possible causes of an EntityNotFoundException when accessing proxy class properties in doctrine 2? In any case, the structure of my entities is as follows:

/**
 * @ORM\Table(name="comments")
 *
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="comment_type", type="smallint")
 * @ORM\DiscriminatorMap({
 *    1 = "VisitorComment",
 *    2 = "MemberComment"
 * })
 */
 class Comment
 {
    //with common properties of its subclasses
 }
Subclasses

:

/**
 * @ORM\Table(name="member_comments")
 */
class MemberComment extends Comment
{
    /**
     * owning side
     *
     * @var Member $author
     * 
     * @ORM\ManyToOne(targetEntity="Member")
     * @ORM\JoinColumn(name="author_id", referencedColumnName="id", nullable=false)
     */
     private $author;

    /**
     * Set author
     *
     * @param Member $author
     */
    public function setAuthor($author)
    {
        $this->author = $author;
    }

    /**
     * Get author
     *
     * @return Member
     */
    public function getAuthor()
    {
        return $this->author;
    }
}


/**
 * @ORM\Table(name="visitor_comments")
 */
class VisitorComment extends Comment
{
   /**
    * owning side
    *
    * @var Visitor $author
    * 
    * @ORM\ManyToOne(targetEntity="Visitor")
    * @ORM\JoinColumn(name="author_id", referencedColumnName="id", nullable=false)
    */
    private $author;

    /**
     * Set author
     *
     * @param string $author
     */
     public function setAuthor($author)
     {
        $this->author = $author;
     }

    /**
     * Get author
     *
     * @return Visitor
     */
    public function getAuthor()
    {
        return $this->author;
    }
}

An exception occurs when I call $ comment-> getAuthor () → getFirstName () <assuming that the author, which is a Member or Visitor object, has the firstName> property. GetAuthor () in this case returns the proxy class of either VisitorProxy or MemberProxy.

Please help me. I am still not familiar with the doctrine.

+5
source share
2 answers

As Floricel found out, this could be caused by an invalid foreign key in a column that points to a table that references the Proxy class.

+2

@Dave Lancea , FK, Null, , , .

0

All Articles