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.Basic; |
| 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 = "user_settings", schema = "public", catalog = "mulkcms") |
| 16 | @IdClass(UserSettingPK.class) |
| 17 | public 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 | } |