Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.linksinnovation.elearning.model; import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonView; import com.linksinnovation.elearning.controller.jsonview.View; import java.util.Objects; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToOne; /** * * @author Jirawong Wongdokpuang <jirawong@linksinnovation.com> */ @Entity public class Answer { @Id @GeneratedValue private Long id; @JsonView(View.INFO.class) private boolean checked; private String answer; @ManyToOne @JsonBackReference private Quiz quiz; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public boolean isChecked() { return checked; } public void setChecked(boolean checked) { this.checked = checked; } public String getAnswer() { return answer; } public void setAnswer(String answer) { this.answer = answer; } public Quiz getQuiz() { return quiz; } public void setQuiz(Quiz quiz) { this.quiz = quiz; } @Override public int hashCode() { int hash = 7; hash = 37 * hash + Objects.hashCode(this.id); return hash; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Answer other = (Answer) obj; if (!Objects.equals(this.id, other.id)) { return false; } return true; } }