Class BookRepository

java.lang.Object
io.micronaut.data.tck.repositories.BookRepository
All Implemented Interfaces:
CrudRepository<Book,Long>, GenericRepository<Book,Long>, JpaSpecificationExecutor<Book>, PageableRepository<Book,Long>, SimpleBookRepository

public abstract class BookRepository extends Object implements PageableRepository<Book,Long>, JpaSpecificationExecutor<Book>, SimpleBookRepository
  • Field Details

  • Constructor Details

  • Method Details

    • findAll

      public abstract Page<Book> findAll(PredicateSpecification<Book> spec, Pageable pageable)
      Description copied from interface: JpaSpecificationExecutor
      Returns a Page of entities matching the given QuerySpecification.
      Specified by:
      findAll in interface JpaSpecificationExecutor<Book>
      Parameters:
      spec - The query specification
      pageable - The pageable object
      Returns:
      a page
    • findAllByStudentsNameIn

      public abstract Page<Book> findAllByStudentsNameIn(List<String> names, Pageable pageable)
    • save

      @NonNull public abstract @NonNull Book save(@NonNull @NonNull Book book)
      Description copied from interface: CrudRepository
      Saves the given valid entity, returning a possibly new entity representing the saved state. Note that certain implementations may not be able to detect whether a save or update should be performed and may always perform an insert. The CrudRepository.update(Object) method can be used in this case to explicitly request an update.
      Specified by:
      save in interface CrudRepository<Book,Long>
      Specified by:
      save in interface SimpleBookRepository
      Parameters:
      book - The entity to save. Must not be null.
      Returns:
      The saved entity will never be null.
    • findBooks

      @Query("SELECT book_.* FROM book book_ ORDER BY book_.title ASC LIMIT :limit OFFSET :offset") public abstract List<Book> findBooks(int limit, int offset)
    • queryByTitle

      public abstract Book queryByTitle(String title)
    • listPageableCustomQuery

      @Query(value="SELECT book_.* FROM book book_ LEFT JOIN author book_author_ ON book_.author_id = book_author_.id", countQuery="SELECT count(*) FROM book book_ ") public abstract Page<Book> listPageableCustomQuery(Pageable pageable)
    • findAll

      @NonNull public abstract @NonNull Page<Book> findAll(@NonNull @NonNull Pageable pageable)
      Description copied from interface: PageableRepository
      Finds all records for the given pageable.
      Specified by:
      findAll in interface PageableRepository<Book,Long>
      Parameters:
      pageable - The pageable.
      Returns:
      The results
    • findAllSorted

      @Find public abstract Page<Book> findAllSorted(Pageable pageable)
    • findAllSorted2

      @Find public abstract Page<Book> findAllSorted2(Pageable pageable)
    • findByTotalPagesGreaterThan

      public abstract Page<Book> findByTotalPagesGreaterThan(int totalPages, Pageable pageable)
    • findAllByTitleStartingWith

      public abstract List<Book> findAllByTitleStartingWith(String text)
    • findByAuthorIsNull

      public abstract List<Book> findByAuthorIsNull()
    • findByAuthorIsNotNull

      public abstract List<Book> findByAuthorIsNotNull()
    • countByTitleIsEmpty

      public abstract int countByTitleIsEmpty()
    • countByTitleIsNotEmpty

      public abstract int countByTitleIsNotEmpty()
    • findByAuthorName

      public abstract List<Book> findByAuthorName(String name)
    • findTop3OrderByTitle

      public abstract List<Book> findTop3OrderByTitle()
    • findTop3ByAuthorNameOrderByTitle

      public abstract Stream<Book> findTop3ByAuthorNameOrderByTitle(String name)
    • queryTop3ByAuthorNameOrderByTitle

      public abstract List<Book> queryTop3ByAuthorNameOrderByTitle(String name)
    • deleteByTitleIsEmptyOrTitleIsNull

      public abstract void deleteByTitleIsEmptyOrTitleIsNull()
    • findByTitle

      public abstract Book findByTitle(String title)
    • findAuthorById

      public abstract Author findAuthorById(@Id Long id)
    • listNativeBooks

      @Query(value="select * from book b where b.title like :arg0 limit 5", nativeQuery=true) public abstract List<Book> listNativeBooks(String arg0)
    • listNativeBooksWithTitleInCollection

      @Query(value="select * from book b where b.title in (:arg0)", nativeQuery=true) public abstract List<Book> listNativeBooksWithTitleInCollection(@Nullable @Nullable Collection<String> arg0)
    • listNativeBooksWithTitleInArray

      @Query(value="select * from book b where b.title IN (:arg0)", nativeQuery=true) public abstract List<Book> listNativeBooksWithTitleInArray(@Expandable @TypeDef(type=STRING) @Nullable @Nullable String[] arg0)
    • listNativeBooksWithTitleAnyCollection

      @Query(value="select * from book b where b.title = any (:arg0)", nativeQuery=true) public abstract List<Book> listNativeBooksWithTitleAnyCollection(@Nullable @Nullable Collection<String> arg0)
    • listNativeBooksWithTitleAnyArray

      @Query(value="select * from book b where b.title = ANY (:arg0)", nativeQuery=true) public abstract List<Book> listNativeBooksWithTitleAnyArray(@TypeDef(type=STRING) @Nullable @Nullable String[] arg0)
    • listNativeBooksNullableListAsStringArray

      @Query(value="select * from book where (CASE WHEN exists ( select (:arg0) ) THEN title = ANY (:arg0) ELSE true END)", nativeQuery=true) public abstract List<Book> listNativeBooksNullableListAsStringArray(@Nullable @TypeDef(type=STRING_ARRAY) @Nullable List<String> arg0)
    • listNativeBooksNullableArrayAsStringArray

      @Query(value="select * from book where (CASE WHEN exists ( select (:arg0) ) THEN title = ANY (:arg0) ELSE true END)", nativeQuery=true) public abstract List<Book> listNativeBooksNullableArrayAsStringArray(@Nullable @TypeDef(type=STRING_ARRAY) @Nullable String[] arg0)
    • updateAuthorCustom

      @Query("UPDATE book SET author_id = :author WHERE id = :id") public abstract long updateAuthorCustom(@Parameter("id") Long id, @Parameter("author") Author author)
    • updateAuthor

      public abstract long updateAuthor(@Parameter("id") @Id Long id, @Parameter("author") Author author)
    • updateByIdInList

      public abstract void updateByIdInList(List<Long> id, String title)
    • saveAuthorBooks

      public void saveAuthorBooks(List<AuthorBooksDto> authorBooksDtos)
    • newAuthor

      protected Author newAuthor(String name)
    • newBook

      protected Book newBook(Author author, String title, int pages)
    • deleteByIdAndAuthorId

      public abstract int deleteByIdAndAuthorId(Long id, Long authorId)
    • save

      public abstract Book save(String title, int totalPages, Author author)
    • deleteByAuthor

      public abstract int deleteByAuthor(Author author)
    • findAllByGenre

      public abstract List<Book> findAllByGenre(Genre genre)
    • findOne

      public abstract Optional<Book> findOne(@Nullable @Nullable PredicateSpecification<Book> spec)
      Description copied from interface: JpaSpecificationExecutor
      Returns a single entity matching the given PredicateSpecification.
      Specified by:
      findOne in interface JpaSpecificationExecutor<Book>
      Parameters:
      spec - The query specification
      Returns:
      optional found result
    • findAll

      public abstract List<Book> findAll(@Nullable @Nullable PredicateSpecification<Book> spec)
      Description copied from interface: JpaSpecificationExecutor
      Returns all entities matching the given PredicateSpecification.
      Specified by:
      findAll in interface JpaSpecificationExecutor<Book>
      Parameters:
      spec - The query specification
      Returns:
      found results
    • findAllByCriteria

      public abstract List<Book> findAllByCriteria(PredicateSpecification<Book> spec)
    • findByTitleOrAuthorAndId

      public abstract Book findByTitleOrAuthorAndId(String title, Author author, Long id)
    • findAllByChaptersTitle

      public abstract List<Book> findAllByChaptersTitle(String chapterTitle)
    • findAllByChaptersTitleAndTitle

      public abstract List<Book> findAllByChaptersTitleAndTitle(String chapterTitle, String title)
    • findByAuthors

      @Query("SELECT b FROM Book b WHERE b.author in :authors") public abstract List<Book> findByAuthors(List<Author> authors)
    • findByAuthorIds

      @Query("SELECT b FROM Book b WHERE b.author.id in :authorIds") public abstract List<Book> findByAuthorIds(List<Long> authorIds)
    • findByAuthorInList

      public abstract List<Book> findByAuthorInList(List<Author> authors)
    • findBooksByTotalPages

      @Query(value="SELECT * FROM book WHERE total_pages = :totalPages", countQuery="SELECT COUNT(*) FROM book WHERE total_pages = :totalPages", nativeQuery=true) public abstract Page<Book> findBooksByTotalPages(int totalPages, Pageable pageable)