-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBooking.java
More file actions
56 lines (45 loc) · 1.4 KB
/
Booking.java
File metadata and controls
56 lines (45 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package ru.practicum.shareit.booking.model;
import lombok.*;
import org.hibernate.Hibernate;
import ru.practicum.shareit.booking.BookingStatus;
import ru.practicum.shareit.item.model.Item;
import ru.practicum.shareit.user.model.User;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Objects;
@Entity
@Table(name = "bookings", schema = "PUBLIC")
@Getter
@Setter
@ToString
@RequiredArgsConstructor
public class Booking {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "booking_id")
private Long id;
@Column(name = "start_date", nullable = false)
private LocalDateTime start;
@Column(name = "end_date", nullable = false)
private LocalDateTime end;
@ManyToOne
@JoinColumn(name = "item_id", nullable = false)
private Item item;
@ManyToOne
@JoinColumn(name = "booker_id", nullable = false)
private User booker;
@Column(name = "status", nullable = false)
@Enumerated(EnumType.STRING)
private BookingStatus status = BookingStatus.WAITING;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
Booking booking = (Booking) o;
return id != null && Objects.equals(id, booking.id);
}
@Override
public int hashCode() {
return getClass().hashCode();
}
}