data-source-patternslisted
Install: claude install-skill robsonkades/agent-skills
# Data Source Patterns
## Purpose
Pick the data-access pattern that matches the logic it will serve, and know precisely what
each one couples to what. Inspect both **who owns database access** and how independently
the object model must evolve from the schema. Shape alone does not classify a pattern.
The failure this prevents is choosing by default — JPA entities for everything because the
starter is on the classpath, or a hand-rolled DAO layer because the previous project had
one — and then fighting the consequences for years in code that looks like a mapping
problem but is a pattern-selection problem.
## The four patterns
```text
Table Data Gateway one gateway for a table or view; its SQL lives
there; methods take and return primitives or record
sets. No domain objects, no per-row identity.
Row Data Gateway one object per row; it holds the row's data and
knows how to load and save itself. No business
logic — that distinction is the whole point.
Active Record Row Data Gateway plus the business logic for that
row. Object shape follows table shape; persistence
is a method on the object.
Data Mapper a separate mapper moves data between objects and
tables. The objects know nothing about persistence,
so the two shapes may diverge freely.
```
An ORM like JPA/Hib