Interface ForeignKeyDefinition.Builder
- All Superinterfaces:
AttributeDefinition.Builder<Entity,
ForeignKeyDefinition.Builder>
- Enclosing interface:
ForeignKeyDefinition
ForeignKeyDefinition
.-
Method Summary
Modifier and TypeMethodDescriptionBy default, all attributes are included when the referenced entity is selected.Marks the given foreign key reference column as read-only, which causes an exception being thrown when the given column value is modified via this foreign key.referenceDepth
(int referenceDepth) Specifies the default query reference depth for this foreign key.soft
(boolean soft) Marks this foreign key as being soft, that is, not based on a physical (table) foreign key and should not prevent deletionMethods inherited from interface is.codion.framework.domain.entity.attribute.AttributeDefinition.Builder
attribute, build, caption, captionResource, captionResource, comparator, dateTimePattern, dateTimePattern, defaultValue, defaultValue, description, format, fractionDigits, hidden, items, maximum, maximumLength, minimum, mnemonic, mnemonicResource, mnemonicResource, nullable, numberGrouping, range, roundingMode, trim
-
Method Details
-
soft
Marks this foreign key as being soft, that is, not based on a physical (table) foreign key and should not prevent deletion- Parameters:
soft
- if true then this foreign key is marked as a non-physical soft key- Returns:
- this instance
-
readOnly
Marks the given foreign key reference column as read-only, which causes an exception being thrown when the given column value is modified via this foreign key.- Parameters:
column
- the reference column- Returns:
- this instance
-
include
By default, all attributes are included when the referenced entity is selected. Use this method to restrict the included attributes.
Note that the primary key attributes are always included and do not have to be specified when using this method.
One thing to consider is to include the attributes used by the formatter for the referenced entity, to guarantee a correct string representation if required (such as in table column display).
- Parameters:
attributes
- the attributes to include in the referenced entity- Returns:
- this instance
-
referenceDepth
Specifies the default query reference depth for this foreign key.Reference depth: -1: the full foreign key graph of the referenced entity is fetched. 0: the referenced entity not fetched. 1: the referenced entity is fetched, without any foreign key references. 2: the referenced entity is fetched, with a single level of foreign key references. 3: the referenced entity is fetched, with two levels of foreign key references. etc...
Warning: Using referenceDepth(-1) when the actual data contains circular references (e.g., record A references B, B references C, C references A) will cause infinite recursion and StackOverflowError. Self-referential foreign keys (like Employee.manager_id) are safe with unlimited depth as long as the data forms a tree/hierarchy without cycles.
- Parameters:
referenceDepth
- the number of levels of foreign key references to fetch for this foreign key- Returns:
- this instance
- Throws:
IllegalArgumentException
- in case reference depth is less than -1- See Also:
-