EntityReflection

data class EntityReflection(val copyFunction: KFunction<*>?, val copyParameters: List<KParameter>, val propertiesByName: Map<String, KProperty1<*, *>>, val primaryConstructor: KFunction<*>?, val constructorParameters: List<KParameter>, val columnsByProperty: Map<String, ColumnSchema>)

The reflection surface needed to read/write an entity's fields at runtime, resolved once per entity kotlin.reflect.KClass at io.kandra.core.SchemaRegistry.register time and cached on TableSchema.reflection.

Before this existed, kandra-runtime re-resolved entity::class.memberFunctions.find { it.name == "copy" } and entity::class.memberProperties.associateBy { it.name } via Kotlin reflection on every single save()/update()/delete()/row-decode call — a linear scan repeated per call instead of once per entity type. See ISS-034 / GitHub #13.

Constructors

Link copied to clipboard
constructor(copyFunction: KFunction<*>?, copyParameters: List<KParameter>, propertiesByName: Map<String, KProperty1<*, *>>, primaryConstructor: KFunction<*>?, constructorParameters: List<KParameter>, columnsByProperty: Map<String, ColumnSchema>)

Properties

Link copied to clipboard

Every column schema for this entity, keyed by Kotlin property name. Used by QueryExecutor.decodeEntity to avoid rebuilding the map on every row.

Link copied to clipboard

primaryConstructor.parameters, cached alongside it — used by QueryExecutor.decodeEntity.

Link copied to clipboard

The entity's copy(...) function, or null if it has none (e.g. not a data class).

Link copied to clipboard

copyFunction.parameters, cached alongside it — the receiver parameter is [0].

Link copied to clipboard

The entity's primary constructor, or null if it has none.

Link copied to clipboard

Every member property of the entity, keyed by Kotlin property name (not CQL column name).