source: src/main/java/com/example/rezevirajmasa/demo/model/Menu.java

main
Last change on this file was e48199a, checked in by Aleksandar Panovski <apano77@…>, 12 days ago

Final version for DB

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[d24f17c]1package com.example.rezevirajmasa.demo.model;
2
[e15e8d9]3import com.fasterxml.jackson.annotation.JsonIgnore;
[d24f17c]4import jakarta.persistence.*;
[e15e8d9]5import lombok.Data;
[d24f17c]6
7import java.math.BigDecimal;
[2518b3a]8import java.util.ArrayList;
9import java.util.List;
[d24f17c]10
11@Entity
12@Table(name = "menus")
[e15e8d9]13@Data
[d24f17c]14public class Menu {
15 @Id
16 @GeneratedValue(strategy = GenerationType.IDENTITY)
[2518b3a]17 @Column(name = "menu_id")
[d24f17c]18 private Long menuID;
19
20 @ManyToOne
[2518b3a]21 @JoinColumn(name = "restaurant_id", nullable = false)
[e15e8d9]22 @JsonIgnore
[d24f17c]23 private Restaurant restaurant;
24
[2518b3a]25 @Column(name = "item_name", length = 100)
[d24f17c]26 private String itemName;
27
[b67dfd3]28 @Column(name = "menuCategory", length = 50)
29 private String menuCategory;
[d24f17c]30
[2518b3a]31 @Column(name = "price", precision = 8, scale = 2)
[d24f17c]32 private BigDecimal price;
33
[2518b3a]34 @Column(name = "description")
[d24f17c]35 private String description;
36
[2518b3a]37 @OneToMany(mappedBy = "menu", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
38 private List<MenuTag> tags = new ArrayList<>();
[d24f17c]39
[e48199a]40 @OneToMany(mappedBy = "menu", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
41 private List<PriceHistory> priceHistoryList = new ArrayList<>();
42
[d24f17c]43 public Menu() {
44 }
45
[2518b3a]46 public Menu(Long menuID, Restaurant restaurant, String itemName, String category, BigDecimal price, String description, List<MenuTag> tags) {
47 this.menuID = menuID;
[d24f17c]48 this.restaurant = restaurant;
49 this.itemName = itemName;
[b67dfd3]50 this.menuCategory = category;
[d24f17c]51 this.price = price;
52 this.description = description;
[2518b3a]53 this.tags = tags;
[d24f17c]54 }
55}
Note: See TracBrowser for help on using the repository browser.