Doctrine orm symfony3中的条令可排序扩展-错误:非空

Doctrine orm symfony3中的条令可排序扩展-错误:非空,doctrine-orm,symfony,doctrine-extensions,Doctrine Orm,Symfony,Doctrine Extensions,我尝试通过gedmo扩展使用条令扩展sortable。我使用composer安装了gedmo包,并按照的说明进行了操作。我使用yaml-文件作为条令的映射信息 我的yaml文件: AppBundle\Entity\Picture: type: entity table: pictures id: id: type: integer generator: { strategy: AUTO } fields: [...] type:

我尝试通过
gedmo
扩展使用条令扩展
sortable
。我使用composer安装了gedmo包,并按照的说明进行了操作。我使用
yaml
-文件作为条令的映射信息

我的yaml文件:

AppBundle\Entity\Picture:
type: entity
table: pictures
id:
    id:
        type: integer
        generator: { strategy: AUTO }
fields:
   [...]
    type:
        type: string
        length: 20
    position:
        type: string
        gedmo:
            sortable:
                groups: [type]
字段位置的类型为
int
,但我也尝试了
string
,因为这会导致可排序扩展名的yaml驱动程序出错(
InvalidMappingException

但是我总是得到的错误是
完整性约束冲突:19非空约束失败:pictures.position
。但是在所有可排序扩展中,不需要专门为position字段设置值,也不需要在yaml文件中允许null。我还假设,
InvalidMappingException
应该出现在
notnull异常之前

因此,我认为扩展甚至没有被使用。 我使用的配置文件:

My config.yml文件:

imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: doctrine_extensions.yml}
[...]
My doctrine_extensions.yml文件:

services:
# KernelRequest listener
gedmo.listener.sortable:
    class: Gedmo\Sortable\SortableListener
    tags:
        - { name: doctrine.event_subscriber, connection: default }
    calls:
        - [ setAnnotationReader, [ "@annotation_reader" ] ]

我知道这个问题很久以前就有人问过了,但如果有帮助的话:根据您使用的版本,您可以尝试以下语法(这对我很有用):

如果需要按组排序,则需要将其添加到关系中(以下是完整示例):


我知道这个问题很久以前就有人问过了,但如果有帮助的话:根据您使用的版本,您可以尝试以下语法(这对我很有用):

如果需要按组排序,则需要将其添加到关系中(以下是完整示例):

#Resources/config/doctrine/Entity.orm.yml
[...]  
fields:  
  position:
      type: integer
      gedmo:
        - sortablePosition
  manyToOne:
    parent:
      targetEntity: Parent
      inversedBy: children
      joinColumn:
        name: parent_id
        referencedColumnName: id
        onDelete: cascade
      gedmo:
        - sortableGroup