diff --git a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Answer.java b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Answer.java index 53d0d35..969119a 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Answer.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Answer.java @@ -4,6 +4,8 @@ package com.edufocus.edufocus.report.entity.vo; import com.edufocus.edufocus.quiz.entity.Quiz; import jakarta.persistence.*; import lombok.*; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; @Entity @Getter @@ -17,15 +19,21 @@ public class Answer { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; + + @Column private String userAnswer; + + @Column private boolean isCorrect; @ManyToOne @JoinColumn(name = "report_id") + @OnDelete(action = OnDeleteAction.CASCADE) private Report report; @ManyToOne @JoinColumn(name = "quiz_id") + @OnDelete(action = OnDeleteAction.CASCADE) private Quiz quiz; } diff --git a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java index 6e5d89a..9bb0440 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java @@ -46,13 +46,15 @@ public class Report { @ManyToOne @JoinColumn(name = "quizset_id") + @OnDelete(action = OnDeleteAction.CASCADE) private QuizSet quizSet; @ManyToOne @JoinColumn(name = "reportset_id") + @OnDelete(action = OnDeleteAction.CASCADE) private ReportSet reportSet; - @OneToMany(mappedBy = "report", cascade = CascadeType.REMOVE) + @OneToMany(mappedBy = "report") private List answers; public ReportResponse makeReportResponse() { diff --git a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java index c23547c..f5beca6 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java @@ -39,7 +39,7 @@ public class ReportSet { @Temporal(TemporalType.TIMESTAMP) private Date createAt; - @OneToMany(mappedBy = "reportSet", cascade = CascadeType.REMOVE) + @OneToMany(mappedBy = "reportSet") private List reports; @ManyToOne @@ -49,6 +49,7 @@ public class ReportSet { @ManyToOne @JoinColumn(name = "quizSet_id") + @OnDelete(action = OnDeleteAction.CASCADE) private QuizSet quizSet; public ReportSetResponse makeReportSetResponse() {