# jooq Companion module for the ankurm.com post **jOOQ with Spring Boot 4: Type-Safe SQL, Code Generation and Testcontainers**. | Piece | Version | |---|---| | Spring Boot | 4.2.0 | | jOOQ (managed by the Boot BOM) | 3.21.9 (3.21.10 is on Maven Central; Boot 4.2.0 does not manage it yet) | | Flyway (managed) | 12.11.0 | | PostgreSQL | 17 (`postgres:17-alpine`, 17.12) via Testcontainers 2.0.5 | | JDK | Temurin 25.0.5.1 | ## What is here ``` src/main/resources/db/migration/ V1 (schema) and V2 (isbn column): the single source of truth src/main/java/.../generated/ jOOQ output, committed, regenerated by scripts/codegen.sh src/main/java/.../BookshopRepository.java typed queries: RETURNING, dynamic WHERE, MULTISET, CTE + window, upsert, seek src/main/java/.../StockService.java transaction behaviour under Spring src/broken/ sources that must NOT compile; driven by scripts/compile-errors.sh src/test/java/ tests that write output/*.txt and assert the same facts ``` ## Run it ```bash export JAVA_HOME= scripts/run-all.sh # needs Docker; regenerates every file in output/ mvn test # just the tests (starts PostgreSQL 17 in Testcontainers) scripts/codegen.sh # throwaway PostgreSQL -> Flyway -> jOOQ codegen -> src/main/java ``` ## Output index | File | Shows | Written by | |---|---|---| | `output/00-codegen-run.txt` | the generator run and a before/after checksum | `scripts/codegen.sh` via `run-all.sh` | | `output/01-codegen-drift-check.txt` | committed generated code equals a fresh generation | `CodegenDriftTest` | | `output/02-autoconfig-and-insert-returning.txt` | dialect, listeners, `INSERT ... RETURNING`, identity column | `QueryTests` | | `output/03-dynamic-where.txt` | one method, three filter sets, three SQL statements | `QueryTests` | | `output/04-multiset.txt` | parent + children in one statement | `QueryTests` | | `output/05-cte-window.txt` | CTE + `rank()`, aggregate leaderboard | `QueryTests` | | `output/06-upsert-and-keyset.txt` | `ON CONFLICT DO UPDATE`, `seek()` | `QueryTests` | | `output/07-runtime-failure-of-plain-sql.txt` | a string-SQL typo fails at runtime | `QueryTests` | | `output/08-transactions.txt` | six transaction scenarios | `TransactionTests` | | `output/09-container-lifecycle-trap.txt` | per-class `@Container` + cached Spring context | `scripts/container-trap.sh` | | `output/10-compile-errors.txt` | what javac says for a wrong type, a typo, a dropped column | `scripts/compile-errors.sh` | | `output/11-drift-detected.txt` | the drift test failing after an unregenerated migration | `scripts/drift-demo.sh` | | `output/12-jooqtest-slice.txt` | what `@JooqTest` does and does not load | `JooqSliceTest` | | `output/13-startup-log-lines.txt` | jOOQ banner and the PostgreSQL dialect WARN | `scripts/startup-warnings.sh` | | `output/14-missing-flyway-database-module.txt` | Flyway 12 without `flyway-database-postgresql` | `scripts/missing-flyway-module.sh` |