【问题标题】:Gedmo Tree Extension: Unable to find ancestor/parent child relationGedmo 树扩展:无法找到祖先/父子关系
【发布时间】:2014-04-11 03:02:00
【问题描述】:

我正在尝试以 YAML 格式使用 Gedmotree 扩展,但是当我尝试更新架构时,它返回以下错误:

[Gedmo\Exception\InvalidMappingException]
Unable to find ancestor/parent child relation through ancestor field - [parent] in class -

以下代码是MyEntity.orm.yml文件:

Project\MyBundle\Entity\MyEntity:
    type: entity
    repositoryClass: Gedmo\Tree\Entity\Repository\NestedTreeRepository
    gedmo:
        tree:
            type: nested
    id:
        id:
            type: string
            nullable: false
            generator:
                strategy: UUID
    fields:
        name:
            type: string
            length: 200
        locale:
            type: string
            length: 6
        lft:
            type: integer
            gedmo:
                - treeLeft
        lvl:
            type: integer
            gedmo:
                - treeLevel
        rgt:
            type: integer
            gedmo:
                - treeRight
        root:
            type: string
            nullable: true
            gedmo:
                - treeRoot

    manyToOne:
        parent:
            targetEntity: Project\MyBundle\Model\MyEntityInterface
            inversedBy: children
            joinColumn:
                name: parent_id
                referencedColumnName: id
                onDelete: CASCADE
            gedmo:
                - treeParent
    oneToMany:
        children:
            targetEntity: Project\MyBundle\Model\MyEntityInterface
            mappedBy: parent
            orderBy:
                lft: ASC

【问题讨论】:

    标签: symfony doctrine-orm tree doctrine-extensions


    【解决方案1】:

    不能是接口,必须是实体

    找到

    targetEntity:项目\MyBundle\Model\MyEntityInterface

    改为:

    目标实体:项目\MyBundle\Entity\MyEntity

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多