Skip to content

Repository files navigation

Kapper

LicenseMaven CentralbuildQuality Gate StatusCoverage

logo

SQL is not a problem to be solved - it's a powerful tool to be embraced.
This is the philosophy behind Kapper...


Kapper is a lightweight, Dapper-inspired ORM (Object-Relational Mapping) library written in Kotlin, targeting the JVM ecosystem. It embraces SQL rather than abstracting it away, providing a simple, intuitive API for executing queries and mapping results.

PostgresMySQLSQLiteOracleMSSQLDuckDBMariaDBCockroachDBYugabyteDBStarRocksTiDBFirebird

See Kapper for more information.

Philosophy

Instead of adding another abstraction layer, Kapper embraces three core principles:

  1. SQL is the Best Query Language: SQL has evolved over decades to be expressive, powerful, and optimised for database operations. Instead of hiding it, we should leverage it directly.

  2. Minimal Abstraction: Kapper provides just enough abstraction to make database operations comfortable in Kotlin, without trying to reinvent database interactions. Kapper prefers extension of existing APIs rather than abstraction of them.

  3. Transparency: What you write is what gets executed. There's no magic query generation or hidden database calls.

📖 Read more about Kapper's philosophy

Features

  • 🎯 SQL-First Approach: Write your SQL directly - no DSL or query builders
  • ⚡ High Performance: Near-JDBC performance with automatic object mapping
  • 🏗️ Auto-Mapping: Automatically map result sets to Kotlin data classes and Java records
  • 🔧 Custom Mappers: Full control with manual mapping for performance-critical paths
  • 🚀 Coroutines Support: First-class support for Kotlin coroutines with kapper-coroutines
  • 🌊 Flow Integration: Return query results as Kotlin Flow for reactive programming
  • 📦 Java Records: Native support for Java record classes alongside Kotlin data classes
  • 🔄 Transactions: Simple transaction handling with automatic commit/rollback
  • 📊 Bulk Operations: Efficient batch inserts, updates, and deletes with executeAll
  • ↩️ DML with Results: Execute DML statements that return records with executeReturning (where supported by the database)
  • 🗄️ Database Support: PostgreSQL, MySQL, SQLite, Oracle, MS SQL Server, DuckDB, and many others
  • 📏 Minimal Dependencies: Lightweight library with zero external dependencies
  • 🔌 JDBC Extension: Extends java.sql.Connection - works alongside existing JDBC code

📖 Explore all features in detail

Quick Start

data classUser(valid:UUID, valname:String, valemail:String?)
// Simple queryval users = connection.query<User>("SELECT * FROM users WHERE age > :age", "age" to 18)
// Insert data
connection.execute(
"INSERT INTO users(id, name, email) VALUES(:id, :name, :email)",
"id" to UUID.randomUUID(),
"name" to "Alice",
"email" to "alice@example.com"
)

Performance That Speaks for Itself

Kapper Performance Benchmarks

Kapper consistently outperforms other ORMs while maintaining the simplicity and transparency of SQL.

📚 Complete Documentation

Discover everything Kapper can do for your project! Visit our comprehensive documentation site:

📖 kapper.samyn.net

What you'll find:

Sponsors

YourKit

Special thanks to the kind people from YourKit for supporting open source projects and providing us with licenses for their profilers.

YourKit is the creator of YourKit Java Profiler, YourKit .NET Profiler,

Contributing

We welcome contributions! Please see our documentation site for guides and examples, or feel free to open an issue or submit a pull request.

License

Kapper is released under the Apache 2.0 License.

About

Kapper - A Dapper-like lightweight ORM for Kotlin

Resources

Code of conduct

Contributing

Stars

14 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages