kotlin-exposed-patterns

Implements database access patterns with JetBrains Exposed ORM, HikariCP pooling, and Flyway migrations.

Updated May 19, 2026
One-click install
npx skills add https://github.com/azusagasaku/--claude-config --skill kotlin-exposed-patterns-azusagasaku
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: kotlin-exposed-patterns
Source: https://github.com/azusagasaku/--claude-config/tree/main/skills/ecc/kotlin-exposed-patterns
Command: npx skills add https://github.com/azusagasaku/--claude-config --skill kotlin-exposed-patterns-azusagasaku

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up database access in Kotlin backend services requires coordinating an ORM, connection pooling, schema migrations, and transaction management, and mistakes in any layer cause connection leaks, unsafe coroutine usage, or untestable data code. ## Core Features & Use Cases - Exposed DSL and DAO Patterns: Write type-safe SQL queries with the DSL style or manage entity lifecycles with DAO entities, including joins, aggregations, subqueries, pagination, batch inserts, and upserts. - Production Database Setup: Configure HikariCP connection pooling, run versioned Flyway migrations at startup, and define tables with JSONB columns via kotlinx.serialization. - Repository Pattern and Testing: Wrap Exposed queries behind repository interfaces and test against an in-memory H2 database in PostgreSQL compatibility mode. - Use Case: When building a Ktor or Spring service backed by PostgreSQL, use these patterns to define tables, run migrations, and implement a coroutine-safe repository with paginated queries. ## Quick Start Ask the AI to set up an Exposed-based user repository with HikariCP pooling, Flyway migrations, and suspend transaction support for a Kotlin PostgreSQL service.

Frequently Asked Questions about kotlin-exposed-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write queries with JetBrains Exposed in Kotlin?▼

Exposed offers two styles: the DSL style uses Table.selectAll().where { } with type-safe column expressions, while the DAO style uses entity classes like UserEntity.find { } for lifecycle-managed objects. Both run inside transaction blocks and return mapped result rows.

Exposed DSL vs DAO pattern, which should I use?▼

Use the DSL style for simple, direct SQL-like queries where you map ResultRow objects manually. Use the DAO style when you need entity lifecycle management, relationships via referencedOn and referrersOn, and object-oriented updates to persisted rows.

How do I use Exposed with Kotlin coroutines?▼

Wrap all database operations in newSuspendedTransaction blocks, which run queries on a dispatcher suitable for blocking JDBC calls without blocking coroutine threads. You can also pass a specific Database instance and transaction isolation level as parameters.

Does Exposed support JSONB columns in PostgreSQL?▼

Yes, you can register a custom JSONB column type that serializes values with kotlinx.serialization and reads PGobject results from the PostgreSQL driver. The exposed-json module also provides built-in JSON support for common cases.

How do I test Exposed repositories without a real database?▼

Connect to an in-memory H2 database using the PostgreSQL compatibility mode URL, create tables with SchemaUtils.create in a beforeSpec hook, and delete all rows before each test. This keeps tests fast and isolated from external infrastructure.

Why do LIKE queries in Exposed risk wildcard injection?▼

User input containing % or _ characters is interpreted as SQL wildcards in LIKE patterns, producing unintended matches. Escape backslashes, percent signs, and underscores in the input before embedding it into the like expression.