Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql Can';当生成器策略设置为IDENTITY时,t设置sequenceGenerator_Postgresql_Symfony_Doctrine Orm_Doctrine - Fatal编程技术网

Postgresql Can';当生成器策略设置为IDENTITY时,t设置sequenceGenerator

Postgresql Can';当生成器策略设置为IDENTITY时,t设置sequenceGenerator,postgresql,symfony,doctrine-orm,doctrine,Postgresql,Symfony,Doctrine Orm,Doctrine,我试图使用PostgreSQL的标识策略设置序列的分配大小和初始值。这不会产生我期望的SQL,但是将策略更改为SEQUENCE会起作用。这是有意的吗 id: id: type: integer id: true generator: strategy: IDENTITY sequenceGenerator: sequenceName: table_id_seq

我试图使用PostgreSQL的标识策略设置序列的分配大小和初始值。这不会产生我期望的SQL,但是将策略更改为SEQUENCE会起作用。这是有意的吗

id:
    id:
        type: integer
        id: true
        generator:
            strategy: IDENTITY
        sequenceGenerator:
            sequenceName: table_id_seq
            allocationSize: 10
            initialValue: 100000

条令在
条令\ORM\Mapping\ClassMetadataFactory
中初始化ID生成器策略。工厂中有一个大的
开关
语句,用于切换YAML配置中提供的

generator:
    strategy: <STRATEGY_NAME>
生成器:
战略:
然后,所选策略从配置中获取更多可选参数

所有可用的策略都列在列表中。序列生成器策略的选项详见

从您的配置判断,您当前正在设置
序列生成器
策略的参数,同时告诉条令使用
标识符
策略。也许这就是你正在经历的意外行为


您可以选择相应的工厂生产线,以明确您的期望。

因此,仅与@GeneratedValue(strategy=“SEQUENCE”)一起使用

对于@GeneratedValue(strategy=“SEQUENCE”)使用,此注释允许指定有关序列的详细信息,例如序列的增量大小和初始值

其他

配置示例:

Message:
  type: entity
  id:
    id:
      type: integer
      generator:
        strategy: SEQUENCE
      sequenceGenerator:
        sequenceName: message_seq
        allocationSize: 100
        initialValue: 1

我认为使用IDENTITY时allocationSize是不相关的,因为插入行时没有nextval()请求。但是,我仍然希望在创建表时设置初始序列值。