0PricingLogin
Spring Boot 4 Microservices & REST APIs · Lesson

Projections and DTOs

Select only the data you need.

Why Projections

Fetching whole entities when you need only a few columns wastes memory and bandwidth.

Projections let you select a subset of fields, returning lightweight objects instead of full entities.

Interface Projections

Declare an interface with getters for the fields you want. Spring Data implements it as a proxy.

public interface UserSummary {
    String getName();
    String getEmail();
}

All lessons in this course

  1. Dynamic Queries with Specifications
  2. Projections and DTOs
  3. Auditing with @CreatedDate
  4. Pagination and Sorting
← Back to Spring Boot 4 Microservices & REST APIs