From fb254e1e3d8d3e699ffe5a8d98cdb324763b806b Mon Sep 17 00:00:00 2001 From: Pekka Helenius Date: Wed, 23 Sep 2020 01:29:57 +0300 Subject: [PATCH] Initial REST API search support for a book by its title Signed-off-by: Pekka Helenius --- .../java/com/fjordtek/bookstore/model/BookRepository.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java index 7fe6657..50d776e 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java @@ -2,15 +2,21 @@ package com.fjordtek.bookstore.model; +import java.util.List; import java.util.Optional; import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +@RepositoryRestResource public interface BookRepository extends CrudRepository { @Override public Optional findById(Long id); + public List findByTitle(@Param("title") String title); + /* Assume a single book with a single ISBN, or multiple books with possibly duplicate ISBNs? * For meanwhile, we have a UNIQUE constraint for ISBN values. If this policy changes, * this method must be changed, as well. Since database allows only UNIQUE values for ISBNs