-
Notifications
You must be signed in to change notification settings - Fork 152
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
[4기 전선희] Mission 3 PR 제출합니다! #288
base: funnysunny08-mission03
Are you sure you want to change the base?
[4기 전선희] Mission 3 PR 제출합니다! #288
Conversation
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.
선희님 3번째 과제까지 고생하셨습니다~~ 👍👍 간단한 리뷰 남겼습니다! 참고해주세요~
p.s 연관 관계에 대한 다이어그램까지 있다면 좋을 것 같아요~~ 😄
@Column(nullable = false) | ||
private String lastName; | ||
|
||
@OneToMany(mappedBy = "customer", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) |
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.
각 옵션에 대해 알고 계신가요~?
customer.setId(1L); | ||
customer.setFirstName("honggu"); | ||
customer.setLastName("Kang"); |
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.
Setter
가 어디서 선언된거죠..😂 Setter
보다 생성자를 활용하면 좋을 것 같아요~
|
||
// Then | ||
Customer entity = repository.findById(1L).get(); | ||
log.info("{} {}", entity.getLastName(), entity.getFirstName()); |
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.
log를 남기기 보다 값을 검증해보면 좋을 것 같아요!
private Long id; | ||
|
||
@Column(name = "memo", nullable = true) | ||
@Setter |
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.
Setter
보다 의미있는 메서드를 사용하는게 좋다는 거 아시죠~?
@Column(name = "order_date_time", columnDefinition = "TIMESTAMP", nullable = false) | ||
private LocalDateTime orderDateTime; | ||
|
||
@ManyToOne(fetch = FetchType.EAGER) |
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.
FetchType
에 대해 잘 알고 계신가요? EAGER
로 하신 이유가 궁금합니다
private Customer customer; | ||
|
||
@OneToMany(mappedBy = "order", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) | ||
private List<OrderItem> orderItems; |
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.
기본 리스트를 가지고 있으면 좋을 것 같아요!
setOrderItem(orderItem); | ||
} | ||
|
||
private void setOrderItem(OrderItem orderItem) { | ||
if (Objects.nonNull(this.orderItem)) { | ||
this.orderItem.getItems().remove(this); | ||
} | ||
|
||
this.orderItem = orderItem; | ||
orderItem.getItems().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.
어떤 의도를 가지고 private
으로 두고 생성자에서 추가하는 방식을 선택하셨는지 궁금합니다~
@Entity | ||
@Table(name = "items") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class 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.
Item
을 재사용할 수 있나요?
📌 과제 설명
springboot-jpa mission 3 구현
👩💻 요구 사항과 구현 내용