Reservation.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package pl.sudra.domain;
  2. import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  3. import jakarta.persistence.*;
  4. import jakarta.validation.constraints.NotNull;
  5. import java.sql.Date;
  6. @Entity
  7. @Table(name = "reservation")
  8. public class Reservation {
  9. @Id
  10. @GeneratedValue(strategy = GenerationType.AUTO)
  11. private Long id;
  12. @ManyToOne(fetch = FetchType.EAGER)
  13. @JoinColumn(name = "userId")
  14. @JsonIgnoreProperties("reservations")
  15. private User user;
  16. @NotNull
  17. private Long boatId;
  18. @NotNull
  19. private Date date;
  20. @NotNull
  21. private byte startHour;
  22. @NotNull
  23. private byte endHour;
  24. @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
  25. @JoinColumn(name = "billId")
  26. private Bill bill;
  27. @Override
  28. public String toString() {
  29. return "Reservation{" +
  30. "id=" + id +
  31. ", user=" + user.getId() +
  32. ", boatId=" + boatId +
  33. ", date=" + date +
  34. ", startHour=" + startHour +
  35. ", endHour=" + endHour +
  36. ", bill=" + bill.getId() +
  37. '}';
  38. }
  39. public Reservation() {
  40. }
  41. public Long getId() {
  42. return id;
  43. }
  44. public void setId(Long id) {
  45. this.id = id;
  46. }
  47. public User getUser() {
  48. return user;
  49. }
  50. public void setUser(User user) {
  51. this.user = user;
  52. }
  53. public Long getBoatId() {
  54. return boatId;
  55. }
  56. public void setBoatId(Long boat_id) {
  57. this.boatId = boat_id;
  58. }
  59. public Date getDate() {
  60. return date;
  61. }
  62. public void setDate(Date date) {
  63. this.date = date;
  64. }
  65. public byte getStartHour() {
  66. return startHour;
  67. }
  68. public void setStartHour(byte start_hour) {
  69. this.startHour = start_hour;
  70. }
  71. public byte getEndHour() {
  72. return endHour;
  73. }
  74. public void setEndHour(byte end_hour) {
  75. this.endHour = end_hour;
  76. }
  77. public Bill getBill() {
  78. return bill;
  79. }
  80. public void setBill(Bill bill) {
  81. this.bill = bill;
  82. }
  83. }