相当于JPQL中的timestampdiff(不使用条件) [英] timestampdiff equivalent in JPQL (without using criteria)

查看:183
本文介绍了相当于JPQL中的timestampdiff(不使用条件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在JPQL中使用以下mysql函数:-

I want to use following mysql function in JPQL:-

TIMESTAMPDIFF(YEAR, some_start_date, CURDATE());

此外,由于我们遵循编写命名查询(JPQL)的做法,因此我不必在JPA中使用Criteria.那么,该函数如何用JPQL编写?

Also, I do not have to use Criteria in JPA, since we are following practice of writing Named queries(JPQL). So, how can this function be written in JPQL?

推荐答案

JPQL中没有timestampdiff. Eclipse的关键字FUNC允许调用特定于数据库的功能,例如timestampdiff.

There is no timestampdiff in JPQL. Eclipse has keyword FUNC which allows to call DB-specific functions, like timestampdiff.

这篇关于相当于JPQL中的timestampdiff(不使用条件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆