** эй, я получаю ошибку при вызове метода findOne в резервировании. Его ошибка, приведенная выше, есть какое-либо тело для решения этой проблемы, которое может быть очень полезным, пожалуйста, помогите мне **
вот мой AbstractEntity класс
package com.rohit.flightreservation.entities;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
@MappedSuperclass
public class AbstractEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
}
вот мой полетный объект класс
package com.rohit.flightreservation.entities;
import javax.persistence.Entity;
import java.sql.Timestamp;
import java.util.Date;
@Entity
public class Flight extends AbstractEntity {
private String flightNumber;
private String operatingAirlines;
private String departureCity;
private String arrivalCity;
private Date dateOfDeparture;
private Timestamp estimatedDepartureTime;
public String getFlightNumber() {
return flightNumber;
}
public void setFlightNumber(String flightNumber) {
this.flightNumber = flightNumber;
}
public String getOperatingAirlines() {
return operatingAirlines;
}
public void setOperatingAirlines(String operatingAirlines) {
this.operatingAirlines = operatingAirlines;
}
public String getDepartureCity() {
return departureCity;
}
public void setDepartureCity(String departureCity) {
this.departureCity = departureCity;
}
public String getArrivalCity() {
return arrivalCity;
}
public void setArrivalCity(String arrivalCity) {
this.arrivalCity = arrivalCity;
}
public Date getDateOfDeparture() {
return dateOfDeparture;
}
public void setDateOfDeparture(Date dateOfDeparture) {
this.dateOfDeparture = dateOfDeparture;
}
public Timestamp getEstimatedDepartureTime() {
return estimatedDepartureTime;
}
public void setEstimatedDepartureTime(Timestamp estimatedDepartureTime) {
this.estimatedDepartureTime = estimatedDepartureTime;
}
}
вот мой ReservationController
package com.rohit.flightreservation.controller;
import com.rohit.flightreservation.Repository.FlightRepository;
import com.rohit.flightreservation.entities.Flight;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class ReservationControler {
@Autowired
FlightRepository flightRepository;
@RequestMapping("/showCompleteReservation")
public String showReservation(@RequestParam("flightId") Long flightId, ModelMap modelMap) {
Flight flight = flightRepository.findOne(flightId);
modelMap.addAttribute("flight", flight);
return "completeReservation";
}
}
вот мой flightRepository
public interface FlightRepository extends JpaRepository<Flight,Long> {
@Query("from Flight where departureCity=:deparuteCity and arrivalCity=:arrivalCity and dateOfDeparture=:dateOfDeparture")
List<Flight> findFlights(@Param("deparuteCity") String from, @Param("arrivalCity")String to, @Param("dateOfDeparture") Date departureDate);
}