Browse Source

Initial REST API search support for a book by its title

Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.2-alpha
Pekka Helenius 4 years ago
parent
commit
fb254e1e3d
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java

+ 6
- 0
bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java View File

@ -2,15 +2,21 @@
package com.fjordtek.bookstore.model; package com.fjordtek.bookstore.model;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import org.springframework.data.repository.CrudRepository; 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<Book, Long> { public interface BookRepository extends CrudRepository<Book, Long> {
@Override @Override
public Optional<Book> findById(Long id); public Optional<Book> findById(Long id);
public List<Book> findByTitle(@Param("title") String title);
/* Assume a single book with a single ISBN, or multiple books with possibly duplicate ISBNs? /* 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, * 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 * this method must be changed, as well. Since database allows only UNIQUE values for ISBNs


Loading…
Cancel
Save