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 = "passwords", schema = "public", catalog = "mulkcms") |
| 15 | @IdClass(PasswordPK.class) |
| 16 | public 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 | } |