Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine @InheritanceType("JOINED") error use statement

I'm trying to use 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?

The parent class is.

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 that I need to add a line to import a class but I do not know what is the class, do somebody have an idea to solve this?

like image 269
timmz Avatar asked Jan 11 '23 01:01

timmz


1 Answers

You missed ORM prefix in InheritanceType namespace, try this:

/**
 * 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
like image 170
Victor Bocharsky Avatar answered Jan 17 '23 03:01

Victor Bocharsky