0
내 데이터 픽스처의 rootCommunication에 통신 파트를 추가하려고하면 오류가 없지만 데이터베이스 필드 'root_communication_id'에 NULL 만있다. 왜? 제 모델 '통신'자체 참조 엔티티에 관계를 저장할 수 없다.
/**
* Communication
*
* @ORM\Table(name="communication")
* @ORM\Entity(repositoryClass="Mother\BaseBundle\Entity\Repository\CommunicationRepository")
*/
class Communication
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="message", type="text", nullable=true)
*/
private $message;
/**
* @ORM\ManyToOne(targetEntity="Communication", inversedBy="childrenCommunication", cascade={"persist"})
* @ORM\JoinColumn(name="root_communication_id", referencedColumnName="id", nullable=true)
*
*/
private $rootCommunication;
/**
* @ORM\OneToMany(targetEntity="Communication", mappedBy="rootCommunication")
*
*/
private $childrenCommunication;
} 제 데이터 조명기에서
의
부품 이런 secound 조명기에 난 childrenCommunication을 추가 데이터베이스 세 통신을 첨가 rootCommunication.
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager){
$contentRepo = $this->container->get('doctrine')->getManager()->getRepository('MotherBaseBundle:Communication');
$communication1 = $contentRepo->find($this->getReference('communication1')->getId());
$communication1->addChildrenCommunication($this->getReference('communication2'));
$communication1->addChildrenCommunication($this->getReference('communication3'));
$manager->persist($communication1);
$manager->flush();
}