【发布时间】:2019-11-07 10:41:32
【问题描述】:
我必须从 mysql DB 获取基于last_update_At的记录列表。它是 mysql 中的 timestamp 字段。从我的 java 代码中,我以以下格式传递日期。
Mon May 06 20:05:32 IST 2019
在 mysql last_update_At 中具有以下格式 2019-05-06 19:46:00。我只想在日期比较时获取此记录,而不是与时间比较。
请在下面找到我的休眠查询:
@Query("select u from User u where u.lastLoginAt <= :thresholdDate")
public List<User> findLastLoginDaysDifference(@Param("thresholdDate") Date thresholdDate);
使用此查询无法获取记录。
【问题讨论】:
-
在比较之前将其转换为日期。这是处理仅日期比较的最安全方法