实体类映射无效 [英] Entity class mapping is invalid

查看:55
本文介绍了实体类映射无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试在 Page 和 Block 表之间创建 OneToMany 关系,但在验证架构时出现以下错误:

Hi i am trying to create a OneToMany relationship between Page and Block tables but i am getting the following error on validating the schema:

[Mapping]  FAIL - The entity-class 'mypath\Entity\Block' mapping is invalid:
* The association mypath\Entity\Block#pages refers to the inverse side field     mypath\Entity\Page#blocks which does not exist.

[Mapping]  FAIL - The entity-class 'mypath\Entity\Page' mapping is invalid:
* The association mypath\Entity\Page#block refers to the owning side field     mypath\Entity\Block#page which does not exist.

以下是我的页面和块实体

Following are my page and Block Entities

页面:

/**
* @ORM\OneToMany(targetEntity="Block", mappedBy="page")
*/
private $block;

阻止:

/**
* @ORM\ManyToOne(targetEntity="Page", inversedBy="block")
* @ORM\JoinColumn(referencedColumnName="id")
*/
private $pages;

我不确定它有什么问题,但似乎与注释有关.请帮忙,谢谢!!!

I am not sure what wrong with it but seems to be something related to annotations. Please help, Thanks !!!

推荐答案

在注释中,您将属性称为块"和页面",但在实际代码中将它们称为块"和页面".

In the annotation, you call the properties "blocks and "page", but they're called "block" and "pages" in the actual code.

页面:

/**
* @ORM\OneToMany(targetEntity="Block", mappedBy="page")
*/
private $blocks;

阻止:

/**
* @ORM\ManyToOne(targetEntity="Page", inversedBy="blocks")
*/
private $page;

这篇关于实体类映射无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆