Skip to content

Commit 1b0618e

Browse files
committed
Create entities Restaurant and OpeningHours
1 parent 929e8bc commit 1b0618e

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

src/main/java/org/example/entities/OpeningHours.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,12 @@ public class OpeningHours {
1111
@GeneratedValue(strategy = GenerationType.IDENTITY)
1212
private Long id;
1313

14-
@ManyToOne
15-
@JoinColumn(name = "restaurant_id")
16-
private Restaurant restaurant;
17-
1814
private String weekday;
1915
private LocalTime openingTime;
2016
private LocalTime closingTime;
2117

2218
public OpeningHours(Long id, Restaurant restaurant, String weekday, LocalTime openingTime, LocalTime closingTime) {
2319
this.id = id;
24-
this.restaurant = restaurant;
2520
this.weekday = weekday;
2621
this.openingTime = openingTime;
2722
this.closingTime = closingTime;
@@ -37,14 +32,6 @@ public String getWeekday() {
3732
return weekday;
3833
}
3934

40-
public Restaurant getRestaurant() {
41-
return restaurant;
42-
}
43-
44-
public void setRestaurant(Restaurant restaurant) {
45-
this.restaurant = restaurant;
46-
}
47-
4835
public void setWeekday(String weekday) {
4936
this.weekday = weekday;
5037
}
@@ -69,7 +56,6 @@ public void setClosingTime(LocalTime closing_time) {
6956
public String toString() {
7057
return "OpeningHours{" +
7158
"id=" + id +
72-
", restaurant=" + restaurant +
7359
", weekday='" + weekday + '\'' +
7460
", openingTime=" + openingTime +
7561
", closingTime=" + closingTime +

src/main/java/org/example/entities/Restaurant.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import jakarta.persistence.*;
44

55
import java.math.BigDecimal;
6-
import java.time.LocalTime;
6+
import java.util.ArrayList;
7+
import java.util.List;
78

89
@Entity
910
public class Restaurant {
@@ -12,6 +13,10 @@ public class Restaurant {
1213
@GeneratedValue(strategy = GenerationType.IDENTITY)
1314
private Long id;
1415

16+
@OneToMany
17+
@JoinColumn(name = "openingHoursId")
18+
private List<OpeningHours> openingHours = new ArrayList<>();
19+
1520
private String name;
1621
private String category;
1722
private String address;

0 commit comments

Comments
 (0)