source: trip-planner/src/main/java/finki/diplomska/tripplanner/models/Region.java

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1package finki.diplomska.tripplanner.models;
2
3import com.fasterxml.jackson.annotation.JsonBackReference;
4import com.fasterxml.jackson.annotation.JsonManagedReference;
5import lombok.AllArgsConstructor;
6import lombok.Getter;
7import lombok.NoArgsConstructor;
8import lombok.Setter;
9
10import javax.persistence.*;
11import java.util.List;
12
13@Entity
14@Table(name = "regions")
15@NoArgsConstructor
16@AllArgsConstructor
17@Getter
18@Setter
19public class Region {
20
21 @Id
22 @GeneratedValue(strategy = GenerationType.IDENTITY)
23 @Column(name = "id_region")
24 private Long id;
25
26 @Column(name = "region_name")
27 private String name;
28
29 @ManyToOne
30 @JoinColumn(name = "id_country", nullable = false)
31 @JsonBackReference
32 private Country country;
33
34
35 @OneToMany(mappedBy = "region", cascade = CascadeType.REMOVE, orphanRemoval = true)
36 @JsonManagedReference
37 private List<City> cityList;
38
39 @OneToMany (mappedBy = "region", cascade = CascadeType.REMOVE, orphanRemoval = true)
40 @JsonManagedReference
41 private List<Location> locationList;
42
43}
Note: See TracBrowser for help on using the repository browser.