DynamicDto
Represents a polymorphic object for database storage, mapping to the dynamic_dto PostgreSQL type.
DynamicDto acts as a "transport container" that bundles a type name and a JSON payload. This allows PostgreSQL to store and query polymorphic data structures without requiring dedicated COMPOSITE types. Corresponds to the dynamic_dto type in the database.
Asymmetric Data Flow
Writing (Kotlin -> DB): Wrap your domain object in a
DynamicDtousing DynamicDto.from. The framework converts this into the database'sdynamic_dto(text, jsonb)structure.Reading (DB -> Kotlin): The framework automatically unmarshals
dynamic_dtovalues directly into your domain classes (annotated with DynamicallyMappable).
Example: Writing Polymorphic Data
// A legionnaire's benefit can be either a land grant or a military pension —
// both stored in the same 'veteran_benefit' column.
val grant = LandGrant(province = "Gallia Narbonensis", areraActa = BigDecimal("120.5"))
val dto = DynamicDto.from(grant)
dataAccess.insertInto("veterans").values("id" to 1, "benefit" to dto).execute()Properties
The serialized state of the object as a JsonElement.
Identifier linked to a DynamicallyMappable class.