我正在尝试在Doctrine中使用继承类型,但是当我创建数据库时,它会显示以下错误消息:
[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?
父类是。
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;
////
}
似乎我需要添加一行来导入一个类,但我不知道什么是类,有人有想法解决这个问题吗?
答案 0 :(得分:9)
您在ORM
命名空间中错过了InheritanceType
前缀,请尝试以下操作:
/**
* 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