# kotlin-orm/ktorm

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/kotlin-orm-ktorm).**

2,336 stars · 162 forks · Kotlin · Apache-2.0

## Links

- GitHub: https://github.com/kotlin-orm/ktorm
- Homepage: https://www.ktorm.org
- awesome-repositories: https://awesome-repositories.com/repository/kotlin-orm-ktorm.md

## Topics

`kotlin` `ktorm` `orm` `sql`

## Description

Ktorm is a lightweight object-relational mapping framework for Kotlin that provides a type-safe SQL domain-specific language and functional sequence APIs for database interaction. It enables developers to define database schemas and map relational tables to interface-based objects, ensuring that data persistence and retrieval are handled through strongly-typed expressions.

The framework distinguishes itself by utilizing a functional, collection-style approach to query construction, allowing developers to chain operations like filtering, sorting, and aggregation using idiomatic language patterns. By employing lazy sequence evaluation, the library ensures that database operations are deferred until data is explicitly accessed, which optimizes performance and memory usage during record retrieval.

The system covers a comprehensive range of database management capabilities, including automated join operations, result pagination, and entity lifecycle management. It supports complex schema definitions and custom type mapping, providing tools to synchronize in-memory object states with persistent database records while maintaining schema consistency through declarative metadata.

## Tags

### Part of an Awesome List

- [Database Access and ORM](https://awesome-repositories.com/f/awesome-lists/data/database-access-and-orm.md) — Retrieves records from relational tables as strongly-typed objects using a lazy-loading interface. ([source](https://www.ktorm.org/en/entity-sequence.html))
- [Database Access](https://awesome-repositories.com/f/awesome-lists/data/database-access.md) — Provides a data retrieval interface that uses collection-style operators to filter, map, and process database records.

### Data & Databases

- [Object-Relational Mapping Frameworks](https://awesome-repositories.com/f/data-databases/object-relational-mapping-frameworks.md) — The ORM supports defining data entities as interface-based objects, allowing for property initialization and custom business logic through methods. ([source](https://www.ktorm.org/en/entities-and-column-binding.html))
- [Type-Safe Query Construction](https://awesome-repositories.com/f/data-databases/expression-based-data-querying/fluent-query-apis/sql-syntax-tree-construction/fluent-query-construction/type-safe-query-construction.md) — Enables programmatic construction of SQL statements that ensures type safety and provides compile-time autocompletion. ([source](https://www.ktorm.org/en/query.html))
- [Functional Query Interfaces](https://awesome-repositories.com/f/data-databases/functional-query-interfaces.md) — Provides functional APIs for chaining database operations using idiomatic collection-style patterns.
- [Interface-Based Mappers](https://awesome-repositories.com/f/data-databases/type-mapping-frameworks/script-to-native-type-mappings/entity-mappings/struct-to-row-mappers/interface-based-mappers.md) — Links relational table columns to interface-based objects using declarative bindings and automated row-to-entity conversion.
- [Type-Safe Query Builders](https://awesome-repositories.com/f/data-databases/type-safe-query-builders.md) — Provides tools for constructing database queries using strongly-typed language features that ensure schema consistency.
- [Column Mappings](https://awesome-repositories.com/f/data-databases/column-mappings.md) — Links table columns to entity properties using declarative bindings. ([source](https://www.ktorm.org/en/entities-and-column-binding.html))
- [Metadata-Driven Schema Mappers](https://awesome-repositories.com/f/data-databases/data-governance-modeling/data-modeling-schemas/schema-mapping/metadata-driven-schema-mappers.md) — Links relational database structures to application objects using declarative metadata.
- [Database ORMs](https://awesome-repositories.com/f/data-databases/database-orms.md) — Enables mapping database tables and columns to code objects using a strongly-typed schema definition language. ([source](https://www.ktorm.org/en/schema-definition.html))
- [Entity Interfaces](https://awesome-repositories.com/f/data-databases/entity-modeling/entity-interfaces.md) — Maps database tables to interface-based objects for property binding and business logic.
- [Lifecycle Management](https://awesome-repositories.com/f/data-databases/entity-relationships/entity-crud-management/lifecycle-management.md) — Synchronizes in-memory object states with persistent database records throughout the entity lifecycle. ([source](https://github.com/kotlin-orm/ktorm/blob/master/README.md))
- [Functional Data Aggregation](https://awesome-repositories.com/f/data-databases/functional-data-aggregation.md) — Computes summary statistics like sums, averages, or counts from filtered database records. ([source](https://www.ktorm.org/en/query.html))
- [Pagination](https://awesome-repositories.com/f/data-databases/query-result-fetching/pagination.md) — Facilitates efficient retrieval of large datasets by limiting records and setting offsets for pagination. ([source](https://www.ktorm.org/en/query.html))
- [Query Filters](https://awesome-repositories.com/f/data-databases/query-sorting/query-filters.md) — Applies conditional logic to database requests by chaining operations that refine selection criteria. ([source](https://www.ktorm.org/en/query.html))
- [ORM Join Generators](https://awesome-repositories.com/f/data-databases/relational-join-engines/orm-join-generators.md) — Reduces boilerplate by automatically performing recursive joins on referenced tables to populate related data. ([source](https://www.ktorm.org/en/entity-finding.html))
- [Relational Schemas](https://awesome-repositories.com/f/data-databases/relational-schemas.md) — Defines database structures through code-based interfaces and declarative bindings to link application objects to table schemas.
- [Dialect-Specific SQL Generation](https://awesome-repositories.com/f/data-databases/sql-generators/dialect-specific-sql-generation.md) — Translates abstract query definitions into database-specific SQL syntax at execution time.
- [Entity Mappings](https://awesome-repositories.com/f/data-databases/type-mapping-frameworks/script-to-native-type-mappings/entity-mappings.md) — Transforms relational table records into strongly-typed objects by automatically binding column values during retrieval. ([source](https://github.com/kotlin-orm/ktorm#readme))

### Web Development

- [SQL Frameworks](https://awesome-repositories.com/f/web-development/server-side-frameworks/kotlin-frameworks/sql-frameworks.md) — Provides a lightweight database access library for Kotlin with a type-safe SQL DSL and functional sequence APIs.
- [Kotlin DAO Layers](https://awesome-repositories.com/f/web-development/crud-generators/dao-persistence-generators/kotlin-dao-layers.md) — Provides a data access layer for Kotlin that maps rows to entity objects with lazy-loaded references.

### Programming Languages & Runtimes

- [Lazy Sequences](https://awesome-repositories.com/f/programming-languages-runtimes/deferred-execution/lazy-evaluation/lazy-sequences.md) — Optimizes performance by deferring database operations until data is explicitly accessed via lazy sequences.
