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 = "openids", schema = "public", catalog = "mulkcms") |
| 15 | @IdClass(OpenIdPK.class) |
| 16 | public class OpenId extends PanacheEntityBase { |
| 17 | |
| 18 | private int userId; |
| 19 | private String openid; |
| 20 | private User user; |
| 21 | |
| 22 | @Id |
| 23 | @Column(name = "user", nullable = false) |
| 24 | public int getUserId() { |
| 25 | return userId; |
| 26 | } |
| 27 | |
| 28 | public void setUserId(int userId) { |
| 29 | this.userId = userId; |
| 30 | } |
| 31 | |
| 32 | @Id |
| 33 | @Column(name = "openid", nullable = false, length = -1) |
| 34 | public String getOpenid() { |
| 35 | return openid; |
| 36 | } |
| 37 | |
| 38 | public void setOpenid(String openid) { |
| 39 | this.openid = openid; |
| 40 | } |
| 41 | |
| 42 | @Override |
| 43 | public boolean equals(Object o) { |
| 44 | if (this == o) { |
| 45 | return true; |
| 46 | } |
| 47 | if (o == null || getClass() != o.getClass()) { |
| 48 | return false; |
| 49 | } |
| 50 | OpenId openId = (OpenId) o; |
| 51 | return userId == openId.userId && |
| 52 | Objects.equals(openid, openId.openid); |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public int hashCode() { |
| 57 | return Objects.hash(userId, openid); |
| 58 | } |
| 59 | |
| 60 | @ManyToOne |
| 61 | @JoinColumn(name = "user", referencedColumnName = "id", nullable = false, insertable = false, updatable = false) |
| 62 | public User getUser() { |
| 63 | return user; |
| 64 | } |
| 65 | |
| 66 | public void setUser(User user) { |
| 67 | this.user = user; |
| 68 | } |
| 69 | } |