2014-03-07 101 views
0

我在我的实体之间有多对一的关系。 一个应用程序可以有活动ManyToOne关系Symfony2

<?php 

namespace AppAcademic\ApplicationBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 

/** 
* Activity 
* 
* @ORM\Table() 
* @ORM\Entity 
*/ 
class Activity 
{ 
    /** 
    * @var integer 
    * 
    * @ORM\Column(name="id", type="integer") 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

    /** 
    * @ORM\ManyToOne(targetEntity="AppAcademic\ApplicationBundle\Entity\Application", inversedBy="activity") 
    * @ORM\JoinColumn(name="application_id", referencedColumnName="id", onDelete="CASCADE") 
    */ 
    private $application; 

    /** 
    * @var string 
    * 
    * @ORM\Column(name="title", type="string", length=255) 
    */ 
    private $title; 



    /** 
    * Get id 
    * 
    * @return integer 
    */ 
    public function getId() 
    { 
     return $this->id; 
    } 


    public function setApplication($application) 
    { 
     $this->application = $application; 

     return $this; 
    } 


    public function getApplication() 
    { 
     return $this->application; 
    } 

    /** 
    * Set title 
    * 
    * @param string $title 
    * @return Activity 
    */ 
    public function setTitle($title) 
    { 
     $this->title = $title; 

     return $this; 
    } 

    /** 
    * Get title 
    * 
    * @return string 
    */ 
    public function getTitle() 
    { 
     return $this->title; 
    } 


} 

和应用

/** 
* Application 
* 
* @ORM\Table() 
* @ORM\Entity(repositoryClass="AppAcademic\ApplicationBundle\Entity\ApplicationRepository") 
*/ 
class Application 
{ 
    /** 
    * @var integer 
    * 
    * @ORM\Column(name="id", type="integer") 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

    /** 
    * @ORM\OneToMany(targetEntity="AppAcademic\ApplicationBundle\Entity\Activity", mappedBy="application") 
    */ 
    protected $activities; 

    ... 

} 

我有这样的探查:

AppAcademic\ApplicationBundle\Entity\Application  
The mappings AppAcademic\ApplicationBundle\Entity\Application#activities and AppAcademic\ApplicationBundle\Entity\Activity#application are inconsistent with each other. 
AppAcademic\ApplicationBundle\Entity\Application  
The mappings AppAcademic\ApplicationBundle\Entity\Application#activities and AppAcademic\ApplicationBundle\Entity\Activity#application are inconsistent with each other. 
AppAcademic\ApplicationBundle\Entity\Activity 
The association AppAcademic\ApplicationBundle\Entity\Activity#application refers to the inverse side field AppAcademic\ApplicationBundle\Entity\Application#activity which does not exist. 

回答

1

有关Activity::$application属性映射注释ManyToOne,属性

inversedBy="activity" 

这应该是

inversedBy="activities"