Let's say I've got two Doctrine entities, Person
and Company
. Both have an address
field which accepts an Address value object. As per business rules, Company::Address
is required while Person::Address
can be null.
Doctrine 2.5 proposes the Embeddable type, which was apparently built with value objects in mind and, indeed, I see it as a perfect solution for my case.
However, there's one thing I can't do: declare that Person::Address
is nullable while Company::Address
is not. A boolean nullable
attribute exists for the Embeddable's fields themselves, but of course this applies to every entity the Address is embedded in.
Does anybody know if I'm missing something, or if this is due to a technical limitation, if there's a workaround, etc. ? Right now the only solution I see is to declare all Embeddable fields as nullable: true
and handle the constraint in my code.