Exposed
Exposed is the SQL framework used by every Arda backend service for PostgreSQL persistence. It is chosen for its idiomatic Kotlin DSL, type safety, and explicit transaction scoping — properties that align with Arda’s bitemporal persistence model and AppError contract.
- Version:
0.60.0. - Database: PostgreSQL (production); ContainerizedPostgres test fixture for unit/integration tests.
- Repositories:
operations/,accounts-component/,common-module/(sharedTabledefinitions and converters).
Conventions in this codebase
Section titled “Conventions in this codebase”- DAO layer is not used. Exposed’s “DSL” API is the only API in
use. Per-table
Tableobjects describe schema; queries useselect,insert,updateagainst those. - Transactions are explicit. Every database access is wrapped in a
transaction(database) { ... }block at a well-defined boundary (typically a use case or service method). No implicit “request transaction”. - Bitemporal columns (
valid_from,valid_to,tx_from,tx_to) are part of every business-state table. See Bitemporal Persistence. - Schema migrations are owned by Flyway, not Exposed. Exposed
describes the current schema; Flyway migrations under
db/migration/evolve it. - Error handling: SQL errors are caught at the boundary and mapped
to the
AppErrorsealed hierarchy. See Exception Handling.
UpdateBuilder.set has no already-initialized guard
Section titled “UpdateBuilder.set has no already-initialized guard”In Exposed 0.60.0, UpdateBuilder.set ends in a plain values[column] = value. Setting the same column twice in one statement does not warn and does not fail — the last write wins, silently.
That matters wherever two writers can reach one column: a framework populating an envelope and a hand-written fill body populating the same column will both succeed, and which value lands depends on call order rather than on intent.
Where a column has more than one possible writer, make one of them the only one. Where that is not possible, assert the column’s value after the statement rather than trusting that the intended writer ran last.
Authoritative references
Section titled “Authoritative references”- Exposed documentation — official.
- Exposed wiki on GitHub — deeper reference for the DSL and Table API.
See also
Section titled “See also”- Kotlin Coding Standards — Result
handling and AppError patterns applied at every Exposed boundary; see
Persistence and Transactions
for the Universe-vs-plain-table decision and the
DBIOtransaction contract. - The
unit-tests-infraskill —ContainerizedPostgresand the Harness pattern for database-backed tests. - Data Authority Pattern — module boundary rules around shared tables.
Copyright: © Arda Systems 2025-2026, All rights reserved