Symfony/Doctrine:类不是有效的实体或映射的超类 [英] Symfony/Doctrine: Class is not a valid entity or mapped super class
问题描述
我收到Class PriceOrQuality\POQBundle\Entity\Tag 不是有效实体或映射的超类错误.我已经检查了类似问题的所有答案,但我似乎无法理解问题.
I'm getting the "Class PriceOrQuality\POQBundle\Entity\Tag is not a valid entity or mapped super class error. I've have checked all the answers to similar questions, but I cannot seem to grasp the problem.
错误是由我的存储库类引发的
The error is thrown by my Repository Class
<?php
namespace PriceOrQuality\POQBundle\Entity\Repository;
use Doctrine\ORM\EntityRepository as ER;
use PriceOrQuality\POQBundle\Entity\Tag;
use Doctrine\ORM\EntityManager;
/**
* EntityTagsRepository
*
*/
class EntityTagsRepository extends ER
{
public function getTagsForTagCloud($entity_ids = null, $tag_id = null) {
$em = $this->getEntityManager();
$qb = $em->createQueryBuilder();
$qb->select(array('IDENTITY(et.tag) as id, COUNT(et.tag) as tag_id_count, LOWER(t.tag) as tag'));
$qb->from('PriceOrQuality\POQBundle\Entity\EntityTag', 'et');
$qb->leftjoin('PriceOrQuality\POQBundle\Entity\Tag','t', 'WITH', 'et.tag = t.id');
$qb->groupBy('et.tag');
$qb->addOrderBy('tag_id_count','DESC');
$qb->setMaxResults(20);
return $qb->getQuery()
->getResult();
}
}
在这个文件(Tag.php)中定义了Tag类(仅限定义):
The Tag class is defined in this file (Tag.php) (definition only):
<?php
namespace PriceOrQuality\POQBundle\Entity;
// src/PriceOrQuality/POQBundle/Entity/Tag.php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use PriceOrQuality\POQBundle\Entity\EntityTag;
use PriceOrQuality\POQBundle\Entity\User;
use JMS\SerializerBundle\Serializer\Serializer;
/**
* @ORM\Entity(repositoryClass="PriceOrQuality\POQBundle\Entity\Repository\TagsRepository")
* @ORM\Table(name="tags")
* @ORM\HasLifecycleCallbacks
*/
有没有聪明人知道从哪里开始调试?
Does any of you smart guys have any idea on where to start with the debugging?
提前致谢,
符文
推荐答案
发现问题.
我在元定义之后和类定义之前有一个//@todo.显然,这搞砸了映射,因为它没有在学说中映射.
I had a //@todo after the meta definition and before the class definition. Apparently that screwed up the mapping, as it was not mapped in doctrine.
移动//@todo 并重新运行映射解决了问题.
Moving the //@todo and rerunning the mapping fixed the problem.
对于发现此问题具有类似问题的人,请尝试运行:
For whomever finds this question with similar problems try running:
php app/console doctrine:mapping:info
它会告诉你你在学说中的映射结构是否有问题
It will show you if you have problems in the mapping structure in doctrine
感谢您的时间.
干杯,符文
这篇关于Symfony/Doctrine:类不是有效的实体或映射的超类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!