-
Notifications
You must be signed in to change notification settings - Fork 78
[Spring Data Jpa] 김예진 미션 제출합니다. #192
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: dpwls0125
Are you sure you want to change the base?
Changes from all commits
8738242
11e2ea3
7a6895e
36ca88a
86293d3
52ccca6
476dee3
9a5d45a
f1473d5
3c9f56a
0492ab9
1481f0e
6c480c3
dc94c4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package roomescape.member; | ||
|
||
import org.springframework.data.repository.CrudRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface MemberRepository extends CrudRepository<Member, Long> { | ||
Optional<Member> findByEmailAndPassword(String email, String password); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package roomescape.reservation; | ||
|
||
public class MyReservationResponse { | ||
|
||
private Long id; | ||
private String theme; | ||
private String date; | ||
private String time; | ||
private String status; | ||
|
||
public MyReservationResponse(Long id, String theme, String date, String time, String status) { | ||
this.id = id; | ||
this.theme = theme; | ||
this.date = date; | ||
this.time = time; | ||
this.status = status; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public String getTheme() { | ||
return theme; | ||
} | ||
|
||
public String getDate() { | ||
return date; | ||
} | ||
|
||
public String getTime() { | ||
return time; | ||
} | ||
|
||
public String getStatus() { | ||
return status; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,66 @@ | ||
package roomescape.reservation; | ||
|
||
import jakarta.persistence.*; | ||
import roomescape.member.Member; | ||
import roomescape.theme.Theme; | ||
import roomescape.time.Time; | ||
import roomescape.time.ParticipationTime; | ||
|
||
@Entity | ||
public class Reservation { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "reservation_id", nullable = false) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
|
||
@Column(nullable = false) | ||
private String date; | ||
private Time time; | ||
|
||
@ManyToOne | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ManyToOne 안의 옵션을 보면 fetch 라는 옵션이 있어요. 기본이 EAGER로 되어있는데요, EAGER와 LAZY의 차이가 뭘까요? 어떤 옵션을 선택하는게 좋을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EAGER와 LAZY 의 차이는 언제 데이터를 언제 불러올 것인가의 시점 차이라고 생각합니다. EAGER의 경우, JPA가 해당 엔티티를 조회할 때 연관 데이터를 즉시 로드하고, LAZY의 경우, 불필요한 데이터를 로딩하지 않고 실제 사용될 경우에 로딩합니다. 따라서 연관 데이터 전체가 반드시 사용되는 경우라면, 관련 데이터를 N번 쿼리하게 되는 N+1 문제를 방지하기 위해 즉시 로딩 전략을 사용하는게 좋을 것 같지만, 연관 데이터가 항상 사용되는 것이 아니라면 과도한 메모리 사용을 방지하기 위해 지연 로딩 전략을 사용하는게 좋을 것 같습니다. |
||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "time_id") | ||
private ParticipationTime participationTime; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "theme_id") | ||
private Theme theme; | ||
|
||
public Reservation(Long id, String name, String date, Time time, Theme theme) { | ||
public Reservation(Long id, String name, String date, ParticipationTime participationTime, Theme theme, Member member) { | ||
this.id = id; | ||
this.name = name; | ||
this.date = date; | ||
this.time = time; | ||
this.participationTime = participationTime; | ||
this.theme = theme; | ||
this.member = member; | ||
} | ||
|
||
public Reservation(Long id, String name, String date, ParticipationTime participationTime, Theme theme) { | ||
this.id = id; | ||
this.name = name; | ||
this.date = date; | ||
this.participationTime = participationTime; | ||
this.theme = theme; | ||
} | ||
|
||
public Reservation(String name, String date, ParticipationTime participationTime, Theme theme) { | ||
this.name = name; | ||
this.date = date; | ||
this.participationTime = participationTime; | ||
this.theme = theme; | ||
} | ||
|
||
public Reservation(String name, String date, Time time, Theme theme) { | ||
public Reservation(String name, String date, ParticipationTime participationTime, Theme theme, Member member) { | ||
this.name = name; | ||
this.date = date; | ||
this.time = time; | ||
this.participationTime = participationTime; | ||
this.theme = theme; | ||
this.member = member; | ||
} | ||
|
||
public Reservation() { | ||
|
@@ -41,8 +79,8 @@ public String getDate() { | |
return date; | ||
} | ||
|
||
public Time getTime() { | ||
return time; | ||
public ParticipationTime getTime() { | ||
return participationTime; | ||
} | ||
|
||
public Theme getTheme() { | ||
|
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.
오호, 많은 Repository 아류 인터페이스들이 있는데 Crud를 선택한 이유가 있을까요?
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.
현재 상황에서는 페이징이나 정렬과 같은 기능이 필요하다 생각하지 않아, 기본적인 crud만 제공하는 인터페이스를 사용했습니다.