在Symfony2上的Doctrine2 YML映射

安东尼

我从Symfony2开始,我也从Doctrine2开始。

我想使一个实体双向,但我不知道我做错了什么。这是我的两个.orm.yml文件:

Categorie.orm.yml:

MY\SUPERBundle\Entity\Categorie:
  type: entity
  fields:
    id:
      id: true
      type: integer
      generator:
        strategy: AUTO
    nomCategorie:
      type: text
      nullable: true
      column: NomCategorie
  oneToMany:
    SousCategories:
      targetEntity: MY\SUPERBundle\Entity\SousCategorie
      mappedBy: Categorie

SousCategorie.orm.yml:

MY\SUPERBundle\Entity\SousCategorie:
  type: entity
  fields:
    id:
      id: true
      type: integer
      generator:
        strategy: AUTO
    nomSousCategorie:
      type: text
      nullable: true
      column: NomSousCategorie
  manyToOne:
    Categorie:
      targetEntity: MY\SUPERBundle\Entity\Categorie
      inversedBy: SousCategories
      joinColumns:
        categorie_id:
          referencedColumnName: id
          nullable: false

当我想运行命令时:

doctrine:schema:update --dump-sql

我收到此错误:

 [ReflectionException]
  Property MY\SUPERBundle\Entity\Categorie::$SousCategories does not exist

如果你们对我在做什么错有任何暗示,我将非常感激。

谢谢 !

约恩·尚邦内(Yoann Chambonnet)

您确定在“类别”类别下确实有一个名为“ SousCategories”的属性吗?如果您可以在第一篇文章中添加实体类,那就太好了。

顺便说一句,如果它是一个属性,则不应以大写字母开头。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章