Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个带有日期字段的实体(java.util.Date)。通常日期保存为例如2012-10-19 21:29:03.000。我的数据库是 MySQL。
2012-10-19 21:29:03.000
现在我需要通过 JPQL 查询数据库,严格使用日期部分,即2012-10-19. 我该怎么做?
2012-10-19
这可以通过在设置参数时给出 TemporalType 来完成:
Date param ... Query q = em.createQuery("SELECT a FROM EntityA a WHERE a.someDate > :param"); q.setParameter("param", param, TemporalType.DATE);