From d348728f74d6ac85c73c54d7e7cc9c7ac8ee88f9 Mon Sep 17 00:00:00 2001 From: Prasanna Selvaraj Date: Tue, 24 Jun 2025 08:58:30 +0800 Subject: [PATCH] Update booklore-api/src/main/java/com/adityachandel/booklore/repository/BookRepository.java Co-authored-by: Aditya Chandel <8075870+adityachandelgit@users.noreply.github.com> --- .../booklore/repository/BookRepository.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/repository/BookRepository.java b/booklore-api/src/main/java/com/adityachandel/booklore/repository/BookRepository.java index 45895e41c..65f815f54 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/repository/BookRepository.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/repository/BookRepository.java @@ -57,19 +57,19 @@ public interface BookRepository extends JpaRepository, JpaSpec """) List findAllFullBooks(); - @Query(""" +@Query(""" SELECT DISTINCT b FROM BookEntity b LEFT JOIN FETCH b.metadata m LEFT JOIN FETCH m.authors a LEFT JOIN FETCH m.categories - LEFT JOIN FETCH b.shelves - WHERE (b.metadata.title like %:text%) - OR (b.metadata.subtitle like %:text%) - OR (b.metadata.description like %:text%) - OR (b.metadata.seriesName like %:text%) - OR (a.name like %:text%) - """) - List findBooksContainingMetadata(@Param("text") String text); + WHERE LOWER(m.title) LIKE LOWER(CONCAT('%', :text, '%')) + OR LOWER(m.subtitle) LIKE LOWER(CONCAT('%', :text, '%')) + OR LOWER(m.description) LIKE LOWER(CONCAT('%', :text, '%')) + OR LOWER(m.seriesName) LIKE LOWER(CONCAT('%', :text, '%')) + OR LOWER(a.name) LIKE LOWER(CONCAT('%', :text, '%')) + ORDER BY m.title ASC +""") +List findBooksContainingMetadata(@Param("text") String text); }