创建新类名为测验班
@Entity
public class Quiz{
@Id
private int id;
private String quizName;
private String quizDescription;
private int passingScore;
private int totalScore;
// Getter and setters
}
问题.类会像这样
@Entity(name = "question")
public class Question extends DateAudit {
@Id
@Column(name = "question_id")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "question_seq")
@SequenceGenerator(name = "question_seq", allocationSize = 1)
private Long id;
@Column(name = "name")
@NotBlank(message = "Question name can not be blank")
private String name;
@Column(name = "is_exam_question", nullable = false)
private Boolean is_exam_question;
@OneToMany(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE },mappedBy="question")
private Set<Answer> answers = new HashSet<>();
@ManyToOne
private Quiz quiz;
}
@Entity
public class Tests{
private int id;
@ManyToOne
private Quiz quiz;
@ManyToOne
private User user;
private int score;
private String status; // failed or passed
}
我想这对你有帮助。请随意问我更多的问题。