Free your mind with JDBI
using explicit SQL mappers...
...in enterprise applications
Maciej Małecki, Architecture Community, Capgemini
2021.
↓
↓
↓
↔
Why?
1: SQL-POJO binding
2: SQL dialect-agnostic
3: transparent persistence
Transparent persistence
change detection
associations
no boundaries
fetching strategies
entity graphs
stateful session
⇯⇯⇯ hidden complexity ⇯⇯⇯
What are the SQL mappers?
When should I consider a mapper?
- 🧅, hexagonal, DDD
- "read-only" app - dump data on screen
- "write-only" app - data importers & updaters
- CQRS
- event sourcing
- "small" apps of any kind
SQL ↭ POJO mapper
fluent API
... or declarative API
wraps around JDBC
native SQL
no limitations
no fake persistence
get what you code
(and nothing more)
JDBI
example config in Spring
... and the same in Spring/Kotlin
Simple SELECT
... and in Kotlin
Simple INSERT
or simply
or bean mapped INSERT
Result beans
if names are excluded from the bytecode
... or use Kotlin
SQL Objects / Transactions
Templating
Find by criteria (Devonfw style)
Entity & event sourcing
DAO implementation for event sourcing