开发者

JPA Date Arithmetic?

开发者 https://www.devze.com 2022-12-31 08:06 出处:网络
Is it possible to perform date arithmetic using JPA/Hibernate?For example, I have an entity with a java.util.Date field indicating when the row was created.Is it possible to perform a query using JPQL

Is it possible to perform date arithmetic using JPA/Hibernate? For example, I have an entity with a java.util.Date field indicating when the row was created. Is it possible to perform a query using JPQL and include date arithmetic on that field? For example, can I perform a COUNT(*) of rows and then GROUP BY the month in that field? Can I perform other functions, such as only return the mont开发者_开发百科h or year from that field in a query?


HQL does have date expressions like second(...), minute(...), hour(...), day(...), month(...), and year(...) but standard JPQL doesn't have such functions.

0

精彩评论

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