I'm trying to use a Discriminator
in a entity that extends from another. This is the code I made:
/**
* @ORM\Entity
* @ORM\Table(name="usuarios_externos.usuarios", schema="usuarios_externos")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({
* "natural" = "Natural",
* "empresa" = "Empresa"
* })
* @UniqueEntity(fields={"correo_alternativo"}, message="El correo electrónico ya está siendo usado.")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*/
class Usuario extends BaseUser {
....
}
But I'm getting this error while ran the command doctrine:schema:validate
:
[Doctrine\ORM\Mapping\MappingException] Entity 'UsuarioBundle\Entity\Usuario' has to be part of the discriminator map of 'UsuarioBundle\Entity\Usuario' to be properly mapped in the inheritance hierarchy. Alternatively you can make 'UsuarioBundle\Entity\Usuario' an abstract class to avoid this exception from occurring.
Any way to fix this? It's possible to use Discriminator in extended classes?