AUTO-CONFIGURATION · CONDITIONS · OWNERSHIP

Spring Boot Exposed Activation and Ownership

JDBC activation can connect Exposed to a Spring DataSource and supply one specifically named transaction manager. R2DBC activation is intentionally thinner: the application still owns the pool, R2dbcDatabase, transaction scope, and shutdown.

01

START WITH OWNERSHIP

Do not carry the JPA auto-configuration assumption into Exposed

JPA / Hibernate

A convention-heavy persistence stack

DataSource → EntityManagerFactory → JpaTransactionManager → JPA repository proxy

Spring Boot can assemble a familiar, integrated persistence path around the JPA provider.

Provider state, dirty checking, and transaction interception become part of the programming model.

JetBrains Exposed

A deliberately bounded integration

JDBC: DataSource → Database.connect → named manager · R2DBC: mapping + repository factory

SQL, database objects, and coroutine transaction boundaries remain visible in application design.

R2DBC infrastructure and multi-call atomicity are application responsibilities, not inferred defaults.

02

SOURCE ARCHITECTURE

Read the JDBC and R2DBC activation paths side by side

The two modules share repository discovery and mapping concepts, but they do not own the same infrastructure. Open either source diagram to inspect its full resolution.

JDBC · container-participating path A DataSource unlocks the named manager contribution.
JDBC auto-configuration architecture showing application, Spring Boot, Exposed mapping, database connection, and transaction manager ownership
JDBC · container-participating path
JDBC auto-configuration architecture showing application, Spring Boot, Exposed mapping, database connection, and transaction manager ownership
R2DBC · application-owned infrastructure path Mapping is contributed; the pool and R2dbcDatabase remain outside.
R2DBC auto-configuration architecture showing application-owned pool and R2dbcDatabase beside Spring mapping and repository discovery
R2DBC · application-owned infrastructure path
R2DBC auto-configuration architecture showing application-owned pool and R2dbcDatabase beside Spring mapping and repository discovery
03

CONDITION LAB

Change one condition and inspect the resulting bean graph

Each scenario separates what Spring evaluates from what the application must still provide. The selected card drives both the condition/result ledger and the sequence diagram.

Condition evaluation

  1. MATCHED
    EntityClass on classpath

    The auto-configuration class is eligible.

  2. MATCHED
    DataSource bean available

    The named transaction manager method can run.

  3. MISSING
    No bean named springTransactionManager

    The JDBC auto-configuration does not back off.

Resulting ownership

  1. CREATED
    ExposedMappingContext created

    Spring Data can resolve Exposed entities.

  2. CREATED
    Database.connect(DataSource) invoked

    Exposed JDBC is attached to the application DataSource.

  3. CREATED
    Named manager created

    Repository proxies use springTransactionManager by default.

04

CALL → EVALUATE → RESULT

Activation sequence: application input first, framework result last

CREATED

JDBC ready

The DataSource exists and the default manager name is free, so the JDBC integration can contribute its complete bean set.

Boundary owner
Spring Boot contributes; application owns DataSource
Application configuration
Spring Boot
Condition evaluation
Exposed JDBC integration
  1. 1 CALL Provide DataSource and enable repositories
  2. 2 CALL Evaluate class, bean, and name conditions
  3. 3 CREATE Create mapping and named manager
  4. 4 RETURN Expose wired JDBC repositories
CREATED Mapping context, Exposed database connection, and named manager are available.
05

OWNERSHIP

Bean and lifecycle ownership is asymmetric

ConcernJDBC pathR2DBC pathOperational consequence
Repository discovery@EnableExposedJdbcRepositories@EnableExposedR2dbcRepositoriesThe application chooses package boundaries in both paths.
Mapping contextCreated when EntityClass is presentCreated only when missingA custom ExposedMappingContext wins on the R2DBC path.
Database objectDatabase.connect(DataSource) during manager creationApplication creates R2dbcDatabaseR2DBC startup and shutdown remain explicit.
Transaction managerCreates bean named springTransactionManager only when that name is missingNo ReactiveTransactionManager contributionJDBC proxy wiring is name-sensitive; R2DBC uses Exposed coroutine transactions.
Multi-call atomicitySpring service transaction can group callsWrap calls in one suspendTransactionRepository discovery does not define the business transaction boundary.
06

CONFIGURATION RECIPES

Minimal configurations by intent

IntentApplication suppliesEnable/wireVerify
Default JDBCDataSource@EnableExposedJdbcRepositoriesBean springTransactionManager exists and rollback spans two repository calls.
Custom JDBC managerNamed PlatformTransactionManagertransactionManagerRef = "ordersTransactionManager"Generated repository definition points to that exact name.
Coroutine R2DBCConnectionPool, R2dbcDatabase, lifecycle@EnableExposedR2dbcRepositoriesOne explicit suspendTransaction owns related operations.
JDBC + R2DBCBoth infrastructure setsSeparate repository packagesExactly one mapping context and unambiguous repository interfaces.
07

FAILURE DIAGNOSTICS

Diagnose activation from the missing condition, not from symptoms

SymptomLikely boundaryInspectCorrection
No Exposed beansEntityClass absentClasspath and condition reportAdd the matching Exposed DAO/core dependency or remove the integration.
JDBC repository cannot find a managerName mismatchtransactionManagerRef and bean namesProvide the exact referenced name or use the default name.
R2DBC repository starts but database access failsInfrastructure not constructedPool and R2dbcDatabase initializationCreate, register, and close application-owned infrastructure.
Two calls commit independentlyBoundary placed at repository methodsService call graphMove related operations into one Spring transaction or one suspendTransaction.
Unexpected mapping behaviorCustom context backs off auto-configurationExposedMappingContext beansKeep one intentional context and test entity resolution.
08

DECISION GUIDE

Choose the integration for the ownership model you want

DecisionPrefer JDBC integration when…Prefer R2DBC integration when…Do not assume
Execution modelThe request path is blocking and Spring transaction interception is desirable.The complete path is coroutine/non-blocking and explicit suspension is desirable.The web framework name alone decides the driver model.
InfrastructureA Spring-managed DataSource is already the stable boundary.The application can own pool creation, R2dbcDatabase, readiness, and shutdown.R2DBC auto-configuration creates those objects.
Transaction compositionSeveral repositories must join a service transaction.Related operations can be expressed in one explicit coroutine transaction.An enable annotation creates business atomicity.
CustomizationA named manager can be wired and tested explicitly.Explicit factories and database objects are acceptable application code.A declared but unused annotation attribute changes runtime behavior.
09

TRACEABLE CLAIMS

Claims are traceable to production code and focused tests

Claim Evidence files
JDBC activation is guarded by EntityClass and contributes mapping plus a conditionally named manager.
The JDBC manager path connects Exposed to the application DataSource.
JDBC repository discovery imports the registrar and JDBC auto-configuration.
The JDBC extension passes transactionManagerRef to generated repository factory beans.
JDBC repositories participate through Spring Data transactional factory support.
R2DBC auto-configuration contributes only a missing mapping context after the JDBC phase.
R2DBC repository discovery is explicit through its enable annotation and registrar.
The R2DBC extension admits suspend and Flow repository methods but does not consume transactionManagerRef.
R2DBC repositories use plain factory support and Exposed suspend transactions rather than Spring transaction interception.
The bilingual manual records the JDBC/R2DBC infrastructure and transaction ownership boundary.
Verification spring-and-ktor.md
Selected activation scenario: