具有不可空字段的可空嵌入值对象

时间:2015-11-19 17:17:59

标签: symfony doctrine-orm nullable embeddable

我在Doctrine2中创建了一个实体“Person”,并在其中添加了一个Adress实体,它是一个值对象(可嵌入)。

我想允许Person创建,没有Address,所以我将嵌入式标记为“nullable = true”。但另一方面,我的地址实体,如果存在,应该至少包含一些信息(如城市,邮政编码等)。所以它有“nullable = false”属性。

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

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

似乎嵌入对象的“nullable = true”无法正常工作。 你知道这是否是正常的学说行为? 我是否必须将所有可嵌入属性设置为nullable = true?

0 个答案:

没有答案
相关问题