Advertisement
wpinda

Reservation

May 11th, 2020
914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.94 KB | None | 0 0
  1. package com.example.student.entities;
  2.  
  3. import javax.persistence.*;
  4. import java.util.Date;
  5. import java.util.Objects;
  6.  
  7. @Entity
  8. public class Reservation {
  9.  
  10.     @EmbeddedId
  11.     ReservationKey reservationKey;
  12.  
  13.     @ManyToOne
  14.     @MapsId("userId")
  15.     @JoinColumn(name = "user_id")
  16.     private User user;
  17.  
  18.     @ManyToOne
  19.     @MapsId("groupId")
  20.     @JoinColumn(name = "group_id")
  21.     private Group group;
  22.  
  23.     @MapsId("myDate")
  24.     @JoinColumn(name = "my_date")
  25.     @Temporal(TemporalType.DATE)
  26.     private Date date;
  27.  
  28.     @Column(name = "amount_cooking")
  29.     private int amountCooking;
  30.  
  31.     @Column(name = "amount_eating")
  32.     private int amountEating;
  33.  
  34.     public Reservation() {
  35.  
  36.     }
  37.  
  38.     public Reservation(User user, Group group, Date date, int amountCooking, int amountEating) {
  39.         this.user = user;
  40.         this.group = group;
  41.         this.date = date;
  42.         this.amountCooking = amountCooking;
  43.         this.amountEating = amountEating;
  44.     }
  45.  
  46.     @Override
  47.     public boolean equals(Object o) {
  48.         if (this == o) return true;
  49.         if (!(o instanceof Reservation)) return false;
  50.         Reservation that = (Reservation) o;
  51.         return amountCooking == that.amountCooking &&
  52.                 amountEating == that.amountEating &&
  53.                 Objects.equals(reservationKey, that.reservationKey) &&
  54.                 Objects.equals(user, that.user) &&
  55.                 Objects.equals(group, that.group) &&
  56.                 Objects.equals(date, that.date);
  57.     }
  58.  
  59.     @Override
  60.     public int hashCode() {
  61.         return Objects.hash(reservationKey, user, group, date, amountCooking, amountEating);
  62.     }
  63.  
  64.     public ReservationKey getReservationKey() {
  65.         return reservationKey;
  66.     }
  67.  
  68.     public void setReservationKey(ReservationKey reservationKey) {
  69.         this.reservationKey = reservationKey;
  70.     }
  71.  
  72.     public User getUser() {
  73.         return user;
  74.     }
  75.  
  76.     public void setUser(User user) {
  77.         this.user = user;
  78.     }
  79.  
  80.     public Group getGroup() {
  81.         return group;
  82.     }
  83.  
  84.     public void setGroup(Group group) {
  85.         this.group = group;
  86.     }
  87.  
  88.     public Date getDate() {
  89.         return date;
  90.     }
  91.  
  92.     public void setDate(Date date) {
  93.         this.date = date;
  94.     }
  95.  
  96.     public int getAmountCooking() {
  97.         return amountCooking;
  98.     }
  99.  
  100.     public void setAmountCooking(int amountCooking) {
  101.         this.amountCooking = amountCooking;
  102.     }
  103.  
  104.     public int getAmountEating() {
  105.         return amountEating;
  106.     }
  107.  
  108.     public void setAmountEating(int amountEating) {
  109.         this.amountEating = amountEating;
  110.     }
  111.  
  112.     @Override
  113.     public String toString() {
  114.         return "Reservation{" +
  115.                 "user=" + user +
  116.                 ", group=" + group +
  117.                 ", date='" + date + "'" +
  118.                 ", amountCooking=" + amountCooking +
  119.                 ", amountEating=" + amountEating +
  120.                 '}';
  121.     }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement