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.Arrays; |
| 5 | import java.util.Objects; |
| 6 | import javax.persistence.Column; |
| 7 | import javax.persistence.Entity; |
| 8 | import javax.persistence.Id; |
| 9 | import javax.persistence.IdClass; |
| 10 | import javax.persistence.JoinColumn; |
| 11 | import javax.persistence.ManyToOne; |
| 12 | import javax.persistence.Table; |
| 13 | |
| 14 | @Entity |
| 15 | @Table(name = "login_certificates", schema = "public", catalog = "mulkcms") |
| 16 | @IdClass(LoginCertificatePK.class) |
| 17 | public class LoginCertificate extends PanacheEntityBase { |
| 18 | |
| 19 | private int userId; |
| 20 | private byte[] certificate; |
| 21 | private User user; |
| 22 | |
| 23 | @Id |
| 24 | @Column(name = "user", nullable = false) |
| 25 | public int getUserId() { |
| 26 | return userId; |
| 27 | } |
| 28 | |
| 29 | public void setUserId(int userId) { |
| 30 | this.userId = userId; |
| 31 | } |
| 32 | |
| 33 | @Id |
| 34 | @Column(name = "certificate", nullable = false) |
| 35 | public byte[] getCertificate() { |
| 36 | return certificate; |
| 37 | } |
| 38 | |
| 39 | public void setCertificate(byte[] certificate) { |
| 40 | this.certificate = certificate; |
| 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 | LoginCertificate that = (LoginCertificate) o; |
| 52 | return userId == that.userId && |
| 53 | Arrays.equals(certificate, that.certificate); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public int hashCode() { |
| 58 | int result = Objects.hash(userId); |
| 59 | result = 31 * result + Arrays.hashCode(certificate); |
| 60 | return result; |
| 61 | } |
| 62 | |
| 63 | @ManyToOne |
| 64 | @JoinColumn(name = "user", referencedColumnName = "id", nullable = false, insertable = false, updatable = false) |
| 65 | public User getUser() { |
| 66 | return user; |
| 67 | } |
| 68 | |
| 69 | public void setUser(User user) { |
| 70 | this.user = user; |
| 71 | } |
| 72 | } |