You want to load a list of authors and show each author's name together with the titles of the books they wrote. The service looks up the authors and returns them, and outside the service (in the controller) the response is assembled by pulling each author's book titles. Complete LibraryService.findAuthors. Note: it's a one-author-to-many-books relationship. Assembling the response (pulling book titles) happens outside the service.
Complete a lookup service built on Spring Boot 3 and JPA (in-memory H2) that loads a list of authors and shows each author's name together with the titles of the books they wrote. It is a one-author-to-many-books relationship: the service returns the authors, and assembling the response (pulling out book titles) happens outside the service.
For a one-to-many association like author–books in JPA, an important topic is when and how the associated data is pulled out as you build the response after a lookup. The service layer that handles the lookup and the outer layer that assembles the response from its result are separated by a boundary. This problem is a data-access exercise in what you have to be mindful of when handling associated data across that boundary.