Guest User

Answer.java

a guest
Feb 27th, 2019
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. package com.example.apidemo.model;
  2.  
  3. import javax.persistence.*;
  4.  
  5. import org.hibernate.annotations.OnDelete;
  6. import org.hibernate.annotations.OnDeleteAction;
  7.  
  8. import com.fasterxml.jackson.annotation.JsonIgnore;
  9.  
  10. @Entity
  11. @Table(name = "answers")
  12. public class Answer extends AuditModel {
  13.  
  14.     @Id
  15.     @GeneratedValue(generator = "answer_generator")
  16.     @SequenceGenerator(
  17.         name = "answer_generator",
  18.         sequenceName = "answer_sequence",
  19.         initialValue = 1000
  20.     )
  21.     private Long id;
  22.    
  23.     @Column(columnDefinition = "text")
  24.     private String text;
  25.  
  26.     @ManyToOne(fetch = FetchType.LAZY, optional = false)
  27.     @JoinColumn(name = "question_id", nullable = false)
  28.     @OnDelete(action = OnDeleteAction.CASCADE)
  29.     @JsonIgnore
  30.     private Question question;
  31.    
  32.     public String getText() {
  33.         return text;
  34.     }
  35.  
  36.     public void setText(String text) {
  37.         this.text = text;
  38.     }
  39.  
  40.     public Question getQuestion() {
  41.         return question;
  42.     }
  43.  
  44.     public void setQuestion(Question question) {
  45.         this.question = question;
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment