学说 - 映射不起作用

时间:2015-10-11 20:53:16

标签: php orm doctrine-orm mapping

我对Doctrine映射有问题。首先,我将介绍我的两个参与者:

/**
* @ORM\Entity
* @ORM\Table(name="header_fotos")
*/

class HeaderFoto extends BaseEntity{

    ....    

    /**
     * 
     * @ORM\Column(type="integer") 
     * @ORM\ManyToOne(targetEntity="\App\Webpage\Webpage", inversedBy="headerFotos")
     * @ORM\JoinColumn(name="webpage_id", referencedColumnName="id")
     */
    protected $webpage;

    ...
}

第二实体:

/**
 * @ORM\Entity
 * @ORM\Table(name="webpages")
 */
class Webpage extends BaseEntity{
    ...

    /**
     * @ORM\OneToMany(targetEntity="\App\Webpage\HeaderFoto", mappedBy="webpage")
     */
    protected $headerFotos;

    public function __construct() {
        parent::__construct();

        $this->headerFotos = new ArrayCollection();
    }

我的问题在于映射。当我加载实体网页并尝试访问HeaderFoto类型的所有实体时,它找不到任何关系。我试图与Doctrine的另一个工作项目进行比较,一切都是一样的。

我试图改变双方与OneToOne的联系,这是肯定的。但在这种情况下,它返回了Exception没有为字段网页找到的映射。

我将感激您的每一个帮助和建议。谢谢你的帮助。

修改

更具体地说,它在方法 getOneToManyStatement 中的类 \ Doctrine \ ORM \ Persisters \ BasicEntityPersister.php 中存在问题。它尝试加载关联的对象,但此类中的数组 associationMappings 为空。这是我发现的最后一件事。

0 个答案:

没有答案
相关问题