Error with JPQL macros

Hi all,

I’m trying this jpql query:

select e from sportbest_AntiCovidCertification e 
inner join sys$CategoryAttributeValue v on v.entity.entityId = e.person.id 
where v.code = 'AntiCovid-19Selfcertificate'   and v.booleanValue = true   and @between(now, e.executionDate + 11, e.executionDate + 14, day)  
and not exists (select t from sportbest_AntiCovidCertification t where t.person = e.person and @dateEquals(t.executionDate, t.executionDate + 14)

but this error is raised:

com.haulmont.cuba.core.sys.jpql.JpqlSyntaxException: Errors found for input jpql:[select e from sportbest_AntiCovidCertification e inner join sys$CategoryAttributeValue v on v.entity.entityId = e.person.id where v.code = 'AntiCovid-19Selfcertificate'   and v.booleanValue = true   and @between(now, e.executionDate + 11, e.executionDate + 14, day)  and not exists (select t from sportbest_AntiCovidCertification t where t.person = e.person and @dateEquals(t.executionDate, t.executionDate + 14)]
CommonErrorNode [<mismatched token: [@63,215:215=',',<66>,1:215], resync=now>]
CommonErrorNode [<mismatched token: [@65,217:217='e',<61>,1:217], resync=e.executionDate + 11>]
CommonErrorNode [<mismatched token: [@74,239:239='e',<61>,1:239], resync=e.executionDate + 14>]
CommonErrorNode [<mismatched token: [@129,407:407='+',<65>,1:407], resync=@dateEquals(t.executionDate, t.executionDate + 14>]

What is the error?

Thanks to all for help

Hi,

@between has the format @between(field_name, moment1, moment2, time_unit).
moment1, moment2 expression containing now variable with an addition or subtraction of an integer number. So t.executionDate + 14 expression is unsupported in moment1, moment2.
The same applies to the @dateEquals macro.

Documentation: Macros in JPQL - CUBA Platform. Developer’s Manual