在以下位置找不到目标实体

昌哥

我正在使用Symfony 2.3,并且在尝试列出项目时遇到此异常:

The target-entity Weber\ProjectBundle\Entity\SurveyUrl cannot be found in 'Weber\ProjectBundle\Entity\Project#surveyUrls'.

我的实体的简化为:

Project.php:

<?php

namespace Weber\ProjectBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;


/**
 * Project
 *
 * @ORM\Entity
 */
class Project
{
    /**
     * @var integer
     *
     * @ORM\Id
     * @ORM\Column(name="id", type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\OneToMany(targetEntity="Respondent", mappedBy="project")
     */
    protected $respondents;

    /**
     * @ORM\OneToMany(targetEntity="SurveyUrl", mappedBy="project")
     */
    protected $surveyUrls;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->respondents = new ArrayCollection();
        $this->surveyUrls = new ArrayCollection();
    }

    /**
     * Add respondents
     *
     * @param \Weber\ProjectBundle\Entity\Respondent $respondents
     * @return Project
     */
    public function addRespondent(\Weber\ProjectBundle\Entity\Respondent $respondents)
    {
        $this->respondents[] = $respondents;

        return $this;
    }

    /**
     * Remove respondents
     *
     * @param \Weber\ProjectBundle\Entity\Respondent $respondents
     */
    public function removeRespondent(\Weber\ProjectBundle\Entity\Respondent $respondents)
    {
        $this->respondents->removeElement($respondents);
    }

    /**
     * Get respondents
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getRespondents()
    {
        return $this->respondents;
    }

    /**
     * Add surveyUrls
     *
     * @param \Weber\ProjectBundle\Entity\SurveyUrl $surveyUrls
     * @return Project
     */
    public function addSurveyUrl(\Weber\ProjectBundle\Entity\SurveyUrl $surveyUrls)
    {
        $this->surveyUrls[] = $surveyUrls;

        return $this;
    }

    /**
     * Remove surveyUrls
     *
     * @param \Weber\ProjectBundle\Entity\SurveyUrl $surveyUrls
     */
    public function removeSurveyUrl(\Weber\ProjectBundle\Entity\SurveyUrl $surveyUrls)
    {
        $this->surveyUrls->removeElement($surveyUrls);
    }

    /**
     * Get surveyUrls
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getSurveyUrls()
    {
        return $this->surveyUrls;
    }
}

Respondent.php:

<?php

namespace Weber\ProjectBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Respondent
 *
 * @ORM\Entity
 */
class Respondent
{
    /**
     * @var integer
     *
     * @ORM\Id
     * @ORM\Column(name="id", type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity="Project")
     */
    protected $project;

    /**
     * Set project
     *
     * @param \Weber\ProjectBundle\Entity\Project $project
     * @return Respondent
     */
    public function setProject(\Weber\ProjectBundle\Entity\Project $project = null)
    {
        $this->project = $project;

        return $this;
    }

    /**
     * Get project
     *
     * @return \Weber\ProjectBundle\Entity\Project 
     */
    public function getProject()
    {
        return $this->project;
    }
}

SurveyUrl.php:

<?php

namespace Weber\ProjectBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * SurveyURL
 *
 * @ORM\Entity
 */
class SurveyURL
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * The project for this url.
     *
     * @ORM\ManyToOne(targetEntity="Project", inversedBy="surveyUrls")
     * (I have also tried without 'inversedBy')
     */
    protected $project;

    /**
     * May be null.
     * The respondent that answered this survey.
     *
     * @ORM\OneToOne(targetEntity="Respondent")
     */
    protected $respondent;

    /**
     * Set project
     *
     * @param \Weber\ProjectBundle\Entity\Project $project
     * @return SurveyURL
     */
    public function setProject(\Weber\ProjectBundle\Entity\Project $project = null)
    {
        $this->project = $project;

        return $this;
    }

    /**
     * Get project
     *
     * @return \Weber\ProjectBundle\Entity\Project 
     */
    public function getProject()
    {
        return $this->project;
    }

    /**
     * Set respondent
     *
     * @param \Weber\ProjectBundle\Entity\Respondent $respondent
     * @return SurveyURL
     */
    public function setRespondent(\Weber\ProjectBundle\Entity\Respondent $respondent = null)
    {
        $this->respondent = $respondent;

        return $this;
    }

    /**
     * Get respondent
     *
     * @return \Weber\ProjectBundle\Entity\Respondent 
     */
    public function getRespondent()
    {
        return $this->respondent;
    }
}

我不明白的是,在创建SurveyUrl实体之前,根本没有问题,而且两个实体的配置几乎相同。

谢谢你的帮助。

皮克斯

您的项目实体中存在错误:

/**
 * @ORM\OneToMany(targetEntity="SurveyUrl", mappedBy="project")
 */
protected $surveyUrls;

targetEntity =“ SurveyUrl”必须替换为targetEntity =“ SurveyURL”

您必须匹配您的实体案例

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

IronPython实体框架6在以下位置找不到属性

来自分类Dev

在以下位置找不到名为“ pubspec.yaml”的文件

来自分类Dev

在以下位置找不到此颜色的声明

来自分类Dev

ReferenceError:找不到变量:在以下位置需要

来自分类Dev

量角器/硒“在以下位置找不到chromedriver”(在Windows上)

来自分类Dev

“找不到符号/在以下位置期望:平面名称空间”的实际含义是什么?

来自分类Dev

量角器/硒“在以下位置找不到chromedriver”(在Windows上)

来自分类Dev

fail2ban.filter:错误在以下位置找不到“主机”

来自分类Dev

找不到.jar文件在以下位置搜索:https://jcenter.bintray.com/

来自分类Dev

在以下位置找不到报告资源时出错: :Branch_Summary_SubReport1.jrxml

来自分类Dev

MappingException:找不到目标实体

来自分类Dev

Gradle 同步失败:找不到 com.google.http-client:google-http-client-parent:1.24.1。在以下位置搜索:

来自分类Dev

在-MappingException中找不到目标实体

来自分类Dev

主义:在(两捆)中找不到目标实体

来自分类Dev

Symfony cmd错误“在..中找不到目标实体。”

来自分类Dev

Symfony2:更新架构时找不到目标实体

来自分类Dev

Deno应用程序的Vscode调试错误:无法连接到以下位置的调试目标

来自分类Dev

映射实体无法完成,因为它找不到合适的位置

来自分类Dev

游标无法在以下位置工作:悬停

来自分类Dev

游标无法在以下位置工作:悬停

来自分类Dev

android studio“在以下位置搜索”

来自分类Dev

嫩枝:找不到实体

来自分类Dev

Android - 找不到以下类

来自分类Dev

找不到名为“ Build”的目标

来自分类Dev

找不到目标的TweenAccessor

来自分类Dev

错误:找不到目标:yaourt

来自分类Dev

找不到文件位置

来自分类Dev

找不到Hybris实体异常

来自分类Dev

找不到dockerfile / elasticsearch的实体

Related 相关文章

  1. 1

    IronPython实体框架6在以下位置找不到属性

  2. 2

    在以下位置找不到名为“ pubspec.yaml”的文件

  3. 3

    在以下位置找不到此颜色的声明

  4. 4

    ReferenceError:找不到变量:在以下位置需要

  5. 5

    量角器/硒“在以下位置找不到chromedriver”(在Windows上)

  6. 6

    “找不到符号/在以下位置期望:平面名称空间”的实际含义是什么?

  7. 7

    量角器/硒“在以下位置找不到chromedriver”(在Windows上)

  8. 8

    fail2ban.filter:错误在以下位置找不到“主机”

  9. 9

    找不到.jar文件在以下位置搜索:https://jcenter.bintray.com/

  10. 10

    在以下位置找不到报告资源时出错: :Branch_Summary_SubReport1.jrxml

  11. 11

    MappingException:找不到目标实体

  12. 12

    Gradle 同步失败:找不到 com.google.http-client:google-http-client-parent:1.24.1。在以下位置搜索:

  13. 13

    在-MappingException中找不到目标实体

  14. 14

    主义:在(两捆)中找不到目标实体

  15. 15

    Symfony cmd错误“在..中找不到目标实体。”

  16. 16

    Symfony2:更新架构时找不到目标实体

  17. 17

    Deno应用程序的Vscode调试错误:无法连接到以下位置的调试目标

  18. 18

    映射实体无法完成,因为它找不到合适的位置

  19. 19

    游标无法在以下位置工作:悬停

  20. 20

    游标无法在以下位置工作:悬停

  21. 21

    android studio“在以下位置搜索”

  22. 22

    嫩枝:找不到实体

  23. 23

    Android - 找不到以下类

  24. 24

    找不到名为“ Build”的目标

  25. 25

    找不到目标的TweenAccessor

  26. 26

    错误:找不到目标:yaourt

  27. 27

    找不到文件位置

  28. 28

    找不到Hybris实体异常

  29. 29

    找不到dockerfile / elasticsearch的实体

热门标签

归档