Async Jasper report gives ALL data when changing parameter name

╄→尐↘猪︶ㄣ 提交于 2021-02-11 15:50:48

问题


I am working on an existing async jasper report in an application wherein the Java backend sends a parameter "employee_id" to the jasper server. Corresponding .jrxml file containing this parameter name "employee_id" executes the SQL query to fetch the results.

Now, as per the new functionality, there is a scenario when the application can send more than 1000 employee ids. So, in the Java side, I am creating sublists each containing at the max 1000 elements. e.g.

first sublist has param name as --> first1000_employee_id

second sublist has param name as --> second1000_employee_id

The corresponding .jrxml file has also been modified to add these 2 new parameters and got rid of "employee_id".

Existing java code:

ReportParameter reportParameter = new ReportParameter();
reportParameter.setName("employee_id");
reportParameter.setValues(employeeIds); // employeeIds is List<String>
reportParameters.add(reportParameter);

New java code:

ReportParameter reportParameterFirst1000 = new ReportParameter();
reportParameterFirst1000.setName("first1000_employee_id");
reportParameterFirst1000.setValues(first1000EmployeeIds); 
reportParameters.add(reportParameterFirst1000);


ReportParameter reportParameterSecond1000 = new ReportParameter();
reportParameterSecond1000.setName("second1000_employee_id");
reportParameterSecond1000.setValues(second1000EmployeeIds);
reportParameters.add(reportParameterSecond1000);

ReportParameters parameters = new ReportParameters();
parameters.setReportParameters(reportParameters);
reportExecutionRequest.setParameters(parameters);

Existing .jrxml SQL query:

SELECT  
    category_desc, 
    SUM(cnt)
    FROM (
        SELECT 
        category_desc,
        cnt 
        FROM   
        TXN_MV
        WHERE
        ( employee_id IN ('0001022051') )
        ) x                     
        GROUP  BY 
        category_desc 
        HAVING 
        SUM(cnt) > 0
        ORDER BY 
        cnt DESC

New .jrxml SQL query:

SELECT  
    category_desc, 
    SUM(cnt)
    FROM (
        SELECT 
        category_desc,
        cnt 
        FROM   
        TXN_MV
        WHERE
        ( first1000_employee_id IN ('0001022051') 
        OR second1000_employee_id IN ('0001022052') )
        ) x                     
        GROUP  BY 
        category_desc 
        HAVING 
        SUM(cnt) > 0
        ORDER BY 
        cnt DESC

Now, when I publish this report to jasper server, the application is picking the records for all the employee ids and not the ones I am specifying in the sublists based on the new SQL query in .jrxml. The WHERE condition for newly defined employee ids is getting ignored and so it is fetching all the records from the DB.

I have debugged and I see all the param names going correctly.

Could you please help what could be the issue ?

来源:https://stackoverflow.com/questions/61597471/async-jasper-report-gives-all-data-when-changing-parameter-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!