使用@Query输入jpql查询时,我没有得到任何输出?有人可以告诉我以下查询有什么问题吗?

时间:2020-05-04 05:57:00

标签: java jpa jpql

我正在使用此查询

@Query("from Flight where departureCity = :departureCity and arrivalCity =:arrivalCity and dateOfDeparture =:dateOfDeparture")

List<Flight> findFlights(@Param("departureCity") String departureCity,@Param("arrivalCity") String arrivalCity,@Param("dateOfDeparture") Date dateOfTravel);

当我使用像findAll这样的默认粗体操作时,所有内容都在打印,但是上面的查询没有显示任何内容。我不明白上面的查询如何工作以及我正在犯什么错误。有人请帮我解决这个问题。 这是我在控制台上得到的输出

Hibernate: select flight0_.id as id1_0_, flight0_.arrival_city as arrival_2_0_, flight0_.date_of_departure as date_of_3_0_, flight0_.departure_city as departur4_0_, flight0_.estimated_departure_time as estimate5_0_, flight0_.flight_number as flight_n6_0_, flight0_.operating_airlines as operatin7_0_ from flight flight0_ where flight0_.departure_city=? and flight0_.arrival_city=? and flight0_.date_of_departure=?

这是我的MODEL CLASS

private String flightNumber;
        private String operatingAirlines;
        private String departureCity;
        private String arrivalCity;
        private Date dateOfDeparture;
        private Timestamp estimatedDepartureTime;

这是我的控制器班

public String findflight(@RequestParam("departurecity")String departureCity, @RequestParam("arrivalcity")String arrivalCity, 
             @RequestParam("traveldate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date dateOfTravel, ModelMap model)
    {
        List<Flight> flight = flightRepo.findFlights(departureCity, arrivalCity, dateOfTravel);
        model.addAttribute("find",  flight);
        return "displayflights";
    }

这是我的JSP页面

<th>Airlines</th>
        <th>Departure City</th>
        <th>Arrival City</th>
        <th>Departure Time</th>
      </tr>
     <c:forEach items="${find}" var="flight">
      <tr>
       <td>${flight.operatingAirlines}</td>
       <td>${flight.departureCity}</td>
       <td>${flight.arrivalCity}</td>
       <td>${flight.estimatedDepartureTime}</td>
       <td><a href="showCompleteReservation?Flightid=${flight.id}">select</a></td>
      </tr>

0 个答案:

没有答案
相关问题