This folder describes the sqlcomponents multi-module Maven project: how it reads database metadata, maps it to a Java-friendly model, generates persistence-oriented Java sources, and how the datastore example module validates that story end-to-end.
The root README.md (sqlbridge notes, Docker, Maven commands) stays the quick operational entry; use this docs/ tree for architecture and module behavior.
SQL Components is a code generator built around JDBC:
- Connect to a live database using URL, credentials, and driver settings held in
Application. - Crawl catalog metadata (tables, columns, keys, indexes, procedures, types, …) into relational POJOs in the core module.
- Map columns and entities to Java types and ORM structures (today:
JavaMapperin the compiler module). - Generate Java source files with FreeMarker templates—notably a façade
DataManager, table-aligned…Storeclasses, andRecord/ enum-style types. - Consume the generated code from application or test code (the datastore module demonstrates this against PostgreSQL).
flowchart LR
subgraph ingest [Ingestion]
JDBC[JDBC metadata]
Crawler[Crawler in core]
end
subgraph model [Model]
App[Application ORM Entity]
end
subgraph gen [Generation]
JC[JavaCompiler]
FTL[FreeMarker templates]
end
subgraph use [Usage]
Stores[DataManager and Stores]
end
JDBC --> Crawler
Crawler --> App
App --> JC
FTL --> JC
JC --> Stores
Design intent (aligned with the root README themes): catch schema issues early, support multiple dialects, and emit readable Java that wraps SQL construction and execution—without replacing the database at runtime.
Read in this order if you are onboarding to the codebase:
| Order | Document | What you learn |
|---|---|---|
| 1 | Project structure | Directories, which Maven modules build from the root reactor, dependency direction, where templates and generated files live. |
| 2 | Core module | Crawler, relational model types, Application, Compiler SPI, YAML loading via CoreConsts. |
| 3 | Compiler module | JavaCompiler pipeline, JavaMapper, FreeMarker template layout, how tests configure output paths. |
| 4 | Datastore module | Example/integration tests, dependency on generated org.example code, building with mvn -f datastore/pom.xml. |
- CONTRIBUTING.md — How to propose changes, run checks, and interact with maintainers.
- LICENSE — Legal terms for using and redistributing the project.
- Upstream context in POM: https://github.com/sqlcomponents/sqlcomponents
- Root README.md — Docker Compose,
mvnrecipes, JDK notes.