DataObjectMapper

fun <T : Any> DataObjectMapper(kClass: KClass<T>): RowMapper<T>

Creates a mapper that converts each row into an instance of a specified Kotlin data class.

The mapping process follows these steps:

  1. Extracts the row as a Map using ColumnNameMapper.

  2. Uses toDataObject (reflection) to instantiate the class.

Naming conventions: Column names in SQL (e.g., user_id) are automatically matched to class properties (e.g., userId) using the standard snake_case ->camelCase transformation, for custom name mapping use MapKey annotation.

Parameters

T

The target type.

kClass

The Kotlin class to map into.