Hello. Please help to create a query in which you need to get information from two tables on the transmitted data. At the entrance comes the name cityFrom and cityTo

Entities: Flight

@Data @Entity @Table(name = "flight") public class Flight { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private Integer id; @Column(name = "flightDate") private Date flightDate; @ManyToOne private City cityFrom; @ManyToOne private City cityTo; 

Essence City

 @Data @Entity @Table(name = "spr_city") public class City implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private Integer id; @Column(name = "nameCity") private String nameCity; 

    1 answer 1

     select f from Flight f join f.cityFrom cf join f.cityYo ct where cf.nameCity = ? and ct.nameCity = ?