gpt4 book ai didi

symfony - Doctrine @InheritanceType ("JOINED") 错误使用语句

转载 作者:行者123 更新时间:2023-12-02 15:26:00 24 4
gpt4 key购买 nike

我尝试在 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;
////
}

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

最佳答案

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

/**
* 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

关于symfony - Doctrine @InheritanceType ("JOINED") 错误使用语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22227933/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com