Advertisement
wpinda

ReservationKey

May 11th, 2020
1,008
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.64 KB | None | 0 0
  1. package com.example.student.entities;
  2.  
  3. import javax.persistence.Column;
  4. import javax.persistence.Embeddable;
  5. import javax.persistence.Temporal;
  6. import javax.persistence.TemporalType;
  7. import java.io.Serializable;
  8. import java.util.Date;
  9. import java.util.Objects;
  10.  
  11. @Embeddable
  12. public class ReservationKey implements Serializable {
  13.  
  14.     @Column(name = "my_date")
  15.     @Temporal(TemporalType.DATE)
  16.     private Date myDate;
  17.  
  18.     @Column(name = "group_id")
  19.     private Integer groupId;
  20.  
  21.     @Column(name = "user_id")
  22.     private Integer userId;
  23.  
  24.     public ReservationKey() {
  25.  
  26.     }
  27.  
  28.     public ReservationKey(Date myDate, int groupId, int userId) {
  29.         this.myDate = myDate;
  30.         this.groupId = groupId;
  31.         this.userId = userId;
  32.     }
  33.  
  34.     @Override
  35.     public boolean equals(Object o) {
  36.         if (this == o) return true;
  37.         if (!(o instanceof ReservationKey)) return false;
  38.         ReservationKey that = (ReservationKey) o;
  39.         return groupId == that.groupId &&
  40.                 userId == that.userId &&
  41.                 Objects.equals(myDate, that.myDate);
  42.     }
  43.  
  44.     @Override
  45.     public int hashCode() {
  46.         return Objects.hash(myDate, groupId, userId);
  47.     }
  48.  
  49.     public Date getMyDate() {
  50.         return myDate;
  51.     }
  52.  
  53.     public void setMyDate(Date date) {
  54.         this.myDate = date;
  55.     }
  56.  
  57.     public int getGroupId() {
  58.         return groupId;
  59.     }
  60.  
  61.     public void setGroupId(Integer groupId) {
  62.         this.groupId = groupId;
  63.     }
  64.  
  65.     public Integer getUserId() {
  66.         return userId;
  67.     }
  68.  
  69.     public void setUserId(int userId) {
  70.         this.userId = userId;
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement