Projections allow you to retrieve a subset of data from the database, which is more efficient than loading entire entities. This project uses interface-based projections:
AuthorProjection: Defines getId() and getName().QuoteProjection: Defines getId(), getName(), and getAuthor() (which returns an AuthorProjection).
When using findFirst10ByOrderByNameDesc(), Spring Data JPA will populate these interfaces with the requested data, minimizing the SQL query footprint.
interface AuthorProjection {
Integer getId();
String getName();
}
interface QuoteProjection {
Integer getId();
String getName();
AuthorProjection getAuthor();
}