1 | package finki.diplomska.tripplanner.models;
|
---|
2 |
|
---|
3 | import com.fasterxml.jackson.annotation.JsonBackReference;
|
---|
4 | import com.fasterxml.jackson.annotation.JsonManagedReference;
|
---|
5 | import lombok.AllArgsConstructor;
|
---|
6 | import lombok.Getter;
|
---|
7 | import lombok.NoArgsConstructor;
|
---|
8 | import lombok.Setter;
|
---|
9 | import net.minidev.json.annotate.JsonIgnore;
|
---|
10 |
|
---|
11 | import javax.persistence.*;
|
---|
12 | import java.util.List;
|
---|
13 |
|
---|
14 | @Entity
|
---|
15 | @Table(name = "locations")
|
---|
16 | @NoArgsConstructor
|
---|
17 | @AllArgsConstructor
|
---|
18 | @Getter
|
---|
19 | @Setter
|
---|
20 | public class Location {
|
---|
21 | @Id
|
---|
22 | @GeneratedValue(strategy = GenerationType.IDENTITY)
|
---|
23 | @Column(name = "id_location")
|
---|
24 | private Long id;
|
---|
25 |
|
---|
26 | @Column(name = "location_name")
|
---|
27 | private String name;
|
---|
28 |
|
---|
29 | @Column(name = "location_description")
|
---|
30 | private String description;
|
---|
31 |
|
---|
32 | private String address;
|
---|
33 |
|
---|
34 | private String priority;
|
---|
35 |
|
---|
36 | private int duration;
|
---|
37 |
|
---|
38 | private String trivia;
|
---|
39 |
|
---|
40 | @Lob
|
---|
41 | @JsonIgnore
|
---|
42 | private byte[] photo;
|
---|
43 |
|
---|
44 |
|
---|
45 | @ManyToMany
|
---|
46 | @JoinTable(
|
---|
47 | name = "recommended_companion",
|
---|
48 | joinColumns = @JoinColumn(name = "id_location"),
|
---|
49 | inverseJoinColumns = @JoinColumn(name = "id_companion"))
|
---|
50 | @com.fasterxml.jackson.annotation.JsonIgnore
|
---|
51 | private List<Companion> companionList;
|
---|
52 |
|
---|
53 | @ManyToOne
|
---|
54 | @JsonBackReference
|
---|
55 | @JoinColumn(name = "id_region", nullable = false)
|
---|
56 | private Region region;
|
---|
57 |
|
---|
58 | @ManyToOne
|
---|
59 | @JsonBackReference
|
---|
60 | @JoinColumn(name = "id_city", nullable = true)
|
---|
61 | private City city;
|
---|
62 |
|
---|
63 | @ManyToMany(mappedBy = "locationList")
|
---|
64 | @com.fasterxml.jackson.annotation.JsonIgnore
|
---|
65 | private List<Planner> plannerList;
|
---|
66 |
|
---|
67 |
|
---|
68 | @ManyToMany
|
---|
69 | @JoinTable(
|
---|
70 | name = "locations_belong",
|
---|
71 | joinColumns = @JoinColumn(name = "id_location"),
|
---|
72 | inverseJoinColumns = @JoinColumn(name = "id_category"))
|
---|
73 | @com.fasterxml.jackson.annotation.JsonIgnore
|
---|
74 | private List<Category> categoryList;
|
---|
75 |
|
---|
76 |
|
---|
77 | @OneToMany(mappedBy = "location", cascade = CascadeType.REMOVE, orphanRemoval = true)
|
---|
78 | @JsonManagedReference
|
---|
79 | private List<Images> imagesList;
|
---|
80 |
|
---|
81 |
|
---|
82 | }
|
---|