Skip to content
Ameen Abozaid
In reviewJNR-005-L08

Repository

  • Lesson 8 of 10
  • 11 min read
  • Junior
On This Lesson 4 topics

The content for this lesson is written and waiting for review. The outline below shows what it covers. It will be published once it is approved.

In this lesson

hide storage behind a collection-like interface.

Planned topics

  • Problem: domain code should not know about SQL or files.
  • A repository offers findById, save, findAll.
  • Domain code uses the interface; storage code implements it.
  • In tests, use an in-memory version.
  • Spring Data uses this idea.
Draft outline details

Demonstration

java
interface ProductRepository {
    Optional<Product> findBySku(Sku sku);
    void save(Product p);
}

Check your understanding

What does a repository hide?

Show answer

How and where data is stored.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.