学说 @InheritanceType( "JOINED" ) 错误使用声明



我正在尝试在 Doctrine 中使用继承类型,但是当我创建数据库时,它显示以下错误消息:

[DoctrineCommonAnnotationsAnnotationException]
[Semantical Error] The annotation "@InheritanceType" in class iMedGestInfo
rmatiqueBundleEntityMaterielInformatique was never imported. Did you mayb
e forget to add a "use" statement for this annotation?

父类是。

namespace iMedGestInformatiqueBundleEntity;
use DoctrineORMMapping as ORM;
/**
 * MaterielInformatique
 *
 * @ORMTable(name="MATERIEL_INFORMATIQUE")
 * @ORMEntity
 * @InheritanceType("JOINED")
 * @DiscriminatorColumn(name="nature", type="string")
 * @DiscriminatorMap({"PCMP" = "PC", "IMPR" = "Imprimante", "ECRN" = "Ecran"})
 */
class MaterielInformatique
{
    /**
     * @var integer
     *
     * @ORMColumn(name="ID", type="integer", nullable=false)
     * @ORMId
     * @ORMGeneratedValue(strategy="IDENTITY")
     */
    private $id;
////
}

似乎我需要添加一行来导入一个类,但我不知道该类是什么,有人有解决这个问题的想法吗?

您错过了InheritanceType命名空间中的ORM前缀,请尝试以下操作:

/**
 * MaterielInformatique
 *
 * @ORMTable(name="MATERIEL_INFORMATIQUE")
 * @ORMEntity
 * @ORMInheritanceType("JOINED")
 * @ORMDiscriminatorColumn(name="nature", type="string")
 * @ORMDiscriminatorMap({"PCMP" = "PC", "IMPR" = "Imprimante", "ECRN" = "Ecran"})
 */
class MaterielInformatique

相关内容

  • 没有找到相关文章