2017-07-18 68 views
0

我有beetween“地段”和“BailProprietaire”一个多对多关系多对多不听者正与虚拟财产

当我得到一个实体“BailProprietaire”,我看到的实体“大量”挂 但是当我实体 “地段”,我没有看到实体 “BailProprietaire” 链接

在lot.orm.yml,我有:

AppBundle\Entity\Lot: 
type: entity 
repositoryClass: AppBundle\Repository\LotRepository 
table: lot 
.... 
.... 
manyToMany: 
    bauxProprietaire: 
     targetEntity: BailProprietaire 
     mappedBy: lots 

在bailProprietaire.orm.yml,我有:

AppBundle\Entity\BailProprietaire: 
type: entity 
table: bail_proprietaire 
repositoryClass: AppBundle\Repository\BailProprietaireRepository 
.... 
.... 
manyToMany: 
    lots: 
     targetEntity: Lot 
     inversedBy: bauxProprietaire 
     fetch: LAZY 
     joinTable: 
      name: bail_proprietaire_lots 
      joinColumns: 
       bail_id: 
        referencedColumnName: id 
      inverseJoinColumns: 
       lot_id: 
        referencedColumnName: id 
lifecycleCallbacks: { } 

你看到我想念的东西吗?

感谢

编辑:添加PHP代码实体

Lot.php

class Lot 
{ 
    /** 
    * @var integer 
    */ 
    private $id; 



    /** 
    * @var \Doctrine\Common\Collections\Collection 
    */ 
    private $bauxProprietaire; 


    /** 
    * Constructor 
    */ 
    public function __construct() 
    { 
     $this->bauxProprietaire = new ArrayCollection(); 
    } 


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





    /** 
    * Add bauxProprietaire 
    * 
    * @param \AppBundle\Entity\BailProprietaire $bauxProprietaire 
    * 
    * @return Lot 
    */ 
    public function addBauxProprietaire(\AppBundle\Entity\BailProprietaire $bauxProprietaire) 
    { 
     $this->bauxProprietaire[] = $bauxProprietaire; 

     return $this; 
    } 

    /** 
    * Remove bauxProprietaire 
    * 
    * @param \AppBundle\Entity\BailProprietaire $bauxProprietaire 
    */ 
    public function removeBauxProprietaire(\AppBundle\Entity\BailProprietaire $bauxProprietaire) 
    { 
     $this->bauxProprietaire->removeElement($bauxProprietaire); 
    } 

    /** 
    * Get bauxProprietaire 
    * 
    * @return \Doctrine\Common\Collections\Collection 
    */ 
    public function getBauxProprietaire() 
    { 
     return $this->bauxProprietaire; 
    } 


} 

BailProprietaire.php

class BailProprietaire 
{ 


    /** 
    * @var integer 
    */ 
    private $id; 


    /** 
    * @var \Doctrine\Common\Collections\Collection 
    */ 
    private $lots; 

    /** 
    * Constructor 
    */ 
    public function __construct() 
    { 
     $this->lots = new \Doctrine\Common\Collections\ArrayCollection(); 
    } 

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



    /** 
    * Add lot 
    * 
    * @param \AppBundle\Entity\Lot $lot 
    * 
    * @return BailProprietaire 
    */ 
    public function addLot(\AppBundle\Entity\Lot $lot) 
    { 
     $this->lots[] = $lot; 

     return $this; 
    } 

    /** 
    * Remove lot 
    * 
    * @param \AppBundle\Entity\Lot $lot 
    */ 
    public function removeLot(\AppBundle\Entity\Lot $lot) 
    { 
     $this->lots->removeElement($lot); 
    } 

    /** 
    * Get lots 
    * 
    * @return \Doctrine\Common\Collections\Collection 
    */ 
    public function getLots() 
    { 
     return $this->lots; 
    } 

} 

编辑2:其实,它的工作原理,但不与聆听者

事实上,当我得到“很多”时,我看到实体“BailProprietaire”,但当我刷新数据时,我有一个监听器。在这个监听器,我称之为“Lot.php”的虚拟propertie我哪里有:

if (!empty($this->bauxProprietaire)) { 
     .... 
    } else { 
     .... 
    } 

但$这个 - > bauxProprietaire总是空

+0

你能告诉我们你的PHP代码的实体? –

回答

0

好吧,我发现这个问题。

当我做这 - $> bauxProprietaire,我有一个“学说\ ORM \ PersistentCollection”但是当我在看该对象的集合,有0元 enter image description here

,但如果我做这 - $ > bauxProprietaire->指定者(),我看到我的关系

我不明白为什么,但它的工作原理