Skip to content
Latchkey

What Is a Data Mapper?

A data mapper is a separate layer responsible for transferring data between in-memory domain objects and the database without either side knowing about the other. Domain classes stay free of any storage code, and the mapper handles loading, saving, and mapping fields. Many ORMs implement this pattern under the hood.

Why it matters

Keeping persistence out of domain objects lets the model focus on behavior and rules. It also lets the database schema and the object model evolve somewhat independently.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →