Skip to main content

Repository Pattern

Learn Repository Pattern (Enterprise Design Patterns, Enterprise Design Patterns) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

What is the Repository Pattern? A Repository mediates between the domain/business layer and the data-mapping layer, exposing a collection-like interface for accessing domain objects - callers work with methods like findById() , save() , findAll() as if they were querying an in-memory collection, without knowing or caring whether the data actually comes from a database, a file, or an in-memory cache. Why It's Useful • The rest of the application depends only on the Repository's interface, not on SQL/JDBC/JPA details. • Swapping the underlying storage (e.g. moving from an in-memory list to a...

More lessons in Enterprise Design Patterns