Skip to content

Commit

Permalink
chore: repository에 어노테이션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Yeji committed Nov 2, 2024
1 parent 45cb73c commit 00edf74
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

import static org.samtuap.inong.common.exceptionType.ProductExceptionType.FARM_NOT_FOUND;

@Repository
public interface FarmRepository extends JpaRepository<Farm, Long> {
default Farm findByIdOrThrow(Long farmId) {
return findById(farmId).orElseThrow(() -> new BaseCustomException(FARM_NOT_FOUND));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

import static org.samtuap.inong.common.exceptionType.ProductExceptionType.PRODUCT_NOT_FOUND;

@Repository
public interface PackageProductRepository extends JpaRepository<PackageProduct, Long> {
@Query("SELECT p FROM PackageProduct p WHERE p.id IN :ids")
List<PackageProduct> findAllByIds(@Param("ids") List<Long> ids);
Expand Down

0 comments on commit 00edf74

Please sign in to comment.