Nullable embedded value object with not nullable fields

≯℡__Kan透↙ 提交于 2019-12-09 07:31:39

问题


I created an entity "Person" in Doctrine2, and I added to it an Adress entity, which is a value object (embeddable).

I want to allow a Person creation, without an Address, so I tag my embedded as "nullable = true". But on the other hand, my Address entity, if it exists, SHOULD contains at least some information (like city, zip code, etc...). So it has "nullable = false" attributes.

Address:
    type: embeddable
    fields:
        [...]
        city:
            type: string
            length: 255
            nullable: false

Person:
    type: entity
    table: null
    embedded:
        address:
            class: Address
            nullable: true

It seems that the "nullable = true" of the embedded object was not working. Do you know if it's a normal Doctrine behaviour ? Do I have to put all my embeddable attributes to nullable = true ?

来源:https://stackoverflow.com/questions/33810341/nullable-embedded-value-object-with-not-nullable-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!