Exposed Spring Boot R2DBC Integration
Latest stable Based on Exposed release 1.11.0
A thin Spring Data repository adapter over an application-owned Exposed R2DBC runtime.
Problem
Section titled “Problem”This module registers Spring Data repository mapping and factories for Exposed R2DBC. Its auto-configuration is deliberately thin: it does not create an R2DBC ConnectionPool, an Exposed R2dbcDatabase, or a Spring reactive transaction manager. The application creates, configures, and closes the pool and R2dbcDatabase.

When to use it
Section titled “When to use it”Use it when an application already owns a working Exposed R2DBC runtime and wants Spring Data repository interfaces, derived queries, and repository scanning. Use the lower-level bluetape4k-exposed-r2dbc API directly when repository proxies add no value or when transaction composition must remain explicit everywhere.
Coordinates
Section titled “Coordinates”Import the ecosystem BOM and omit the module version:
dependencies { implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<version>")) implementation("io.github.bluetape4k.exposed:bluetape4k-exposed-spring-boot-r2dbc")}Core concepts
Section titled “Core concepts”@EnableExposedR2dbcRepositories discovers repository interfaces and connects them to ExposedR2dbcRepositoryFactory. The application must connect its R2dbcDatabase before repository calls; the repository factory does not inject or own a database. Individual methods in SimpleExposedR2dbcRepository open their own Exposed suspendTransaction; this gives one repository call a transaction, not an automatic transaction spanning several calls.
Quick start
Section titled “Quick start”Create the driver ConnectionFactory, wrap it in the application’s ConnectionPool, and connect an Exposed R2dbcDatabase so Exposed has the intended transaction target. Enable repository scanning, call one repository method from a suspend function, and close the pool during application shutdown.
@EnableExposedR2dbcRepositories(basePackageClasses = [MemberRepository::class])class PersistenceConfigurationThe exact pool options, credentials, lifecycle hooks, and R2dbcDatabase construction belong to the application, not this auto-configuration.
API by task
Section titled “API by task”- Define a repository by extending
ExposedR2dbcRepository<T, ID>. - Enable discovery with
@EnableExposedR2dbcRepositories. - Use supported derived-query methods through
PartTreeExposedR2dbcQuery. - Use
streamAll()when rows must be consumed as a true stream. - Wrap related calls in one explicit outer Exposed
suspendTransactionwhen they must commit or roll back together.
Recommended patterns
Section titled “Recommended patterns”Keep pool and R2dbcDatabase creation in one application infrastructure component and close them exactly once. Establish the intended Exposed database before using a repository. Prefer one explicit outer suspendTransaction for a multi-repository use case; repository calls can then participate in that Exposed transaction instead of relying on a Spring reactive transaction manager that this module does not provide.
Integrations
Section titled “Integrations”The module integrates Spring Data repository discovery with Exposed R2DBC query and repository implementations. Its factory deliberately bypasses Spring Data’s transaction interceptor for suspend methods and delegates to the Exposed implementation. It does not bridge Exposed transactions into Spring’s ReactiveTransactionManager; do not infer Spring @Transactional semantics from repository registration alone.
Configuration
Section titled “Configuration”Configure the R2DBC driver, pool limits, acquisition timeout, validation, and shutdown in the owning application. When more than one database exists, select the intended database with an explicit outer suspendTransaction or the database argument supported by streamAll(). Repository package scanning should remain narrow and does not itself select a database.
Failure modes
Section titled “Failure modes”- Repository startup fails because no
R2dbcDatabaseis available: create and expose the application-owned database before repository registration. - Two repository calls partially commit: they ran in separate internal
suspendTransactionblocks; wrap them in one explicit outersuspendTransaction. - Pool connections remain after shutdown: close the application-owned
ConnectionPool; the auto-configuration does not own it. - Cancellation becomes an application error: rethrow
CancellationExceptionafter cleanup so the Exposed transaction can unwind and the caller keeps cancellation semantics. - A
Flowconsumes memory unexpectedly:streamAll()andfindAll()usechannelFlowfor true row streaming, while operations such asfindAllById()andsaveAll()may collect results before emission.
Operations
Section titled “Operations”Observe pool acquisition time, active/idle connections, transaction duration, rows consumed, cancellation, and pool shutdown. Distinguish time waiting for a connection from time executing a query. A repository proxy being healthy does not prove the application-owned pool can acquire a connection.
Testing
Section titled “Testing”Test with the same driver and pool type used in production. Verify repository scanning, one-call commit and rollback, explicit multi-call atomicity, cancellation propagation, streamAll() incremental consumption, materialized-flow memory behavior, and pool closure. Include a negative test proving that two unwrapped repository calls are not one atomic unit.
Workshops and learning path
Section titled “Workshops and learning path”Run the Spring Boot R2DBC example, then read JDBC vs R2DBC and transaction boundaries. The Exposed R2DBC workshop develops the same ownership model through larger examples.
Limitations
Section titled “Limitations”This module does not provision connections, manage R2dbcDatabase lifecycle, create schema, or supply Spring reactive transaction management. Derived-query support is bounded by the release implementation. A flow-returning method is not necessarily a streaming database cursor; streamAll() is the explicit streaming path.
Release diagrams
Section titled “Release diagrams”These diagrams are loaded directly from README assets published with the 1.11.0 release and pinned to its immutable commit. They describe this manual’s released structure and runtime flows, not later Snapshot changes. Select a preview to open the SVG at the same release commit.
Spring Boot Exposed R2DBC coroutine repository wiring diagram
Section titled “Spring Boot Exposed R2DBC coroutine repository wiring diagram”Release README: spring-boot/r2dbc/README.md
Spring Boot Exposed R2DBC suspend query flow diagram
Section titled “Spring Boot Exposed R2DBC suspend query flow diagram”Release README: spring-boot/r2dbc/README.md

