cuba-platform / cuba

CUBA Platform is a high level framework for enterprise applications development
https://www.cuba-platform.com
Apache License 2.0
1.34k stars 219 forks source link

Report band JPQL query cannot contain both parameters and JPQL macros #3276

Open gorbunkov opened 2 years ago

gorbunkov commented 2 years ago

Platform version: 7.2.19

Create a report with JPQL dataset. The query must use some external parameter and JPQL date macros, e.g.:

select
e.name as "name",
e.dueDate as "dueDate",
owner.login as "owner.login"
from sample_Project e  
left join e.owner owner 
 where e.owner.id = ${owner1} and
 @dateBefore(e.dueDate, now)

Run the report.

The exception:

Caused by: com.haulmont.yarg.exception.DataLoadingException: An error occurred while loading data for data set [Dataset]
    at com.haulmont.reports.libintegration.JpqlDataDataLoader.loadData(JpqlDataDataLoader.java:91) ~[reports-core-7.2.19.jar:7.2.19]
    at com.haulmont.yarg.reporting.extraction.controller.DefaultExtractionController.lambda$getQueryData$1(DefaultExtractionController.java:206) ~[yarg-2.2.11.jar:na]
    at com.haulmont.yarg.reporting.extraction.DefaultPreprocessorFactory.lambda$new$0(DefaultPreprocessorFactory.java:35) ~[yarg-2.2.11.jar:na]
    at com.haulmont.yarg.reporting.extraction.controller.DefaultExtractionController.getQueryData(DefaultExtractionController.java:204) ~[yarg-2.2.11.jar:na]
    ... 94 common frames omitted
Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
Exception Description: Syntax error parsing [select e.name, e.dueDate, owner.login from sample_Project e left join e.owner owner where e.owner.id = ?1 and (e.dueDate < :e_dueDate_1_1)]. 
[103, 105] Named and positional input parameters must not be mixed in a single query.
[123, 137] Named and positional input parameters must not be mixed in a single query.
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1750) ~[org.eclipse.persistence.jpa-2.7.3-19-cuba.jar:na]

It seems that for some reasons reporting replaces named query parameters with positioned ones.

Sample project: cuba-report-param.zip

The report: Report for entity Project - error.zip

Forum: https://forum.cuba-platform.com/t/email-templates-report-error-in-my-setup/16386