我必须从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);
使用此查询无法获取记录。
答案 0 :(得分:0)
您可以使用Hibernate强制转换运算符:
select u from User u where cast(u.lastLoginAt as date) <= :thresholdDate