Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: INTERVAL near
这是我的查询:
private static final String USERS_NOT_ACTION_IN_LAST_MONTH = select u from myTable u where u.lastDate + INTERVAL 30 DAY <= CURDATE();
@Override
public List<MyEntity> getItemOlderThanMonth() {
Query q = _entityManager.createQuery(USERS_NOT_ACTION_IN_LAST_MONTH, MyEntity.class);
return q.getResultList();
}
我想要获取 30 天以上的记录。
最佳答案
您可以通过查询参数(current_date- 30)计算当前日期
private static final String USERS_NOT_ACTION_IN_LAST_MONTH = select u from myTable u where u.lastDate <= :calculated_date;
其中计算日期=当前日期 -30 天。
关于mysql - 第 1 行附近的间隔 : Caused by: org. hibernate.hql.internal.ast.QuerySyntaxException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60164168/