Spring Data JPA: Replace N Queries with Single Query

Understanding query improvement tricks as a software engineer