是否可以添加嵌入在Doctrine中的实体的索引?

时间:2019-10-18 09:26:05

标签: doctrine-orm

我想知道是否可以添加已定义的嵌入式实体的索引,而无需将其写入父实体

App\Documents\Person\Domain\Parent:
  type: entity
  table: parent
  id:
    uuid:
      type: guid
  fields:
    id:
      type: integer
      unique: true
      nullable: true
      columnDefinition: INT NOT NULL AUTO_INCREMENT
  embedded:
    referenceUuid:
      class: App\Documents\Shared\Domain\ReferenceUuid
      columnPrefix: false
      useColumnPrefix: false
    user:
      class: App\Shared\Domain\Aggregate\User
      useColumnPrefix: false
      columnPrefix: false


App\Documents\Shared\Domain\ReferenceUuid:
  type: embeddable
  fields:
    value:
      type: guid
      nullable: true
      column: reference_uuid
  indexes:
    reference_uuid_index:
      columns: [reference_uuid]


App\Shared\Domain\Aggregate\User:
  type: embeddable
  embedded:
    uuid:
      class: App\Shared\Domain\Aggregate\UserUuid
      useColumnPrefix: true
      columnPrefix: user_
    name:
      class: App\Shared\Domain\Aggregate\UserName
      columnPrefix: user_
      useColumnPrefix: true
    role:
      class: App\Shared\Domain\Aggregate\UserRole
      useColumnPrefix: true
      columnPrefix: user_


App\Shared\Domain\Aggregate\UserUuid:
  type: embeddable
  fields:
    value:
      type: guid
      nullable: true
      column: uuid
  indexes:
    user_uuid_index:
      columns: [uuid]

为了将索引存储在MySQL数据库中,必须在父实体中定义它们:

App\Documents\Person\Domain\Parent:
  type: entity
  table: parent
  id:
    uuid:
      type: guid
  fields:
    id:
      type: integer
      unique: true
      nullable: true
      columnDefinition: INT NOT NULL AUTO_INCREMENT
  embedded:
    referenceUuid:
      class: App\Documents\Shared\Domain\ReferenceUuid
      columnPrefix: false
      useColumnPrefix: false
    user:
      class: App\Shared\Domain\Aggregate\User
      useColumnPrefix: false
      columnPrefix: false

  indexes:
    reference_uuid_index:
      columns: [reference_uuid]
    user_uuid_index:
      columns: [uuid]

我希望有办法解决,并使用嵌入实体中包含的索引。

谢谢

0 个答案:

没有答案