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.Objects; |
| 5 | import javax.persistence.Column; |
| 6 | import javax.persistence.Entity; |
| 7 | import javax.persistence.Id; |
| 8 | import javax.persistence.IdClass; |
| 9 | import javax.persistence.JoinColumn; |
| 10 | import javax.persistence.ManyToOne; |
| 11 | import javax.persistence.Table; |
| 12 | |
| 13 | @Entity |
| 14 | @Table(name = "journal_entries", schema = "public", catalog = "mulkcms") |
| 15 | @IdClass(JournalEntryPK.class) |
| 16 | public 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 | } |