不是有效的实体或映射的超类 [英] Not a valid entity or mapped super class
问题描述
我有两个捆绑的重复实体。像
用户
CMS包中的用户我将其设为抽象类。 (不知道这是否是正确的选择,实际上,我想要的是扩展我的用户实体,如果需要)。 cms用户:
抽象类用户实现UserInterface
bundle用户:
使用MV\CMSBundle\Entity\User作为BaseUser;
/ **
* @ ORM\Entity(repositoryClass =MV\NameBundle\Repository\UserRepository)
* @ DoctrineAssert\UniqueEntity(fields = {email},message =user.email.already.exist)
* /
类用户扩展BaseUser
{
....
}
我得到错误类MV\CMSBundle\Entity\用户不是有效的实体或映射的超级类。
我在symfony的文档中搜索过,并找到此页面:实体 - 实体映射,但他们没有添加一些内容xD
哦,不,我不想使用FOSUserBundle;)
Symfony:2.1
定义基类如下:
**
* @ ORM\MappedSuperclass
* /
抽象类BaseUser
{
// ...
定义实体:
/ **
* @ ORM\Entity
* /
类用户扩展BaseUser
{
// ...
}
因为你在基类上缺少@MappedSuperclass注释,所以Doctrine抛出你提到的例外。
I have 2 bundles, 1 CMS bundle that will be the parent bundle.
I have in both bundles duplicated entitys. Like User
The user in the CMS bundle i made it a abstract class. (not sure if that is the right choice. Actually, what I want is extending my user entity IF needed.).
cms user:
abstract class User implements UserInterface
bundle user:
use MV\CMSBundle\Entity\User as BaseUser;
/**
* @ORM\Entity(repositoryClass="MV\NameBundle\Repository\UserRepository")
* @DoctrineAssert\UniqueEntity(fields={"email"}, message="user.email.already.exist" )
*/
class User extends BaseUser
{
....
}
Im getting the error Class "MV\CMSBundle\Entity\User" is not a valid entity or mapped super class.
I have searched in the documentation of symfony and found this page: entities-entity-mapping but they didn't add some content xD
Oh, and no I dont want to use FOSUserBundle ;)
Symfony: 2.1
Define the base-class as follows:
/**
* @ORM\MappedSuperclass
*/
abstract class BaseUser
{
// ...
}
Define the real entity:
/**
* @ORM\Entity
*/
class User extends BaseUser
{
// ...
}
Because you're missing the @MappedSuperclass annotation on the base-class, Doctrine throws the exception you mention.
这篇关于不是有效的实体或映射的超类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!