MappingException:目标实体"实体"在&x; xxx \ Entity \ User#nhpProductIds'中找不到

时间:2014-04-29 18:46:32

标签: symfony doctrine mapping entity

我的生产服务器上只有一个奇怪的问题,映射似乎不正确。它在我的开发服务器上工作 - 它们都是最新的git。

这是我正在制作的错误:

[Doctrine\ORM\Mapping\MappingException]
The target-entity Shawmut\ClientBundle\Entity\NHPProductId cannot be found in 'Shawmut\ClientBundle\Entity\User#nhpProductIds'.

来自我的实体\ NHPProductId:

/**
 * @ORM\ManyToOne(targetEntity="User", inversedBy="nhpProductIds")
 * @ORM\JoinColumn(name="nhp_product_id_users", referencedColumnName="id")
 **/
protected $user;

来自我的实体\用户:

/**
 * @ORM\OneToMany(targetEntity="NHPProductId", mappedBy="user")
 **/
protected $nhpProductIds;

有谁能想到这里出了什么问题?

编辑:我能够通过将我的实体重命名为 ProductId 而不是NHPProductId来解决这个问题。我不知道为什么这会导致实体无法加载,但这就是修复。

1 个答案:

答案 0 :(得分:1)

这最终归因于我的实体名称。通过将其重命名为NhpProductId,问题就消失了。