Merge branch 'Be/Report' into 'backend'

[Back-End] feat : cascade 추가

See merge request s11-webmobile1-sub2/S11P12A701!154
This commit is contained in:
박정민 2024-08-09 16:43:52 +09:00
commit 7a1aaf8f80
3 changed files with 13 additions and 2 deletions

View File

@ -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;
}

View File

@ -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<Answer> answers;
public ReportResponse makeReportResponse() {

View File

@ -39,7 +39,7 @@ public class ReportSet {
@Temporal(TemporalType.TIMESTAMP)
private Date createAt;
@OneToMany(mappedBy = "reportSet", cascade = CascadeType.REMOVE)
@OneToMany(mappedBy = "reportSet")
private List<Report> reports;
@ManyToOne
@ -49,6 +49,7 @@ public class ReportSet {
@ManyToOne
@JoinColumn(name = "quizSet_id")
@OnDelete(action = OnDeleteAction.CASCADE)
private QuizSet quizSet;
public ReportSetResponse makeReportSetResponse() {