Object object cannot be found in

I use Symfony 2.3, and I get this exception when I try to list projects:

The target-entity Weber\ProjectBundle\Entity\SurveyUrl cannot be found in 'Weber\ProjectBundle\Entity\Project#surveyUrls'. 

Simplification of my objects:

Project.php:

 <?php namespace Weber\ProjectBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; /** * Project * * @ORM\Entity */ class Project { /** * @var integer * * @ORM\Id * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @ORM\OneToMany(targetEntity="Respondent", mappedBy="project") */ protected $respondents; /** * @ORM\OneToMany(targetEntity="SurveyUrl", mappedBy="project") */ protected $surveyUrls; /** * Constructor */ public function __construct() { $this->respondents = new ArrayCollection(); $this->surveyUrls = new ArrayCollection(); } /** * Add respondents * * @param \Weber\ProjectBundle\Entity\Respondent $respondents * @return Project */ public function addRespondent(\Weber\ProjectBundle\Entity\Respondent $respondents) { $this->respondents[] = $respondents; return $this; } /** * Remove respondents * * @param \Weber\ProjectBundle\Entity\Respondent $respondents */ public function removeRespondent(\Weber\ProjectBundle\Entity\Respondent $respondents) { $this->respondents->removeElement($respondents); } /** * Get respondents * * @return \Doctrine\Common\Collections\Collection */ public function getRespondents() { return $this->respondents; } /** * Add surveyUrls * * @param \Weber\ProjectBundle\Entity\SurveyUrl $surveyUrls * @return Project */ public function addSurveyUrl(\Weber\ProjectBundle\Entity\SurveyUrl $surveyUrls) { $this->surveyUrls[] = $surveyUrls; return $this; } /** * Remove surveyUrls * * @param \Weber\ProjectBundle\Entity\SurveyUrl $surveyUrls */ public function removeSurveyUrl(\Weber\ProjectBundle\Entity\SurveyUrl $surveyUrls) { $this->surveyUrls->removeElement($surveyUrls); } /** * Get surveyUrls * * @return \Doctrine\Common\Collections\Collection */ public function getSurveyUrls() { return $this->surveyUrls; } } 

Respondent.php:

 <?php namespace Weber\ProjectBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * Respondent * * @ORM\Entity */ class Respondent { /** * @var integer * * @ORM\Id * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @ORM\ManyToOne(targetEntity="Project") */ protected $project; /** * Set project * * @param \Weber\ProjectBundle\Entity\Project $project * @return Respondent */ public function setProject(\Weber\ProjectBundle\Entity\Project $project = null) { $this->project = $project; return $this; } /** * Get project * * @return \Weber\ProjectBundle\Entity\Project */ public function getProject() { return $this->project; } } 

and SurveyUrl.php:

 <?php namespace Weber\ProjectBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * SurveyURL * * @ORM\Entity */ class SurveyURL { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * The project for this url. * * @ORM\ManyToOne(targetEntity="Project", inversedBy="surveyUrls") * (I have also tried without 'inversedBy') */ protected $project; /** * May be null. * The respondent that answered this survey. * * @ORM\OneToOne(targetEntity="Respondent") */ protected $respondent; /** * Set project * * @param \Weber\ProjectBundle\Entity\Project $project * @return SurveyURL */ public function setProject(\Weber\ProjectBundle\Entity\Project $project = null) { $this->project = $project; return $this; } /** * Get project * * @return \Weber\ProjectBundle\Entity\Project */ public function getProject() { return $this->project; } /** * Set respondent * * @param \Weber\ProjectBundle\Entity\Respondent $respondent * @return SurveyURL */ public function setRespondent(\Weber\ProjectBundle\Entity\Respondent $respondent = null) { $this->respondent = $respondent; return $this; } /** * Get respondent * * @return \Weber\ProjectBundle\Entity\Respondent */ public function getRespondent() { return $this->respondent; } } 

I do not understand that before I created the SurveyUrl object, there were no problems at all, and both objects are almost identical in configuration.

Thanks for any help.

+4
source share
1 answer

You have an error in the project object:

 /** * @ORM\OneToMany(targetEntity="SurveyUrl", mappedBy="project") */ protected $surveyUrls; 

targetEntity = "SurveyUrl" should be replaced targetEntity = "SurveyURL"

You must match your case.

+5
source

Source: https://habr.com/ru/post/1489934/


All Articles