Skip to content

Commit

Permalink
fix: 중복 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
qormoon committed Jul 14, 2024
1 parent bc0de72 commit 0bc0f00
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public interface FlowerRepository extends JpaRepository<Flower, Long> {

List<Flower> findByName(String name);

@Query("SELECT DISTINCT f FROM Flower f WHERE f.name LIKE %: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)
List<Flower> findDistinctByNameContaining(@Param("name") String name);

@Query("SELECT DISTINCT f FROM Flower f")
@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)
Page<Flower> findDistinctAll(Pageable pageable);
}

0 comments on commit 0bc0f00

Please sign in to comment.