blob: 308c13eaca0d97daea4b0ef9c4d1220f56129833 [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.Basic;
6import javax.persistence.Column;
7import javax.persistence.Entity;
8import javax.persistence.Id;
9import javax.persistence.IdClass;
10import javax.persistence.JoinColumn;
11import javax.persistence.ManyToOne;
12import javax.persistence.Table;
13
14@Entity
15@Table(name = "user_settings", schema = "public", catalog = "mulkcms")
16@IdClass(UserSettingPK.class)
17public class UserSetting extends PanacheEntityBase {
18
19 private int userId;
20 private String setting;
21 private String value;
22 private User user;
23
24 @Id
25 @Column(name = "user", nullable = false)
26 public int getUserId() {
27 return userId;
28 }
29
30 public void setUserId(int userId) {
31 this.userId = userId;
32 }
33
34 @Id
35 @Column(name = "setting", nullable = false, length = -1)
36 public String getSetting() {
37 return setting;
38 }
39
40 public void setSetting(String setting) {
41 this.setting = setting;
42 }
43
44 @Basic
45 @Column(name = "value", nullable = true, length = -1)
46 public String getValue() {
47 return value;
48 }
49
50 public void setValue(String value) {
51 this.value = value;
52 }
53
54 @Override
55 public boolean equals(Object o) {
56 if (this == o) {
57 return true;
58 }
59 if (o == null || getClass() != o.getClass()) {
60 return false;
61 }
62 UserSetting that = (UserSetting) o;
63 return userId == that.userId &&
64 Objects.equals(setting, that.setting) &&
65 Objects.equals(value, that.value);
66 }
67
68 @Override
69 public int hashCode() {
70 return Objects.hash(userId, setting, value);
71 }
72
73 @ManyToOne
74 @JoinColumn(name = "user", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
75 public User getUser() {
76 return user;
77 }
78
79 public void setUser(User user) {
80 this.user = user;
81 }
82}