I am using custom queries in JPA, it doesn't let me use interval
keyword. It gives correct output if I do not use - interval '7 days'
in the query.
Exception says:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: interval near line 1, column 214
@Query("select d from DomainName d , DomainNameReminder dr, Reseller r"+
" where d.reminder.id = dr.id "+
" and dr.secondNotification=current_date - interval '7 days' "+
" and r.checkParty=true "+
" and r.id = d.invoicingParty.id ")
public List<Object> findDomainsBySecondNotificationDate();
This query basically brings all the records that are having second notification date 7 days before today.
My interface is declared as
public interface DomainNameRepository extends JpaRepository<DomainName, Long>,
QueryDslPredicateExecutor<DomainName> {
My query is giving correct output in pgadmin postgresql client
, I am pretty surprised why can't I use keywords here.