[4기 유명한] Springboot-jpa weekly 미션 1차 PR입니다.#306
Open
yumyeonghan wants to merge 57 commits intoprgrms-be-devcourse:yumyeonghanfrom
Open
[4기 유명한] Springboot-jpa weekly 미션 1차 PR입니다.#306yumyeonghan wants to merge 57 commits intoprgrms-be-devcourse:yumyeonghanfrom
yumyeonghan wants to merge 57 commits intoprgrms-be-devcourse:yumyeonghanfrom
Conversation
added 27 commits
July 24, 2023 20:56
dojinyou
reviewed
Aug 5, 2023
src/test/java/com/programmers/jpa/item/domain/ItemRepositoryTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/programmers/jpa/item/domain/ItemRepositoryTest.java
Outdated
Show resolved
Hide resolved
seung-hun-h
reviewed
Aug 6, 2023
seung-hun-h
left a comment
There was a problem hiding this comment.
리뷰 남겼습니다~ 도진님이 리뷰를 잘 남겨주셔서 추가적인 리뷰는 없네요
Comment on lines
+50
to
+62
| public String getChef() { | ||
| if (!this.itemType.equals(FOOD)) { | ||
| throw new IllegalArgumentException("해당 상품은 음식이 아닙니다."); | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| public Long getPower() { | ||
| if (!this.itemType.equals(CAR)) { | ||
| throw new IllegalArgumentException("해당 상품은 자동차가 아닙니다."); | ||
| } | ||
| return null; | ||
| } |
There was a problem hiding this comment.
Item은 상품의 기본 정보만 담고 있고, 각 상품에 한정적인 부분은 추상 클래스에 포함할 필요는 없을 것 같아요.
특정 상품의 타입을 명시적으로 알아야 하는 경우라면 Item이 아닌 Car, Food 같은 특정 타입으로 사용하면 될 것 같아요.
그리고 Spring Data Jpa에서도 이런 상속 구조를 위해서 제네릭을 제공하는 것으로 보이네요
public interface ItemRepository<T extends Item> extends JpaRepository<T, Long> {
}
특정 상품의 타입을 명시적으로 알아야 하는 경우 라고 하면 getChef를 반드시 호출해야 하는 경우라고 볼 수 있을 것 같네요.
added 16 commits
August 6, 2023 13:58
seung-hun-h
approved these changes
Aug 6, 2023
| public FindResponse findById(Long id) { | ||
| return customerRepository.findById(id) | ||
| .map(FindResponse::from) | ||
| .orElseThrow(() -> new IllegalArgumentException("고객이 존재하지 않습니다.")); |
| @Transactional | ||
| public Long update(UpdateRequest updateRequest) { | ||
| Customer foundCustomer = customerRepository.findById(updateRequest.id()) | ||
| .orElseThrow(() -> new IllegalArgumentException("고객이 존재하지 않습니다.")); |
dojinyou
reviewed
Aug 8, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 과제 설명
미션1 : 2. JPA 소개(단일 엔티티를 이용한 CRUD를 구현)
미션2 : 3. 영속성컨텍스트(customer 엔티티를 이용하여 생명주기 실습)
미션3 : 4-2. 연관관계매핑(order, order_item, item의 연관관계 매핑 실습)
👩💻 요구 사항과 구현 내용