JPQL and date comparison (constraint in the query)

前提是你 提交于 2019-12-11 02:22:31

问题


My Application model object contains a date field (time stamp):

@Entity
@Table(name = "MYTABLE")
public class Application {

   private Date timeStamp;
   ...
}

I'm trying to construct a JPQL query that would select all applications that were changed today (i.e. their time stamp was changed anytime today). What is the best way to do this?


回答1:


There is no perfect way with standard JPQL, JPQL doesn't provide Date arithmetic functions. But your provider might provide extensions (e.g. Hibernate and EclipseLink do). Or use a native SQL.



来源:https://stackoverflow.com/questions/4105946/jpql-and-date-comparison-constraint-in-the-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!