blob: 270864027f03bf799cacf28e8c756a7189c60855 [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 = "openids", schema = "public", catalog = "mulkcms")
15@IdClass(OpenIdPK.class)
16public 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}