Quali sono le possibili cause di EntityNotFoundException durante l'accesso alle proprietà della classe proxy in doctrine 2? In ogni caso, il seguente è la struttura i miei entita:EntityNotFoundException in doctrine 2 classe proxy
/**
* @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
}
sottoclassi sono i seguenti:
/**
* @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;
}
}
L'eccezione si verifica quando chiamo $ comment-> getAuthor() -> getFirstName() < assumendo l'autore che è un'entità membro o visitatore ha proprietà firstName>. GetAuthor() in questo caso restituisce una classe proxy di VisitorProxy o MemberProxy.
Gentilmente aiutatemi. Sono ancora nuovo alla dottrina.
È stata colpa mia. Dal momento che aggiungo ancora manualmente i miei dati nel database, ho erroneamente scambiato il visitatore con il commento del membro e con il commento del visitatore come autore. – Floricel