107 lines
2.3 KiB
Java
107 lines
2.3 KiB
Java
package eu.eudat.migration.entities;
|
|
|
|
import org.hibernate.annotations.LazyCollection;
|
|
import org.hibernate.annotations.LazyCollectionOption;
|
|
|
|
import javax.persistence.*;
|
|
import java.util.Date;
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
@Entity
|
|
@Table(name = "answers")
|
|
public class Answer {
|
|
|
|
@Id
|
|
private Long id;
|
|
private String text;
|
|
@ManyToOne(fetch = FetchType.EAGER)
|
|
@JoinColumn(name = "user_id")
|
|
private User user;
|
|
@ManyToOne(fetch = FetchType.EAGER)
|
|
@JoinColumn(name = "question_id")
|
|
private Question question;
|
|
@Column(name = "created_at")
|
|
@Temporal(TemporalType.TIMESTAMP)
|
|
private Date createdAt;
|
|
@Column(name = "updated_at")
|
|
@Temporal(TemporalType.TIMESTAMP)
|
|
private Date updatedAt;
|
|
@ManyToMany(cascade = CascadeType.ALL)
|
|
@JoinTable(name = "answers_question_options",
|
|
joinColumns = {@JoinColumn(name = "answer_id")},
|
|
inverseJoinColumns = {@JoinColumn(name = "question_option_id")}
|
|
)
|
|
@LazyCollection(LazyCollectionOption.FALSE)
|
|
private Set<QuestionOption> questionOptions = new HashSet<>();
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Answer{" +
|
|
"id=" + id +
|
|
", text='" + text + '\'' +
|
|
", user=" + user +
|
|
", question=" + question +
|
|
", createdAt=" + createdAt +
|
|
", updatedAt=" + updatedAt +
|
|
", questionOptions=" + questionOptions +
|
|
'}';
|
|
}
|
|
|
|
public Long getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(Long id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getText() {
|
|
return text;
|
|
}
|
|
|
|
public void setText(String text) {
|
|
this.text = text;
|
|
}
|
|
|
|
public User getUser() {
|
|
return user;
|
|
}
|
|
|
|
public void setUser(User user) {
|
|
this.user = user;
|
|
}
|
|
|
|
public Question getQuestion() {
|
|
return question;
|
|
}
|
|
|
|
public void setQuestion(Question question) {
|
|
this.question = question;
|
|
}
|
|
|
|
public Date getCreatedAt() {
|
|
return createdAt;
|
|
}
|
|
|
|
public void setCreatedAt(Date createdAt) {
|
|
this.createdAt = createdAt;
|
|
}
|
|
|
|
public Date getUpdatedAt() {
|
|
return updatedAt;
|
|
}
|
|
|
|
public void setUpdatedAt(Date updatedAt) {
|
|
this.updatedAt = updatedAt;
|
|
}
|
|
|
|
public Set<QuestionOption> getQuestionOptions() {
|
|
return questionOptions;
|
|
}
|
|
|
|
public void setQuestionOptions(Set<QuestionOption> questionOptions) {
|
|
this.questionOptions = questionOptions;
|
|
}
|
|
}
|