Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @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;
- @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE })
- private Set<Answer> answers = new HashSet<>();
- }
- @Entity(name = "answer")
- public class Answer {
- @Id
- @Column(name = "answer_id")
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "answer_seq")
- @SequenceGenerator(name = "answer_seq", allocationSize = 1)
- private Long id;
- @Column(name = "answer_to_question")
- @NotBlank(message = "Answer to question name can not be blank")
- private String answer_to_question;
- @ManyToOne
- private Question question;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement