source: Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Food.java@ c03e53b

main
Last change on this file since c03e53b was c03e53b, checked in by SazdovaEkaterina <sazdovaekaterina@…>, 16 months ago

m-m relations

  • Property mode set to 100644
File size: 1.0 KB
Line 
1package finki.paw5.model.entities;
2
3import finki.paw5.model.enumerations.FoodType;
4import jakarta.persistence.*;
5import lombok.Data;
6import lombok.RequiredArgsConstructor;
7
8import java.util.List;
9
10@Data
11@Entity
12@RequiredArgsConstructor
13@Table(name = "food")
14public class Food {
15
16 @Id
17 @GeneratedValue(strategy = GenerationType.IDENTITY)
18 @Column(name = "id_food")
19 private Integer id;
20
21 @Column(name = "manufacturer", nullable = false, length = 100)
22 private String manufacturer;
23
24 @Column(name = "name_food", nullable = false, length = 20)
25 private String name;
26
27 @Column(name = "type_food", nullable = false)
28 private FoodType type;
29
30 @ManyToMany
31 @JoinTable(name = "pet_preferably_eats_food",
32 joinColumns = @JoinColumn(name = "id_food"),
33 inverseJoinColumns = @JoinColumn(name = "id_pet"))
34 List<Pet> pets;
35
36 public Food(String manufacturer, String name, FoodType type) {
37 this.manufacturer = manufacturer;
38 this.name = name;
39 this.type = type;
40 }
41}
Note: See TracBrowser for help on using the repository browser.