Matthias Andreas Benkard | 2f0b370 | 2020-01-12 15:46:34 +0100 | [diff] [blame^] | 1 | package eu.mulk.entity; |
| 2 | |
| 3 | import io.quarkus.hibernate.orm.panache.PanacheEntityBase; |
| 4 | import java.util.Collection; |
| 5 | import java.util.Objects; |
| 6 | import javax.persistence.Basic; |
| 7 | import javax.persistence.Column; |
| 8 | import javax.persistence.Entity; |
| 9 | import javax.persistence.Id; |
| 10 | import javax.persistence.JoinColumn; |
| 11 | import javax.persistence.ManyToOne; |
| 12 | import javax.persistence.OneToMany; |
| 13 | import javax.persistence.Table; |
| 14 | |
| 15 | @Entity |
| 16 | @Table(name = "comments", schema = "public", catalog = "mulkcms") |
| 17 | public 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 | } |