feat : cascade 추가
This commit is contained in:
parent
d4d8474eff
commit
d1e7f6d581
@ -4,6 +4,8 @@ package com.edufocus.edufocus.report.entity.vo;
|
|||||||
import com.edufocus.edufocus.quiz.entity.Quiz;
|
import com.edufocus.edufocus.quiz.entity.Quiz;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
import org.hibernate.annotations.OnDelete;
|
||||||
|
import org.hibernate.annotations.OnDeleteAction;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Getter
|
@Getter
|
||||||
@ -17,15 +19,21 @@ public class Answer {
|
|||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
|
@Column
|
||||||
private String userAnswer;
|
private String userAnswer;
|
||||||
|
|
||||||
|
@Column
|
||||||
private boolean isCorrect;
|
private boolean isCorrect;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "report_id")
|
@JoinColumn(name = "report_id")
|
||||||
|
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||||
private Report report;
|
private Report report;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "quiz_id")
|
@JoinColumn(name = "quiz_id")
|
||||||
|
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||||
private Quiz quiz;
|
private Quiz quiz;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,13 +46,15 @@ public class Report {
|
|||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "quizset_id")
|
@JoinColumn(name = "quizset_id")
|
||||||
|
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||||
private QuizSet quizSet;
|
private QuizSet quizSet;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "reportset_id")
|
@JoinColumn(name = "reportset_id")
|
||||||
|
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||||
private ReportSet reportSet;
|
private ReportSet reportSet;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "report", cascade = CascadeType.REMOVE)
|
@OneToMany(mappedBy = "report")
|
||||||
private List<Answer> answers;
|
private List<Answer> answers;
|
||||||
|
|
||||||
public ReportResponse makeReportResponse() {
|
public ReportResponse makeReportResponse() {
|
||||||
|
@ -39,7 +39,7 @@ public class ReportSet {
|
|||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date createAt;
|
private Date createAt;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "reportSet", cascade = CascadeType.REMOVE)
|
@OneToMany(mappedBy = "reportSet")
|
||||||
private List<Report> reports;
|
private List<Report> reports;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@ -49,6 +49,7 @@ public class ReportSet {
|
|||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "quizSet_id")
|
@JoinColumn(name = "quizSet_id")
|
||||||
|
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||||
private QuizSet quizSet;
|
private QuizSet quizSet;
|
||||||
|
|
||||||
public ReportSetResponse makeReportSetResponse() {
|
public ReportSetResponse makeReportSetResponse() {
|
||||||
|
Loading…
Reference in New Issue
Block a user