JPQL和日期比较(查询中的约束) [英] JPQL and date comparison (constraint in the query)
本文介绍了JPQL和日期比较(查询中的约束)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序模型对象包含一个日期字段(时间戳):
My Application model object contains a date field (time stamp):
@Entity
@Table(name = "MYTABLE")
public class Application {
private Date timeStamp;
...
}
我正在尝试构建一个JPQL查询这将选择今天更改的所有应用程序(即他们的时间戳在今天的任何时间更改)。什么是最好的方法?
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?
推荐答案
标准JPQL没有完美的方法,JPQL不提供日期算术函数。但是您的提供商可能会提供扩展(例如Hibernate和EclipseLink)。或使用本地SQL。
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.
这篇关于JPQL和日期比较(查询中的约束)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文