Spring Boot Mysql查询,根据@query值获取所有记录

Spring Boot Mysql查询,根据@query值获取所有记录,mysql,spring-boot,spring-boot-jpa,Mysql,Spring Boot,Spring Boot Jpa,我正在尝试使用SpringBootJPA从MySQL表检索所有记录。以下是寄存的定义 电影定位类 @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> getMo

我正在尝试使用SpringBootJPA从MySQL表检索所有记录。以下是寄存的定义

电影定位类

@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;
@Query(“来自MovieEntity m,TheateMovieShowEntity tms,TheEntity t其中t.city=?1和t.TheateId=tms.TheateId和m.movieid=tms.movieid和t.SeatAvailable>=?2”)
List getMoviesDetails(字符串cityName,int noOfTickets)抛出MovieException;
电影服务类

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;
    }
public List getMoviesDetails(字符串cityName,int noOfTickets)引发MovieException{
ListMoviesInCityList=new ArrayList();
**MoviesInCityList=(列表)movieRepository.getMoviesDetails(城市名称,noOfTickets)**
System.out.println(“在查询“+MoviesInCityList”后的getMoviesDetails中);//这是空的
返回城市列表中的电影;
}

我缺少什么?

在您的存储库文件中,请使用这种方式

List findbycityname和noOfTickets(字符串cityName,int noOfTickets)

请参阅仅使用

List<Movie> movieRepository.findByCityNameAndNoOfTickets(String cityName, int noOfTickets);
List movieRepository.findbycityname和noOfTickets(字符串cityName,int noOfTickets);

在你的电影里。然后叫它。在Spring Data JPA中,如果您遵循正确的命名约定,那么您只需在存储库中声明方法的名称,JPA将为您实现它。

这里的两个查询参数位于两个不同的表中。cityName在桌上电影中,noOfTickets在桌上影院中。如何处理需要根据两个不同表中的值筛选结果的tpe查询。