[6a3a178] | 1 | package finki.diplomska.tripplanner.models;
|
---|
| 2 |
|
---|
| 3 | import com.fasterxml.jackson.annotation.JsonBackReference;
|
---|
[59329aa] | 4 | import com.fasterxml.jackson.annotation.JsonManagedReference;
|
---|
[6a3a178] | 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 | @Lob
|
---|
| 39 | @JsonIgnore
|
---|
| 40 | private byte[] photo;
|
---|
| 41 |
|
---|
| 42 |
|
---|
| 43 | @ManyToMany
|
---|
| 44 | @JoinTable(
|
---|
| 45 | name = "recommended_companion",
|
---|
| 46 | joinColumns = @JoinColumn(name = "id_location"),
|
---|
| 47 | inverseJoinColumns = @JoinColumn(name = "id_companion"))
|
---|
| 48 | @com.fasterxml.jackson.annotation.JsonIgnore
|
---|
| 49 | private List<Companion> companionList;
|
---|
| 50 |
|
---|
| 51 | @ManyToOne
|
---|
| 52 | @JsonBackReference
|
---|
| 53 | @JoinColumn(name = "id_region", nullable = false)
|
---|
| 54 | private Region region;
|
---|
| 55 |
|
---|
| 56 | @ManyToOne
|
---|
| 57 | @JsonBackReference
|
---|
| 58 | @JoinColumn(name = "id_city", nullable = true)
|
---|
| 59 | private City city;
|
---|
| 60 |
|
---|
| 61 | @ManyToMany(mappedBy = "locationList")
|
---|
| 62 | @com.fasterxml.jackson.annotation.JsonIgnore
|
---|
| 63 | private List<Planner> plannerList;
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 | @ManyToMany
|
---|
| 67 | @JoinTable(
|
---|
| 68 | name = "locations_belong",
|
---|
| 69 | joinColumns = @JoinColumn(name = "id_location"),
|
---|
| 70 | inverseJoinColumns = @JoinColumn(name = "id_category"))
|
---|
| 71 | @com.fasterxml.jackson.annotation.JsonIgnore
|
---|
| 72 | private List<Category> categoryList;
|
---|
| 73 |
|
---|
| 74 |
|
---|
[59329aa] | 75 | @OneToMany(mappedBy = "location", cascade = CascadeType.REMOVE, orphanRemoval = true)
|
---|
| 76 | @JsonManagedReference
|
---|
| 77 | private List<Images> imagesList;
|
---|
| 78 |
|
---|
| 79 |
|
---|
[6a3a178] | 80 | }
|
---|