Commit | Line | Data |
---|---|---|
5d05ee58 MS |
1 | /* |
2 | * To change this template, choose Tools | Templates | |
3 | * and open the template in the editor. | |
4 | */ | |
5 | package org.ufcspa.simdecs.bn.entity; | |
6 | ||
7 | import java.io.Serializable; | |
8 | import java.util.List; | |
9 | import javax.persistence.*; | |
10 | ||
11 | /** | |
12 | * | |
13 | * @author mchelem | |
14 | */ | |
15 | @Entity | |
16 | public class Question implements Serializable { | |
17 | private static final long serialVersionUID = 1L; | |
18 | @Id | |
19 | @GeneratedValue(strategy = GenerationType.AUTO) | |
20 | private Long id; | |
21 | ||
22 | private String text; | |
23 | ||
24 | @OneToMany(cascade = javax.persistence.CascadeType.ALL, mappedBy = "question") | |
25 | private List<Answer> answers; | |
26 | ||
27 | @ManyToOne | |
28 | private Node node; | |
29 | ||
30 | public Long getId() { | |
31 | return id; | |
32 | } | |
33 | ||
34 | public void setId(Long id) { | |
35 | this.id = id; | |
36 | } | |
37 | ||
38 | public String getText() { | |
39 | return text; | |
40 | } | |
41 | ||
42 | public void setText(String text) { | |
43 | this.text = text; | |
44 | } | |
45 | ||
46 | public List<Answer> getAnswers() { | |
47 | return answers; | |
48 | } | |
49 | ||
50 | public void setAnswers(List<Answer> answers) { | |
51 | this.answers = answers; | |
52 | } | |
53 | ||
54 | public Node getNode() { | |
55 | return node; | |
56 | } | |
57 | ||
58 | public void setNode(Node node) { | |
59 | this.node = node; | |
60 | } | |
61 | ||
62 | @Override | |
63 | public int hashCode() { | |
64 | int hash = 0; | |
65 | hash += (id != null ? id.hashCode() : 0); | |
66 | return hash; | |
67 | } | |
68 | ||
69 | @Override | |
70 | public boolean equals(Object object) { | |
71 | // TODO: Warning - this method won't work in the case the id fields are not set | |
72 | if (!(object instanceof Question)) { | |
73 | return false; | |
74 | } | |
75 | Question other = (Question) object; | |
76 | if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { | |
77 | return false; | |
78 | } | |
79 | return true; | |
80 | } | |
81 | ||
82 | @Override | |
83 | public String toString() { | |
84 | return "org.ufcspa.simdecs.entity.Question[ id=" + id + " ]"; | |
85 | } | |
86 | ||
87 | } |