DDC-3747: Embeddables should not conatain Id definitions #4596

Open
opened 2026-01-22 14:45:38 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (May 27, 2015).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user acasademont:

Hi! I have an Sku entity which contains an SkuId embeddable object, which is an Id for the Sku entity. At the same time, the Sku entity also contains a ProductId embeddable which is an Id for the Product entity, not the Sku. But as the Id definition is inside the embeddable, I can't embed the ProductId class in the Sku entity because Doctrine thinks this is a composite primary key, which breaks quite a lot of things.

Sku\Sku:
  type: entity
  fields:
    name:
      type: string
      length: 100
  embedded:
    skuId:
      class: Ulabox\Inventory\Domain\Model\Sku\SkuId
      columnPrefix: false
    productId:
      class: Ulabox\Inventory\Domain\Model\Product\ProductId
      columnPrefix: product_
Sku\SkuId:
  type: embeddable
  id:
    id:
      type: guid
Product\ProductId:
  type: embeddable
  id:
    id:
      type: guid

I've switched to using custom types for this "class Id's" but I think that the Id definition should be separated from the Embeddable definition because sometimes an Embeddable might be the Id of an entity, but it also could be a simple field, which is not possible right now. Maybe some kind of "type" attribute in the "embedded" definition that could mark if the Embeddable fields are going to be used as simple fields or id fields

Sku\Sku:
  type: entity
  fields:
    name:
      type: string
      length: 100
  embedded:
    skuId:
      type: id
      class: Ulabox\Inventory\Domain\Model\Sku\SkuId
      columnPrefix: false
    productId:
      class: Ulabox\Inventory\Domain\Model\Product\ProductId
      columnPrefix: product_
Sku\SkuId:
  type: embeddable
  fields:
    id:
      type: guid
Product\ProductId:
  type: embeddable
  fields:
    id:
      type: guid
Originally created by @doctrinebot on GitHub (May 27, 2015). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user acasademont: Hi! I have an Sku entity which contains an SkuId embeddable object, which is an Id for the Sku entity. At the same time, the Sku entity also contains a ProductId embeddable which is an Id for the Product entity, not the Sku. But as the Id definition is inside the embeddable, I can't embed the ProductId class in the Sku entity because Doctrine thinks this is a composite primary key, which breaks quite a lot of things. ``` Sku\Sku: type: entity fields: name: type: string length: 100 embedded: skuId: class: Ulabox\Inventory\Domain\Model\Sku\SkuId columnPrefix: false productId: class: Ulabox\Inventory\Domain\Model\Product\ProductId columnPrefix: product_ Sku\SkuId: type: embeddable id: id: type: guid Product\ProductId: type: embeddable id: id: type: guid ``` I've switched to using custom types for this "class Id's" but I think that the Id definition should be separated from the Embeddable definition because sometimes an Embeddable might be the Id of an entity, but it also could be a simple field, which is not possible right now. Maybe some kind of "type" attribute in the "embedded" definition that could mark if the Embeddable fields are going to be used as simple fields or id fields ``` Sku\Sku: type: entity fields: name: type: string length: 100 embedded: skuId: type: id class: Ulabox\Inventory\Domain\Model\Sku\SkuId columnPrefix: false productId: class: Ulabox\Inventory\Domain\Model\Product\ProductId columnPrefix: product_ Sku\SkuId: type: embeddable fields: id: type: guid Product\ProductId: type: embeddable fields: id: type: guid ```
admin added the Bug label 2026-01-22 14:45:38 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4596