简体   繁体   English

如何在Symfony中设置ORM两个实体ID

[英]How to set ORM Two Entity id's in Symfony

Here i'm new to symfony, i tried to set two id's as orm entity its taken first coloumn as primarykey but second coloumn doesn't present in database, can any one help me to solve this problem. 在这里,我是symfony的新手,我试图将两个id设置为orm实体,它的第一个列为主键,但是第二个列不存在于数据库中,任何人都可以帮助我解决此问题。

My ORM Entity 我的ORM实体

id:
    merchantId:
      type: merchant_id
      column: merchant_id
    auto_id:
        type: integer
        auto_id: true
        column: auto_id
        associationKey: true
        generator:
            strategy: AUTO

merchantId is my uuid(PostgreSQL DB), auto_id is auto increment id (1,2,3....). MerchantId是我的uuid(PostgreSQL DB),auto_id是自动增量ID(1,2,3 ....)。

How to i solve this, can any one help me if you can. 我如何解决此问题,如果可以的话,谁能帮助我。

When I mapped the entity it looks like this 当我映射实体时,它看起来像这样

   SomeBundle\Entity\Example:
    type: entity
    table: example
    id:
        firstId:
            type: integer
            nullable: false
            options:
                unsigned: false
            id: true
            column: first_id
        secondId:
            type: string
            nullable: false
            length: null
            options:
                fixed: false
            id: true
            column: second_id
    fields:
        someExtraData:
            type: string
            nullable: true
            length: null
            options:
                fixed: false
            column: some_extra_data
    lifecycleCallbacks: {  }

You could try either way desing the entity and mappit or update your entity declaration. 您可以尝试以任何一种方式设计实体和mappit或更新您的实体声明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM