У меня есть две сущности с именами UserCode и Question, которые имеют отношение между столбцами вопросов, и когда я запускаю doctrine:schema:validate
, это нормально, но моя проблема в том, когда я добавляю
@ORM\Entity(repositoryClass="AppBundle\Repository\UserCodeRepository")
поверх сущности UserCode, которую я получаюэта ошибка !!
* The association AppBundle\Entity\UserCode#question refers to the inverse side field AppBundle\Entity\Question#question which is not defined as association.
* The association AppBundle\Entity\UserCode#question refers to the inverse side field AppBundle\Entity\Question#question which does not exist.
Объект сущности:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use AppBundle\Entity\UserCode;
/**
* Question
*
* @ORM\Table(name="question")
* @ORM\Entity(repositoryClass="AppBundle\Repository\QuestionRepository")
*/
class Question
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="question", type="text")
* @ORM\OneToMany(targetEntity="AppBundle\Entity\UserCode", mappedBy="question")
*/
private $question;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set question
*
* @param string $question
*
* @return Question
*/
public function setQuestion($question)
{
$this->question = $question;
return $this;
}
/**
* Get question
*
* @return string
*/
public function getQuestion()
{
return $this->question;
}
}
, и это моя сущность UserCode:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\JoinColumn;
use Symfony\Component\Validator\Constraints as Assert;
/**
* UserCode
*
* @ORM\Table(name="user_code")
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserCodeRepository")
*/
class UserCode
{
/**
* @var int
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Question", inversedBy="question")
* @ORM\JoinColumn(name="question", referencedColumnName="id")
*/
private $question;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set question
*
* @param \AppBundle\Entity\Question $question
*
* @return UserCode
*/
public function setQuestion(\AppBundle\Entity\Question $question = null)
{
$this->question = $question;
return $this;
}
/**
* Get question
*
* @return \AppBundle\Entity\Question
*/
public function getQuestion()
{
return $this->question;
}
}