blob: 3e9d302079bc6a1b31b130d8aa85215690e71202 [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 = "passwords", schema = "public", catalog = "mulkcms")
15@IdClass(PasswordPK.class)
16public class Password extends PanacheEntityBase {
17
18 private int userId;
19 private String password;
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 = "password", nullable = false, length = -1)
34 public String getPassword() {
35 return password;
36 }
37
38 public void setPassword(String password) {
39 this.password = password;
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 Password password1 = (Password) o;
51 return userId == password1.userId &&
52 Objects.equals(password, password1.password);
53 }
54
55 @Override
56 public int hashCode() {
57 return Objects.hash(userId, password);
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}