java - 如何在 Maven 应用程序 java 中比较两个日期
问题描述
我创建了一个函数来获取一些与日期匹配的行。但是该功能没有相应地执行。我怀疑存在一些语法问题。请帮我找出问题。DaoImpl 函数如下:
public List<ReportSewing> getReport(Date reportDate) {
return session.getCurrentSession()
.createQuery("from ReportSewing where DATE(reportDate) = (reportDate)")
.list();
}
解决方案
好像你忘了传递查询参数。
public List<ReportSewing> getReport(Date reportDate) {
return session.getCurrentSession()
.createQuery("from ReportSewing where DATE(reportDate) = :reportDate")
.setParameter("reportDate", reportDate)
.list();
}
推荐阅读
- python - Pandas CSV 数据框
- asp.net - 发生“System.Data.SqlClient.SqlException”类型的异常,出现此错误,我尝试将此数据插入数据库中的表中
- jquery - 如何使用 jquery 获取基于 html 值的 json 数据?
- java - 如何按升序对包含列表的对象进行排序
- python - 如何将现有数据帧中的值附加到 for 循环中的空数据帧?
- c# - 找不到 HtmlSelect 的方法名称
- c# - 在 Unity3D 中结合 Vuforia 地平面和模型目标
- javascript - 处理承诺:如何从 for 循环中返回一个包含承诺的列表?
- database - 无法更新表临时表,因为它没有副本标识并在 Postgres 中发布更新
- c++ - 通过重新排列其字母使回文字符串成为非回文字符串