我有一个一对多的自引用实体。只要父值设置为空,一切正常。当我将父项设置为列表中实际的内容时,出现错误:
类整数不存在
500 内部服务器错误 - ReflectionException
这是我的实体的代码:
<?php
namespace WorkRecorder\WorkBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity(repositoryClass="WorkRecorder\WorkBundle\Repository\WorkRepository")
* @ORM\Table(name="strategyUsed")
*/
class StrategyUsed
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="integer")
*/
protected $sortOrder;
/**
* @ORM\Column(type="string", length=50)
*/
protected $name;
/**
* @ORM\Column(type="text")
*/
protected $description;
/**
* @ORM\OneToMany(targetEntity="StrategyUsed", mappedBy="parent")
*/
private $children;
/**
* @ORM\ManyToOne(targetEntity="StrategyUsed", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
private $parent;
public function __construct() {
$this->children = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set description
*
* @param text $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* Get description
*
* @return text
*/
public function getDescription()
{
return $this->description;
}
/**
* Set sortOrder
*
* @param integer $sortOrder
*/
public function setSortOrder(\integer $sortOrder)
{
$this->sortOrder = $sortOrder;
}
/**
* Get sortOrder
*
* @return integer
*/
public function getSortOrder()
{
return $this->sortOrder;
}
/**
* Add children
*
* @param WorkRecorder\WorkBundle\Entity\StrategyUsed $children
*/
public function addStrategyUsed(\WorkRecorder\WorkBundle\Entity\StrategyUsed $children)
{
$this->children[] = $children;
}
/**
* Get children
*
* @return Doctrine\Common\Collections\Collection
*/
public function getChildren()
{
return $this->children;
}
/**
* Set parent
*
* @param WorkRecorder\WorkBundle\Entity\StrategyUsed $parent
*/
public function setParent(\WorkRecorder\WorkBundle\Entity\StrategyUsed $parent)
{
$this->parent = $parent;
}
/**
* Get parent
*
* @return WorkRecorder\WorkBundle\Entity\StrategyUsed
*/
public function getParent()
{
return $this->parent;
}
}
我究竟做错了什么?