加载和声明的类名之间的大小写不匹配:“Doctrine \ ORM \ Mapping \ ManytoOne”vs“Doctrine \ ORM \ Mapping \ ManyToOne”

时间:2018-02-01 08:23:45

标签: symfony doctrine entity many-to-one

我收到加载和声明的类名之间的Case不匹配错误:“Doctrine \ ORM \ Mapping \ ManytoOne”vs“Doctrine \ ORM \ Mapping \ ManyToOne”仅限用户实体。与其他实体相同的代码工作正常。

这是我的Comp Entity

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Comp
 *
 * @ORM\Table(name="comp")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\CompanyRepository")
 */
class Comp
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var integer
     * @ORM\ManytoOne(targetEntity="User")
     * @ORM\JoinColumn(name="user_id",referencedColumnName="id", nullable=true)
     */
    private $user;

我的用户实体

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * User
 *
 * @ORM\Table(name="user")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
 */
class User extends BaseUser
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=255)
     */
    private $name;

我得错了 加载和声明的类名之间的大小写不匹配:“Doctrine \ ORM \ Mapping \ ManytoOne”vs“Doctrine \ ORM \ Mapping \ ManyToOne”

更新架构时

相同的代码是与其他实体一起工作的文件。我设法制作外键。无法理解仅用户字段出现的问题。

1 个答案:

答案 0 :(得分:1)

尝试改变这个:

* @ORM\ManytoOne(targetEntity="User")

到此:

* @ORM\ManyToOne(targetEntity="User")

注释区分大小写,因此您检索错误