blob: 4a32706b8808594a38719375f66ece4e02f34582 [file] [log] [blame]
Matthias Andreas Benkard2f0b3702020-01-12 15:46:34 +01001package eu.mulk.entity;
2
3import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
4import java.util.Collection;
5import java.util.Objects;
6import javax.persistence.Basic;
7import javax.persistence.Column;
8import javax.persistence.Entity;
9import javax.persistence.Id;
10import javax.persistence.JoinColumn;
11import javax.persistence.ManyToOne;
12import javax.persistence.OneToMany;
13import javax.persistence.Table;
14
15@Entity
16@Table(name = "comments", schema = "public", catalog = "mulkcms")
17public class Comment extends PanacheEntityBase {
18
19 private int id;
20 private String globalId;
21 private Collection<CommentRevision> revisions;
22 private Article article;
23
24 @Id
25 @Column(name = "id", nullable = false)
26 public int getId() {
27 return id;
28 }
29
30 public void setId(int id) {
31 this.id = id;
32 }
33
34 @Basic
35 @Column(name = "global_id", nullable = true, length = -1)
36 public String getGlobalId() {
37 return globalId;
38 }
39
40 public void setGlobalId(String globalId) {
41 this.globalId = globalId;
42 }
43
44 @Override
45 public boolean equals(Object o) {
46 if (this == o) {
47 return true;
48 }
49 if (o == null || getClass() != o.getClass()) {
50 return false;
51 }
52 Comment comment = (Comment) o;
53 return id == comment.id &&
54 Objects.equals(globalId, comment.globalId);
55 }
56
57 @Override
58 public int hashCode() {
59 return Objects.hash(id, globalId);
60 }
61
62 @OneToMany(mappedBy = "comment")
63 public Collection<CommentRevision> getRevisions() {
64 return revisions;
65 }
66
67 public void setRevisions(Collection<CommentRevision> revisions) {
68 this.revisions = revisions;
69 }
70
71 @ManyToOne
72 @JoinColumn(name = "article", referencedColumnName = "id", nullable = false)
73 public Article getArticle() {
74 return article;
75 }
76
77 public void setArticle(Article article) {
78 this.article = article;
79 }
80}