我得到一个空列表,在查询JavaSpring时出错
我有问题,当我进行查询时,列表是空的我得到一个空列表,在查询JavaSpring时出错,java,spring,hibernate,Java,Spring,Hibernate,我有问题,当我进行查询时,列表是空的 @Override public List<QcReport> listQc3(double year, String hole_id) { Session session = this.sessionFactory.getCurrentSession(); List report = session.createQuery("SELECT hole_id,year FROM QcReport whe
@Override
public List<QcReport> listQc3(double year, String hole_id) {
Session session = this.sessionFactory.getCurrentSession();
List report = session.createQuery("SELECT hole_id,year FROM QcReport where year = " +year+" AND hole_id = :hole_id")
// .setParameter("year", year)
.setParameter("hole_id", hole_id)
.list();
System.out.println(report);
return report;
}
当
QcReport hole=new QcReport()时,构造函数中是否设置了任何默认值代码>?您确定使用给定的参数可以从数据库中提取记录吗?使用DB客户端查询数据库时,您看到了什么?你得到结果了吗?如果我得到结果,我知道我的查询是错误的,但我不知道来源是什么
@RequestMapping(value = "/qc_table")
public ModelAndView listReport(@ModelAttribute("report") QcReport assay,Model model) throws IOException {
ModelAndView mod = new ModelAndView("qc_table");
QcReport hole = new QcReport();
List<QcReport> list = qcServ.listQc3(hole.getYear(),hole.getHole_id());
model.addAttribute("listReporte", list);
// mod.addObject("listReporte", list);
return mod;
}
Hibernate:
select
qcreport0_.hole_id as col_0_0_,
qcreport0_.year as col_1_0_
from
vw_dhqc_report qcreport0_
where
qcreport0_.year=0.0
and qcreport0_.hole_id=?
[]