Doctrine Usage Operator @InheritanceType ("JOINED")

I am trying to use the Inheritance Type in Doctrine, but when I create the database, it shows this error message:

[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "@InheritanceType" in class iMed\GestInfo
rmatiqueBundle\Entity\MaterielInformatique was never imported. Did you mayb
e forget to add a "use" statement for this annotation?

Parent class.

namespace iMed\GestInformatiqueBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * MaterielInformatique
 *
 * @ORM\Table(name="MATERIEL_INFORMATIQUE")
 * @ORM\Entity
 * @InheritanceType("JOINED")
 * @DiscriminatorColumn(name="nature", type="string")
 * @DiscriminatorMap({"PCMP" = "PC", "IMPR" = "Imprimante", "ECRN" = "Ecran"})
 */
class MaterielInformatique
{
    /**
     * @var integer
     *
     * @ORM\Column(name="ID", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;
////
}

It seems I need to add a line to import the class, but I don't know what the class is, does anyone have an idea to solve this problem?

+4
source share
1 answer

You missed the prefix ORMin the namespace InheritanceType, try the following:

/**
 * MaterielInformatique
 *
 * @ORM\Table(name="MATERIEL_INFORMATIQUE")
 * @ORM\Entity
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="nature", type="string")
 * @ORM\DiscriminatorMap({"PCMP" = "PC", "IMPR" = "Imprimante", "ECRN" = "Ecran"})
 */
class MaterielInformatique
+9
source

Source: https://habr.com/ru/post/1530437/


All Articles