r2dbc: Spring Data R2DBC CRUD, DatabaseClient, reactive transactions and Testcontainers Postgres (post 2)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b4VQVEJWetTT1dYzyJ
This commit is contained in:
2026-10-29 04:16:34 +00:00
co-authored by Claude Sonnet 5.5
parent 89358e7b7c
commit 7d7d4e872e
27 changed files with 813 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
# r2dbc
Companion code for the ankurm.com post
[Reactive Data Access with Spring Data R2DBC: CRUD, Transactions and When to Choose It](https://ankurm.com/spring-data-r2dbc-crud-transactions/).
Spring Boot 4.1.2, JDK 25, Spring Data R2DBC, r2dbc-postgresql 1.1.3.RELEASE, PostgreSQL 17 (Testcontainers 2.0.5).
## What is in here
- `Customer`, `PurchaseOrder`, `Account`: plain records, one row each. No relationship mapping.
- `CustomerRepository`: `ReactiveCrudRepository`, derived queries, `@Query`, `@Modifying`.
- `CustomerOrderService`: three ways to load customers with orders (1+N, two queries, one JOIN with `DatabaseClient`).
- `AccountService`: `@Transactional` and `TransactionalOperator`, with rollback on error.
- `schema.sql`: run by Spring Boot through the R2DBC connection at startup.
- Tests use `StepVerifier` and write the transcripts in `output/`.
## Run
```bash
cd r2dbc
./scripts/run-all.sh # needs Docker; regenerates output/*.txt
```
`output/07-throughput-indicative.txt` is an indicative JDBC vs R2DBC run on a shared 2-vCPU sandbox.
Treat it as a harness, not a result: run it on your own hardware.