blob: 1c4040e0c5c439ea40d47bae5208c7caaa3f886d [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.Objects;
5import javax.persistence.Column;
6import javax.persistence.Entity;
7import javax.persistence.Id;
8import javax.persistence.IdClass;
9import javax.persistence.JoinColumn;
10import javax.persistence.ManyToOne;
11import javax.persistence.Table;
12
13@Entity
14@Table(name = "journal_entries", schema = "public", catalog = "mulkcms")
15@IdClass(JournalEntryPK.class)
16public class JournalEntry extends PanacheEntityBase {
17
18 private int journalId;
19 private int index;
20 private Journal journal;
21 private Article article;
22
23 @Id
24 @Column(name = "journal", nullable = false)
25 public int getJournalId() {
26 return journalId;
27 }
28
29 public void setJournalId(int journalId) {
30 this.journalId = journalId;
31 }
32
33 @Id
34 @Column(name = "index", nullable = false)
35 public int getIndex() {
36 return index;
37 }
38
39 public void setIndex(int index) {
40 this.index = index;
41 }
42
43 @Override
44 public boolean equals(Object o) {
45 if (this == o) {
46 return true;
47 }
48 if (o == null || getClass() != o.getClass()) {
49 return false;
50 }
51 JournalEntry that = (JournalEntry) o;
52 return journalId == that.journalId &&
53 index == that.index;
54 }
55
56 @Override
57 public int hashCode() {
58 return Objects.hash(journalId, index);
59 }
60
61 @ManyToOne
62 @JoinColumn(name = "journal", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
63 public Journal getJournal() {
64 return journal;
65 }
66
67 public void setJournal(Journal journal) {
68 this.journal = journal;
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}