开发者

JPQL and date comparison (constraint in the query)

开发者 https://www.devze.com 2023-01-23 21:32 出处:网络
My Application model object contains a date field (time stamp): @Entity @Table(name = \"M开发者_开发百科YTABLE\")

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

@Entity
@Table(name = "M开发者_开发百科YTABLE")
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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号