I am trying to retreive all records from a MySQL table using spring boot JPA. Following is the repositry definition
MovieRepository class
@Query("From MovieEntity m, TheaterMovieShowEntity tms, TheaterEntity t where t.city=?1 and t.theaterid=tms.theaterid and m.movieid=tms.movieid and t.seatsavailable>=?2")
List<Movie> getMoviesDetails(String cityName, int noOfTickets)throws MovieException;
MovieService Class
public List<Movie> getMoviesDetails(String cityName, int noOfTickets)throws MovieException{
List<Movie>moviesIntheCityList = new ArrayList<Movie>();
**moviesIntheCityList = (List<Movie>) movieRepository.getMoviesDetails(cityName, noOfTickets);**
System.out.println("in the getMoviesDetails after querying"+moviesIntheCityList); // This is null
return moviesIntheCityList;
}
What am i missing?
In your Repository File use this way
List<Movie> findByCityNameAndNoOfTickets(String cityName, int noOfTickets)
refer Query Creation