【发布时间】:2020-09-22 00:21:51
【问题描述】:
我必须将以下查询转换为休眠条件查询:
select * from tbl1 t1,tbl2 t2 where t1.id=t2.id
and ( To_char(t1.modified_date, 'YYYYMMDD') - To_char(get_sys_date, 'YYYYMMDD') )>10;
其中 get_sys_date 是一个 sql 函数。
当我在我的 java 代码中使用 datediff 函数时:
Expression<String> day = cb.literal("day");
Expression<Integer> diff = cb.function("DATEDIFF", Integer.class, day, currentDate,
root.get(myVO_.modified_date));
它给了我一个编译错误:
method function in interface CriteriaBuilder cannot be applied to given types
'currentDate' 作为参数传递给方法。
那么creteria表达式怎么写呢?
【问题讨论】:
标签: jpa hibernate-criteria datediff criteria-api