-
Notifications
You must be signed in to change notification settings - Fork 152
[4기 황창현, 이현호] JPA Mission 3 - 도메인 연관관계 매핑 실습 #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 창현,현호-mission2
Are you sure you want to change the base?
The head ref may contain hidden characters: "\uCC3D\uD604,\uD604\uD638-mission3"
Conversation
src/main/java/com/programmers/springbootjpa/domain/order/Order.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
this.customer = customer; | ||
customer.getOrders().add(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분도 위쪽 리뷰를 참고하여 addOrder메소드를 만들어 정리해주세요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 add 메서드도 적용했습니다~!
적용 커밋: e3a73f6
this.customer = customer; | ||
customer.getOrders().add(this); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이쪽 부분에도 OrderItem연관관계 편의 메소드에서 사용할 add,remove 메소드를 만들 수 있을 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order역시 OrderItem과의 연관 관계는 단방향이라서 편의 메서드를 만들지 않았습니다.
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "item_id", referencedColumnName = "id") | ||
private Item item; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order, Item 클래스의 연관관계 편의 메소드를 만들어주세요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
단방향이라서 편의 메서드는 만들 수 없었습니다.
private String name; | ||
private Integer price; | ||
private Integer stockQuantity; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order 클래스의 리뷰를 참고하여 연관관계 편의 메소드에서 사용할 add,remove 메소드를 만들수 있을 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Item의 경우 단방향 연관관계로 매핑되어 있어서 편의 메서드를 쓸 수 없다고 생각했습니다!
창현님, 현호님 수고하셨습니다! 😀😀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 사항에 대해서는 재훈님이 잘 말씀해주신 것 같아서, 저는 간단하게 리뷰했습니다.
고생 많으셨어요!
class AssociationTest { | ||
|
||
@Autowired | ||
CustomerRepository customerRepository; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
필드 사이에 한칸 씩 띄우면 가독성이 더 좋아질 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 붙어있는 부분을 놓쳤네요. 적용했습니다~
적용 커밋: c6668a7
Customer savedCustomer = customerRepository.save(customer); | ||
Order savedOrder = orderRepository.save(order); | ||
Item savedItem = itemRepository.save(item); | ||
OrderItem savedOrderItem = orderItemRepository.save(orderItem); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전체적으로 조회에 대한 테스트인데, 메서드 별로 계속 given을 위해서 생성이 이루어지는 것 같습니다.
이를 매번 메서드에서 진행하지 않고, BeforeAll을 이용해서 한번만 필요한 customer, order, item, orderItem 을 저장해놓고
테스트 메서드에서는 조회만 진행해보면 어떨까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
공유할 수 있는 given자원에 대해 @transactional, @beforeeach를 통해 초기화 할 수 있도록 처리했습니다. 테스트 코드가 훨씬 간결해진 것 같네요!
적용 커밋: e136bc8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 반영했습니다~!! 확인 해주시면 너무 감사하겠습니다.
private String name; | ||
private Integer price; | ||
private Integer stockQuantity; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Item의 경우 단방향 연관관계로 매핑되어 있어서 편의 메서드를 쓸 수 없다고 생각했습니다!
this.customer = customer; | ||
customer.getOrders().add(this); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order역시 OrderItem과의 연관 관계는 단방향이라서 편의 메서드를 만들지 않았습니다.
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "item_id", referencedColumnName = "id") | ||
private Item item; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
단방향이라서 편의 메서드는 만들 수 없었습니다.
class AssociationTest { | ||
|
||
@Autowired | ||
CustomerRepository customerRepository; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 붙어있는 부분을 놓쳤네요. 적용했습니다~
적용 커밋: c6668a7
Customer savedCustomer = customerRepository.save(customer); | ||
Order savedOrder = orderRepository.save(order); | ||
Item savedItem = itemRepository.save(item); | ||
OrderItem savedOrderItem = orderItemRepository.save(orderItem); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
공유할 수 있는 given자원에 대해 @transactional, @beforeeach를 통해 초기화 할 수 있도록 처리했습니다. 테스트 코드가 훨씬 간결해진 것 같네요!
적용 커밋: e136bc8
🥇 요구 사항 및 구현 내용
미션3
연관 관계 매핑 실습
연관 관계 테스트 코드 작성