Personal notes and detailed explanations for the spring-relational-data-access module.
Following the official Spring Guide with H2 in-memory database.
| Section | File | Description |
|---|---|---|
| Customer.java | Source | Domain model for customer data |
| RelationalDataAccessApplication.java | Source | Main app with CommandLineRunner |
Path: src/main/java/com/example/relationaldataaccess/Customer.java
{What does this class do? Simple POJO to hold customer data from the database}
- Plain Java object (no annotations needed for JDBC)
- Maps to database table columns
{Personal observations, things you learned}
Path: src/main/java/com/example/relationaldataaccess/RelationalDataAccessApplication.java
{Main application that demonstrates JdbcTemplate usage}
| Annotation | Purpose |
|---|---|
@SpringBootApplication |
{What it does} |
| Method | Purpose |
|---|---|
execute() |
{DDL statements like CREATE TABLE} |
batchUpdate() |
{Insert multiple records} |
query() |
{Select with RowMapper} |
{Personal observations about JdbcTemplate, gotchas encountered}
| Test | Verifies |
|---|---|
contextLoads() |
{Application context starts} |
- {Pattern}: {Why we use it}
A: {Answer you discovered}
Extending beyond the guide with PostgreSQL and custom additions.
| Change | Why | ADR |
|---|---|---|
| H2 -> PostgreSQL | {Production-ready DB, learning real setup} | ADR-0001 |
| {Other enhancement} | {Reason} | ADR-XXXX |
# Docker command used
docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=pass postgres:16# application.properties changes
spring.datasource.url=jdbc:postgresql://localhost:5432/yourdb
spring.datasource.username=user
spring.datasource.password=pass{What was different from H2? Gotchas?}
{Notes on how Postgres runs in CI}
{What I learned about service containers}
{What you added, why, what you learned}
{What you added, why, what you learned}
| Test | Verifies |
|---|---|
| {test name} | {what it tests} |
{Notes on testing against real DB vs H2}
A: {Answer you discovered}
- Complete Phase 1 implementation
- Run
./mvnw clean verify - Commit Phase 1
- Add PostgreSQL dependency
- Update CI workflow
- Write ADR-0001 for Postgres switch