doctrine2 association is not initialized

后端 未结 4 1890
执笔经年
执笔经年 2020-12-16 06:33

I have a Class like the following:

/** @Entity **/
class orgGroup{

    //id and stuff...

    /**
     * @Column(type=\"string\")
     **/
    private $name         


        
4条回答
  •  失恋的感觉
    2020-12-16 07:24

    Be sure to initialize the orgGroups collection in the orgGroupType entity

    /**
     * @OneToMany(targetEntity="orgGroup", mappedBy="_orgGroupType")
     */
    protected $orgGroups ;
    
    public function __construct() {
        $this->orgGroups = new ArrayCollection();
    }
    

    You might need to include the following in the Entity

    use Doctrine\Common\Collections\Collection,
    Doctrine\Common\Collections\ArrayCollection;
    

提交回复
热议问题