OptionalLoadHow far owner.Load() walks into the embedded record. Defaults to 'inherit'.
'inherit' — the embedded is loaded as embedded.Load() would: fields,
IS-A chain, immediate companions, nested embeddeds. Explicit
related-record collections stay explicit.'related' — also LoadRelatedRecords() on the embedded, so e.g.
deal.Load() brings Order.Lines too.OptionalOnWhat happens to the embedded row when the owner clears the relationship
or is deleted. Defaults to 'orphan'.
'orphan' — null the FK, leave the embedded row. Correct when the
target is a first-class document in another bounded context (a Deal's
Order).'delete' — delete the embedded row after the owner (the FK lives on
the owner, so the owner must go first).'refuse' — Clear() throws. For relationships where detaching is
always a bug.
Declares an
EntityField(a foreign key on this entity) as a first-class embedded record — a 1:1 peerBaseEntitythat loads, validates and persists as one unit with its owner.Stored in the
EmbeddedRecordcolumn ofMJ: Entity Fields. When non-null, CodeGen emits{FieldName}_Object/{FieldName}_EnsureObject()on the generated entity subclass.RelatedEntityand the FK field name are deliberately absent. They already exist asEntityField.RelatedEntityIDandEntityField.Name. Duplicating them here would create two sources of truth that can disagree — with the JSON copy winning silently. CodeGen reads them from the row.Mandatory vs optional is
EntityField.AllowsNull, not a flag here. A non-nullable FK is provisioned withGetEntityObject/NewRecord. A nullable FK staysnulluntil{FieldName}_EnsureObject()or untilLoad()finds a value.NULL means the field is an ordinary FK. That is the default and reproduces pre-feature behaviour exactly: nothing is generated and nothing is constructed at
GetEntityObjecttime.See