Skip to content

WW-3245 feat(jasperreports): fill from report parameters when no dataSource or connection is set - #1919

Merged
lukaszlenart merged 1 commit into
mainfrom
WW-3245-jasper-parameter-fill
Sep 12, 2026
Merged

WW-3245 feat(jasperreports): fill from report parameters when no dataSource or connection is set#1919
lukaszlenart merged 1 commit into
mainfrom
WW-3245-jasper-parameter-fill

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Fixes 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: connectiondataSource → 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

…Source or connection is set

Both result types insisted on either dataSource or connection and only ever
called the three-argument JasperFillManager.fillReport overloads, so a
report whose data comes from a JasperReports query executer (Hibernate,
CSV, JSON, EJBQL, ...) could not be filled without first materialising a
List in the action.

When neither is configured the result now calls fillReport(report, params)
and lets JasperReports resolve the data from the parameter map exactly as
its standalone API does: the executer's supplier object (HIBERNATE_SESSION,
CSV_INPUT_STREAM, ...) or a ready REPORT_DATA_SOURCE / REPORT_CONNECTION is
handed over via reportParameters. No parameter-key inspection and no new
dependency, so every present and future executer works the same way.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@lukaszlenart
lukaszlenart marked this pull request as ready for review September 12, 2026 08:54
lukaszlenart added a commit to apache/struts-site that referenced this pull request Sep 12, 2026
…330)

Companion to apache/struts#1919: dataSource is no longer required, and a
report can be filled from its parameters alone (HIBERNATE_SESSION,
CSV_INPUT_STREAM, REPORT_DATA_SOURCE, ...) when neither dataSource nor
connection is set.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@lukaszlenart
lukaszlenart merged commit 8f8be8f into main Sep 12, 2026
13 checks passed
@lukaszlenart
lukaszlenart deleted the WW-3245-jasper-parameter-fill branch September 12, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant