mbo*_*ouz 4 symfony doctrine-orm
我正在尝试在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?
Run Code Online (Sandbox Code Playgroud)
父类是.
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;
////
}
Run Code Online (Sandbox Code Playgroud)
似乎我需要添加一行来导入一个类,但我不知道什么是类,有人有想法解决这个问题吗?
你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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2236 次 |
| 最近记录: |