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();
}