Skip to content

Commit

Permalink
[refac] change JPQL to Query Method
Browse files Browse the repository at this point in the history
  • Loading branch information
PicturePark1101 committed Jul 14, 2024
1 parent f163519 commit 7d5d6ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public Favorite findById(final Long id) {
}

public List<Favorite> findAllByIds(final List<Long> ids) {
return favoriteRepository.findAllByIds(ids);
return favoriteRepository.findByIdIn(ids);
}

public List<Favorite> findAllByUserId(final Long userId) {
return favoriteRepository.findAllByUserId(userId);
return favoriteRepository.findByUserIdOrderByCreatedAtDesc(userId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ public interface FavoriteRepository extends JpaRepository<Favorite, Long> {
@Query("delete from Favorite f where f in :favorites")
void deleteAll(@Param("favorites") List<Favorite> favorites);

@Query("select f from Favorite f where f.id in :favoriteId")
List<Favorite> findAllByIds(@Param("favoriteId") List<Long> favoriteId);
List<Favorite> findByIdIn(@Param("favoriteId") List<Long> favoriteId);

@Query("select f from Favorite f where f.user.id = :userId order by f.createdAt desc")
List<Favorite> findAllByUserId(@Param("userId") Long userId);
}
List<Favorite> findByUserIdOrderByCreatedAtDesc(Long userId);
}

0 comments on commit 7d5d6ff

Please sign in to comment.