【发布时间】:2017-09-23 00:56:42
【问题描述】:
尝试加载我的网页时,我在服务器上收到此错误: 在“ArcaSolutions\ListingBundle\Entity\Listing#classified”中找不到目标实体 ArcaSolutions\ListingBundle\Entity\Classified。 我毫不怀疑问题在于目标实体引用的是 ListingBundle 而不是 ClassifiedBundle,但我在我的代码中看不到任何可能犯此错误的地方。
到目前为止,我已经尝试重新启动 Apache,并清除了学说缓存。
这是 Classified.php 的代码 (MyProject\src\ArcaSolutions\ClassifiedBundle\Entity\Classified.php)
namespace ArcaSolutions\ClassifiedBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\JoinColumn;
use JMS\Serializer\Annotation as Serializer;
/**
* Classified
*
* @ORM\Table(name="Classified", indexes={@ORM\Index(name="country_id", columns={"location_1"}), @ORM\Index(name="state_id", columns={"location_2"}), @ORM\Index(name="region_id", columns={"location_3"}), @ORM\Index(name="latitude", columns={"latitude"}), @ORM\Index(name="longitude", columns={"longitude"}), @ORM\Index(name="level", columns={"level"}), @ORM\Index(name="status", columns={"status"}), @ORM\Index(name="account_id", columns={"account_id"}), @ORM\Index(name="city_id", columns={"location_4"}), @ORM\Index(name="area_id", columns={"location_5"}), @ORM\Index(name="title", columns={"title"}), @ORM\Index(name="friendly_url", columns={"friendly_url"}), @ORM\Index(name="cat_1_id", columns={"cat_1_id"}), @ORM\Index(name="parcat_1_level1_id", columns={"parcat_1_level1_id"}), @ORM\Index(name="fulltextsearch_keyword", columns={"fulltextsearch_keyword"}), @ORM\Index(name="fulltextsearch_where", columns={"fulltextsearch_where"})})
* @ORM\Entity(repositoryClass="ArcaSolutions\ClassifiedBundle\Repository\ClassifiedRepository")
*/
class Classified
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
* @Serializer\Groups({"classifiedDetail", "Result", "listingDetail"})
*/
private $id;
/**
* @ORM\OneToMany(targetEntity="ArcaSolutions\ListingBundle\Entity\Listing", mappedBy="classified")
* @ORM\OrderBy({"status" = "ASC"})
* @Serializer\Groups({"classifiedDetail", "Result"})
* @Serializer\Type("array")
*/
private $listingArray;
/**
* Constructor
*/
public function __construct()
{
$this->listingArray = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add listingArray
*
* @param \ArcaSolutions\ListingBundle\Entity\Listing $listingArray
* @return Classified
*/
public function addListingArray(\ArcaSolutions\ListingBundle\Entity\Listing $listingArray)
{
$this->listingArray[] = $listingArray;
return $this;
}
/**
* Remove listingArray
*
* @param \ArcaSolutions\ListingBundle\Entity\Listing $listingArray
*/
public function removeListingArray(\ArcaSolutions\ListingBundle\Entity\Listing $listingArray)
{
$this->listingArray->removeElement($listingArray);
}
/**
* Get listingArray
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getListingArray()
{
return $this->listingArray;
}
}
这里是 Listing.php 的代码 (MyProject\src\ArcaSolutions\ListingBundle\Entity\Listing.php)
namespace ArcaSolutions\ListingBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\JoinColumn;
use JMS\Serializer\Annotation as Serializer;
/**
* Listing
*
* @ORM\Table(name="Listing", indexes={@ORM\Index(name="title", columns={"title"}), @ORM\Index(name="country_id", columns={"location_1"}), @ORM\Index(name="state_id", columns={"location_2"}), @ORM\Index(name="region_id", columns={"location_3"}), @ORM\Index(name="account_id", columns={"account_id"}), @ORM\Index(name="renewal_date", columns={"renewal_date"}), @ORM\Index(name="status", columns={"status"}), @ORM\Index(name="latitude", columns={"latitude"}), @ORM\Index(name="longitude", columns={"longitude"}), @ORM\Index(name="level", columns={"level"}), @ORM\Index(name="city_id", columns={"location_4"}), @ORM\Index(name="area_id", columns={"location_5"}), @ORM\Index(name="zip_code", columns={"zip_code"}), @ORM\Index(name="friendly_url", columns={"friendly_url"}), @ORM\Index(name="listingtemplate_id", columns={"listingtemplate_id"}), @ORM\Index(name="image_id", columns={"image_id"}), @ORM\Index(name="thumb_id", columns={"thumb_id"}), @ORM\Index(name="idx_fulltextsearch_keyword", columns={"fulltextsearch_keyword"}), @ORM\Index(name="idx_fulltextsearch_where", columns={"fulltextsearch_where"}), @ORM\Index(name="updated_date", columns={"updated"}), @ORM\Index(name="clicktocall_number", columns={"clicktocall_number"}), @ORM\Index(name="Listing_Promotion", columns={"level", "account_id", "title", "id"})})
* @ORM\Entity(repositoryClass="ArcaSolutions\ListingBundle\Repository\ListingRepository")
*/
class Listing
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
* @Serializer\Groups({"listingDetail", "Result", "classifiedDetail", "dealDetail", "reviewItem"})
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="classified_id", type="integer", nullable=true)
*/
private $classifiedId;
/**
* @ORM\ManyToOne(targetEntity="ArcaSolutions\ClassifiedBundle\Entity\Classified", inversedBy="listingArray")
* @ORM\JoinColumn(name="classified_id", referencedColumnName="id")
* @Serializer\Groups({"listingDetail"})
*/
private $classified;
/**
* Set classifiedId
*
* @param integer $classifiedId
* @return Listing
*/
public function setClassifiedId($classifiedId)
{
$this->classifiedId = $classifiedId;
return $this;
}
/**
* Get classifiedId
*
* @return integer
*/
public function getClassifiedId()
{
return $this->classifiedId;
}
/**
* Set classified
*
* @param \ArcaSolutions\ClassifiedBundle\Entity\Classified $classified
* @return Listing
*/
public function setClassified(\ArcaSolutions\ClassifiedBundle\Entity\Classified $classified = null)
{
$this->classified = $classified;
return $this;
}
/**
* Get classified
*
* @return \ArcaSolutions\ClassifiedBundle\Entity\Classified
*/
public function getClassified()
{
return $this->classified;
}
/**
* Add classifieds
*
* @param \ArcaSolutions\ClassifiedBundle\Entity\Classified $classifieds
* @return Listing
*/
public function addClassified(\ArcaSolutions\ClassifiedBundle\Entity\Classified $classifieds)
{
$this->classifieds[] = $classifieds;
return $this;
}
/**
* Remove classifieds
*
* @param \ArcaSolutions\ClassifiedBundle\Entity\Classified $classifieds
*/
public function removeClassified(\ArcaSolutions\ClassifiedBundle\Entity\Classified $classifieds)
{
$this->classifieds->removeElement($classifieds);
}
}
【问题讨论】:
-
尝试删除列表中的
classifiedId,因为您不需要它,这可能会造成问题 -
你试过重启 Apache / php-fpm 吗?如果您启用了 apc 缓存,仅清除缓存文件夹是不够的。您还可以显示两个文件的完整文件名吗?
-
@kunicmarko20 删除分类 ID 没有影响,删除后仍然收到相同的错误。
-
@MaksymMoskvychev 我已经重新启动 Apache 以确保清除缓存,但仍然收到相同的错误。我还包括了 MyProject 根文件夹中的完整路径名。
-
它在错误的地方寻找你的实体
ArcaSolutions\ListingBundle\Entity\Classified这个实体在ClassifiedBundle而不是Listing你是否清除了你的学说缓存?
标签: php entity-framework symfony doctrine-orm orm