SHARE
TWEET

Untitled

a guest Feb 16th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Repository
  2. public interface StreetInter extends JpaRepository<Street, Long> {
  3.  
  4.     Street findStreetByNameAndCity_NameAndCity_Country_Name(String street_name, String city_name, String country_name);
  5.  
  6. @Entity
  7. @Data
  8. public class City {
  9.  
  10.     @Id
  11.     @GeneratedValue(strategy = GenerationType.AUTO)
  12.  
  13.     private Long id;
  14.     @NotNull
  15.     private String name;
  16.     @OneToMany(mappedBy = "city",cascade=CascadeType.ALL)
  17.     private List<Street> streets;
  18.     @ManyToOne
  19.     @JoinColumn(name = "country_id")
  20.     private Country country;
  21. }
  22.  
  23.  
  24. @Entity
  25. @Data
  26. public class Country {
  27.     @Id
  28.     @GeneratedValue(strategy = GenerationType.AUTO)
  29.  
  30.     private Long id;
  31.  
  32.     @NotNull
  33.  
  34.     private String name;
  35.  
  36.      @OneToMany(mappedBy = "country",cascade=CascadeType.ALL)
  37.  
  38.     private List<City> cityList;
  39. }
  40.  
  41. @Entity
  42.  
  43. @Data
  44.  
  45. public class Street {
  46.     @Id
  47.     @GeneratedValue(strategy = GenerationType.AUTO)
  48.     private Long id;
  49.     @NotNull
  50.     private String name;
  51.  
  52.     @ManyToOne
  53.     @JoinColumn(name = "city_id")
  54.     private City city;
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top