1 | package com.example.villadihovo.model.reservations;
|
---|
2 |
|
---|
3 | import com.example.villadihovo.model.offers.Meal;
|
---|
4 | import com.example.villadihovo.model.offers.PreparedMeal;
|
---|
5 | import jakarta.persistence.*;
|
---|
6 | import jakarta.validation.constraints.Min;
|
---|
7 | import lombok.AllArgsConstructor;
|
---|
8 | import lombok.Data;
|
---|
9 | import lombok.NoArgsConstructor;
|
---|
10 | import org.hibernate.annotations.OnDelete;
|
---|
11 | import org.hibernate.annotations.OnDeleteAction;
|
---|
12 |
|
---|
13 | @Data
|
---|
14 | @AllArgsConstructor
|
---|
15 | @NoArgsConstructor
|
---|
16 | @Entity
|
---|
17 | @Table(name = "reservation_for_prepared_meal")
|
---|
18 | public class ReservationForPreparedMeal {
|
---|
19 |
|
---|
20 | @EmbeddedId
|
---|
21 | private ReservationForPreparedMealId id;
|
---|
22 |
|
---|
23 | @Column(name = "quantity")
|
---|
24 | @Min(value = 0, message = "Quantity must be greater than or equal to 0")
|
---|
25 | private Integer quantity;
|
---|
26 |
|
---|
27 | @ManyToOne(cascade = CascadeType.ALL)
|
---|
28 | @JoinColumn(name = "reservation_id", referencedColumnName = "reservation_id", insertable = false, updatable = false)
|
---|
29 | private Reservation reservation_id;
|
---|
30 |
|
---|
31 | @ManyToOne
|
---|
32 | @JoinColumns({
|
---|
33 | @JoinColumn(name = "prepared_meal_id", referencedColumnName = "prepared_meal_id", insertable = false, updatable = false)
|
---|
34 | })
|
---|
35 | private PreparedMeal prepared_meal_id;
|
---|
36 |
|
---|
37 | @ManyToOne
|
---|
38 | @JoinColumn(name = "meal_id", referencedColumnName = "meal_id", insertable = false, updatable = false)
|
---|
39 | private Meal meal_id;
|
---|
40 |
|
---|
41 | }
|
---|