Skip to content

Commit

Permalink
Fix: 안부전화 Cascade 순환참조 문제 해결 및 관계성 오류 해결 구현 (#100)
Browse files Browse the repository at this point in the history
fix: 안부전화 Cascade 순환참조 문제 해결 및 관계성 오류 해결
  • Loading branch information
GitJIHO authored Oct 21, 2024
1 parent b9e0fe3 commit 70f2f3c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ public class HelloCall {
@Enumerated(EnumType.STRING)
private HelloCall.Status status;

@OneToOne
@ManyToOne
@JoinColumn(name = "senior_id")
@NotNull
@OnDelete(action = OnDeleteAction.CASCADE)
private Senior senior;
@OneToMany(mappedBy = "helloCall", cascade = CascadeType.REMOVE)
@OneToMany(mappedBy = "helloCall")
private List<TimeSlot> timeSlots = new ArrayList<>();
@ManyToOne
@JoinColumn(name = "member_id")
private Member member;
@OneToMany(mappedBy = "helloCall", cascade = CascadeType.REMOVE)
@OneToMany(mappedBy = "helloCall")
private List<HelloCallTimeLog> helloCallTimeLogs = new ArrayList<>();

public HelloCall(LocalDate startDate, LocalDate endDate, int price, int serviceTime, String requirement, Senior senior) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.example.sinitto.member.entity.Member;
import jakarta.persistence.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

import java.time.LocalDateTime;

Expand All @@ -14,9 +16,11 @@ public class HelloCallTimeLog {
private LocalDateTime startDateAndTime;
private LocalDateTime endDateAndTime;
@ManyToOne
@OnDelete(action = OnDeleteAction.CASCADE)
@JoinColumn(name = "helloCall_id")
private HelloCall helloCall;
@ManyToOne
@OnDelete(action = OnDeleteAction.CASCADE)
@JoinColumn(name = "sinitto_id")
private Member member;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.example.sinitto.helloCall.exception.TimeRuleException;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

import java.time.LocalTime;

Expand All @@ -19,6 +21,7 @@ public class TimeSlot {
@NotNull
private LocalTime endTime;
@ManyToOne
@OnDelete(action = OnDeleteAction.CASCADE)
@JoinColumn(name = "hellocall_id")
private HelloCall helloCall;

Expand Down

0 comments on commit 70f2f3c

Please sign in to comment.