当前位置: 动力学知识库 > 问答 > 编程问答 >

java - In Hibernate, how do I create a Criteria-restriction object with a function operation trunc on a column name?

问题描述:

select * from tableA where trunc(order_date) > sysdate -7;

Something like

Criteria criteria = getSession().createCriteria(TableA.class).

add(Restrictions.gt("orderDate", afterSubtracting7DaysFromToday));

网友答案:

Use sqlRestriction to execute sql database functions. Something like this:

Criteria criteria = getSession().createCriteria(TableA.class).
.add(Restrictions.sqlRestriction("trunc(order_date) > sysdate -7"));
分享给朋友:
您可能感兴趣的文章:
随机阅读: