1. Concept library
  2. Java & Spring Boot
  3. Module 8: Data access with JPA

Concept

Entities and repositories

A JPA @Entity maps a class to a table, and a Spring Data repository interface gives you save, findById and derived queries without writing SQL. The method name is the query.

What a session covers

The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.

  1. Explain what @Entity maps and what a repository interface provides
  2. Write an entity and a derived query method
  3. Spot ddl-auto=update in production and replace it with migrations

In practice

A few lines that show Entities and repositories doing its job.

Java
@Entity
@Table(name = "orders")
public class Order {
    @Id @GeneratedValue private UUID id;
    @Column(nullable = false) private String customerEmail;
    @Enumerated(EnumType.STRING) private OrderStatus status;
    protected Order() {}
}

public interface OrderRepository extends JpaRepository<Order, UUID> {
    List<Order> findByCustomerEmailAndStatus(String email, OrderStatus status);
}

The common mistake

Watch for

Letting Hibernate generate the schema in production with ddl-auto=update. Column changes become silent drift; use migrations (Flyway or Liquibase) and set ddl-auto to validate.

What to know first

Your roadmap puts these before Entities and repositories, unless you already know them.

How it stays learned

Once a session shows you understand Entities and repositories, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.

  1. Day 3First recall, while it is fresh
  2. Day 7Second, a week on
  3. Day 18Last, when it has settled

Where it leads

Topics that build on Entities and repositories.

Next in the moduleRelationships →