Embedded

annotation class Embedded(val prefix: String = "")

Annotation to mark a property as an embedded object. The fields of the embedded object will be stored in the same scope as the parent entity.

Prefix behavior

The prefix is prepended to each field key of the embedded object, joined by a dot separator.

  • "" (empty) → street, city — fields flattened at root level

  • "addr"addr.street — standard dot separator

  • "addr."addr.street — trailing dot acts as separator

  • "addr_"addr_street — underscore blends into key name

  • "nested."nested.addr.street — nested prefixes accumulate with dots

Key rule: If the prefix already ends with a separator character (. or _), no extra dot is added — the prefix is treated as intentionally containing the separator. Otherwise, a . is inserted between the prefix and the field key.

Parameters

prefix

An optional prefix to prepend to the keys of the embedded object. If empty, the property name will be used as a prefix with a dot.

Example:

@Embedded(prefix = "prefs_")
val settings: UserSettings

Properties

Link copied to clipboard