Not a valid entity or mapped super class

doctrine entity-framework symfony

Question

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

1
16
2/2/2013 1:48:32 PM

Accepted Answer

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.

24
7/18/2016 4:58:09 PM

Popular Answer

In my case I was missing * @ORM\Entity in my class definition.

/**
 * @ORM\Entity
 * @ORM\Table(name="listtype")
 */
class ListType
{
    ...
}


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow