[
https://issues.apache.org/jira/browse/WW-3245?focusedWorklogId=1041086&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1041086
]
ASF GitHub Bot logged work on WW-3245:
--------------------------------------
Author: ASF GitHub Bot
Created on: 12/Sep/26 08:37
Start Date: 12/Sep/26 08:37
Worklog Time Spent: 10m
Work Description: lukaszlenart opened a new pull request, #1919:
URL: https://github.com/apache/struts/pull/1919
Fixes [WW-3245](https://issues.apache.org/jira/browse/WW-3245)
## What
Both JasperReports result types (`jasperreports` and `jasperreports7`
plugins) required either `dataSource` or `connection` and only ever called the
three-argument `JasperFillManager.fillReport` overloads. A report whose data
comes from a JasperReports query executer — Hibernate (`HIBERNATE_SESSION`),
CSV, JSON, EJBQL, XPath… — could therefore not be filled without first
materialising a `List` in the action, which is what the ticket (2009) asks to
remove.
When neither is configured, the result now calls `fillReport(report,
parameters)` and lets JasperReports resolve its data from the parameter map
exactly as its standalone API does. The supplier object the executer expects,
or a ready `REPORT_DATA_SOURCE` / `REPORT_CONNECTION`, is handed over via
`reportParameters`.
## Why this shape and not the attached patch
The 2009 patch special-cased `HIBERNATE_SESSION` and imported
`JRHibernateQueryExecuterFactory`. JasperReports 7 moved that class out of the
core jar into the optional `jasperreports-hibernate` artifact, so the patch
would not compile against the jasperreports7 plugin, and every other executer
would still be locked out. Delegating to the two-argument overload needs no key
inspection and no new dependency, and works for every present and future
executer.
Precedence is unchanged: `connection` → `dataSource` → parameters-only. The
acceptance checks on the `dataSource` and `reportParameters` expressions still
run whenever they are set. When the parameter map carries nothing the executer
can use, the outcome is JasperReports' own (the JDBC executer logs and fills
per `whenNoDataType`, Hibernate throws) — the plugin adds no policy of its own;
a debug line marks the parameters-only path so a forgotten `dataSource` stays
diagnosable.
## Tests
One new test per plugin,
`testFillFromReportParametersWithoutDataSourceOrConnection`: a `csv.jrxml`
fixture with a `csv` query and no `dataSource`/`connection` on the result,
`CSV_INPUT_STREAM` supplied via `reportParameters`, XML export asserted to
contain the CSV row. Both failed with `No dataSource specified...` before the
change.
Docs: companion struts-site PR follows.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Issue Time Tracking
-------------------
Worklog Id: (was: 1041086)
Remaining Estimate: 0h
Time Spent: 10m
> Jasper plugin does not support supply of data via report parameters (for
> example Hibernate session object)
> ----------------------------------------------------------------------------------------------------------
>
> Key: WW-3245
> URL: https://issues.apache.org/jira/browse/WW-3245
> Project: Struts 2
> Issue Type: Improvement
> Components: Plugin - JasperReports
> Affects Versions: 2.1.6, 2.3.20, 6.1.1
> Environment: Present in all environments, attempting usage of
> Hibernate query HQL embedded in a JasperReport.
> Reporter: Andrew Hodgson
> Assignee: Lukasz Lenart
> Priority: Minor
> Fix For: 7.4.0
>
> Attachments: struts2JasperReportsPluginHQLPatch.patch
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> A typical usage scenario for a Jasper report involves writing code within the
> report document to retrieve report from a database recent Struts code
> supports this via supply of a SQL Connection object, but I notice it's not
> supported in 2.1.6 production release.
> JasperReports supports many implementation languages for it's data retrieval
> code, but in particular I have identified issue in relation to Hibernate HQL
> queries.
> Normal route in this scenario (if not using Struts JasperReports plugin) is
> to supply Hibernate session as a parameter to the report, then implement HQL
> within the document to retrieve the data. However the Plugin only supports
> Connection or a pre-populated dataSource as a source for the report's data.
> This means a temporary data structure (perhaps a sizable List / Map) must be
> produced in order to present data to the Plugin..
> It would be more efficient and convenient to either support supply of a
> Hibernate Session object, or allow call to the plugin when both connection
> and datasource are absent. In this scenario, the plugin would respond by
> calling
> http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JasperFillManager.html#fillReport(java.io.InputStream,%20java.util.Map)
> And rely on Jasper Fill Manager's inbuilt functionality to draw connection
> detail from the supplied parameters. This option has the advantage that it
> can support a range of query languages / connection methods that
> JasperReports may support, now or in the future.
> The code would of course have to deal with the case in which the relevant
> report parameters have be left blank, and thus respond with an appropriate
> error condition, as it does in Struts 2.1.6 when dataSource has been left
> null.
> I will attempt to produce a patch with proposed modified code in the near
> future, to assist with this improvement.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)