Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.apidemo.model;
- import javax.persistence.*;
- import org.hibernate.annotations.OnDelete;
- import org.hibernate.annotations.OnDeleteAction;
- import com.fasterxml.jackson.annotation.JsonIgnore;
- @Entity
- @Table(name = "answers")
- public class Answer extends AuditModel {
- @Id
- @GeneratedValue(generator = "answer_generator")
- @SequenceGenerator(
- name = "answer_generator",
- sequenceName = "answer_sequence",
- initialValue = 1000
- )
- private Long id;
- @Column(columnDefinition = "text")
- private String text;
- @ManyToOne(fetch = FetchType.LAZY, optional = false)
- @JoinColumn(name = "question_id", nullable = false)
- @OnDelete(action = OnDeleteAction.CASCADE)
- @JsonIgnore
- private Question question;
- public String getText() {
- return text;
- }
- public void setText(String text) {
- this.text = text;
- }
- public Question getQuestion() {
- return question;
- }
- public void setQuestion(Question question) {
- this.question = question;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment