Play Framework - Sql 查询返回 0 个结果
Play Framework - Sql query returning 0 result
public static List<SqlRow> findQuery(int page , int index, String source , String destination , Date date) {
String sql = "select DISTINCT airplane.id,airplane.reg_no,airplane.type,airplane.total_seat,source,destination,depart_date,amount from airplane,routee,flight,fare,airport ,flight_airplane where airplane.id IN (select AIRPLANE_ID from FLIGHT_AIRPLANE where FLIGHT_ID IN (select id from flight where depart_date= :date \n" +
"AND ROUTEE_ID IN (select id from routee where source= :first and destination= :destination and airport_id IN (select id from airport where CITY= :first OR COUNTRY= :first) AND fare_id IN (select id from fare) ))\n" +
") and source= :first and destination= :destination and depart_date= :date order by amount ;";
SqlQuery sqlQuery = Ebean.createSqlQuery(sql);
sqlQuery.setParameter("first",source);
sqlQuery.setParameter("destination",destination);
sqlQuery.setParameter("date",date);
return sqlQuery.findList();
}
这是我为连接各种 table 和 return 列表而编写的查询。这在我的电脑上很好用,但如果我在不同的 PC/laptop 中尝试它,它总是 return 0 结果。让我知道我做错了什么。
谢谢
问题出在表单的绑定值 (NULL) 上,因此 NULL 值作为参数传递,产生 0 个结果。要解决绑定值问题,我所做的就是:
激活剂清洁
激活器编译
激活剂运行
public static List<SqlRow> findQuery(int page , int index, String source , String destination , Date date) {
String sql = "select DISTINCT airplane.id,airplane.reg_no,airplane.type,airplane.total_seat,source,destination,depart_date,amount from airplane,routee,flight,fare,airport ,flight_airplane where airplane.id IN (select AIRPLANE_ID from FLIGHT_AIRPLANE where FLIGHT_ID IN (select id from flight where depart_date= :date \n" +
"AND ROUTEE_ID IN (select id from routee where source= :first and destination= :destination and airport_id IN (select id from airport where CITY= :first OR COUNTRY= :first) AND fare_id IN (select id from fare) ))\n" +
") and source= :first and destination= :destination and depart_date= :date order by amount ;";
SqlQuery sqlQuery = Ebean.createSqlQuery(sql);
sqlQuery.setParameter("first",source);
sqlQuery.setParameter("destination",destination);
sqlQuery.setParameter("date",date);
return sqlQuery.findList();
}
这是我为连接各种 table 和 return 列表而编写的查询。这在我的电脑上很好用,但如果我在不同的 PC/laptop 中尝试它,它总是 return 0 结果。让我知道我做错了什么。
谢谢
问题出在表单的绑定值 (NULL) 上,因此 NULL 值作为参数传递,产生 0 个结果。要解决绑定值问题,我所做的就是:
激活剂清洁
激活器编译
激活剂运行