diff --git a/src/main/java/com/example/sinitto/helloCall/entity/HelloCall.java b/src/main/java/com/example/sinitto/helloCall/entity/HelloCall.java index 47877d29..9481d788 100644 --- a/src/main/java/com/example/sinitto/helloCall/entity/HelloCall.java +++ b/src/main/java/com/example/sinitto/helloCall/entity/HelloCall.java @@ -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 timeSlots = new ArrayList<>(); @ManyToOne @JoinColumn(name = "member_id") private Member member; - @OneToMany(mappedBy = "helloCall", cascade = CascadeType.REMOVE) + @OneToMany(mappedBy = "helloCall") private List helloCallTimeLogs = new ArrayList<>(); public HelloCall(LocalDate startDate, LocalDate endDate, int price, int serviceTime, String requirement, Senior senior) { diff --git a/src/main/java/com/example/sinitto/helloCall/entity/HelloCallTimeLog.java b/src/main/java/com/example/sinitto/helloCall/entity/HelloCallTimeLog.java index 4b1a3bdc..0133c297 100644 --- a/src/main/java/com/example/sinitto/helloCall/entity/HelloCallTimeLog.java +++ b/src/main/java/com/example/sinitto/helloCall/entity/HelloCallTimeLog.java @@ -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; @@ -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; diff --git a/src/main/java/com/example/sinitto/helloCall/entity/TimeSlot.java b/src/main/java/com/example/sinitto/helloCall/entity/TimeSlot.java index 14c47735..877150de 100644 --- a/src/main/java/com/example/sinitto/helloCall/entity/TimeSlot.java +++ b/src/main/java/com/example/sinitto/helloCall/entity/TimeSlot.java @@ -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; @@ -19,6 +21,7 @@ public class TimeSlot { @NotNull private LocalTime endTime; @ManyToOne + @OnDelete(action = OnDeleteAction.CASCADE) @JoinColumn(name = "hellocall_id") private HelloCall helloCall;