-For these three entities, `Book`, `Paperback` and `Ebook`, we have the corresponding repositories, `BookRepository`, `PaperbackRepository` and `EbookRepository`. But, if we write a query-method as `findByTitle()` we should duplicate it in each of these repositories in order to call `BookRepository#findByTitle()`, `PaperbackRepository#findByTitle()` and `EBookRepository#findByTitle()`. But, we know that `Paperback` and `Ebook` are actually subclasses of `Book`, therefore they inherit the `Book` class. It will be useful to do the same thing for our repositories. It will be better to write the `findById()` query-method only once and use it in all these repositories instead of duplicating it in each repository. This application shows you how to do it.
0 commit comments