0

假设我有 2 个实体。卡和用户。用户在 UserBundle 中,卡在 PublicBundle 中。

在用户中我有这个功能:

#namespace Kanban\UserBundle\Entity;
    /**
     * Add assignment
     *
     * @param \Kanban\PublicBundle\Entity\Card $assignment
     * @return User
     */
    public function addAssignment(\Kanban\PublicBundle\Entity\Card $assignment)
    {
        $this->assignment[] = $assignment;

        return $this;
    }

每次我执行这个命令:

php app/console doctrine:schema:update --dump-sql

它抛出这个错误:

    [Doctrine\ORM\Mapping\MappingException]                                                                    
  The target-entity Kanban\UserBundle\Entity\Card cannot be found in 'Kanban\UserBundle\Entity\User#assignm  
  ent'. 

我试过这样的说法:

use Kanban\PublicBundle\Entity;
use Kanban\PublicBundle\Entity\Card;

在文件的开头但显示相同的错误。关于我做错了什么的任何想法?

4

1 回答 1

1

纳米!,

orm.yml 文件有问题,已更改:

manyToMany:
    assignment:
        targetEntity: Card
        cascade: {  }
        mappedBy: customer
        inversedBy: null
        joinTable: null
        orderBy: null

进入

manyToMany:
    assignment:
        targetEntity: Kanban\PublicBundle\Entity\Card
        cascade: {  }
        mappedBy: customer
        inversedBy: null
        joinTable: null
        orderBy: null

这解决了问题!

于 2013-02-08T15:23:51.837 回答