From 611c6f961943b1bf25e3e0d4648c3f2fa5d22508 Mon Sep 17 00:00:00 2001 From: jihyeon baek Date: Sun, 14 Jul 2024 17:37:38 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=BF=BC=EB=A6=AC=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fiurinee/domain/flower/repository/FlowerRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/fiurinee/domain/flower/repository/FlowerRepository.java b/src/main/java/com/example/fiurinee/domain/flower/repository/FlowerRepository.java index c93c60f..bb0370d 100644 --- a/src/main/java/com/example/fiurinee/domain/flower/repository/FlowerRepository.java +++ b/src/main/java/com/example/fiurinee/domain/flower/repository/FlowerRepository.java @@ -21,9 +21,9 @@ public interface FlowerRepository extends JpaRepository { List findByName(String name); - @Query(value = "SELECT * FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY name ORDER BY flower_id) as row_num FROM flower) as flowers WHERE row_num = 1 AND name LIKE %:name%", nativeQuery = true) + @Query(value = "SELECT DISTINCT ON (f.name) f.* FROM flower f WHERE f.name LIKE %:name%", nativeQuery = true) List findDistinctByNameContaining(@Param("name") String name); - @Query(value = "SELECT * FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY name ORDER BY flower_id) as row_num FROM flower) as flowers WHERE row_num = 1", nativeQuery = true) + @Query(value = "SELECT DISTINCT ON (f.name) f.* FROM flower f", nativeQuery = true) Page findDistinctAll(Pageable pageable); }