I want to pass the datasource from main report to a subreport.
So I simply change Connection Type in iReport to Use a datasource expression and pass the REPORT_DATA_SOURCE parameter.
The report should generate a few hundred sites. And it computes 1 subreport per page.
The subreport only needs some lines of the datasource, so it uses his own WHERE in the query.
The problem is:
after changing the Connection Type from Connection to Data Source, the Report only displays the first site. It seems as if the subreport changes the dataset of the mainreport with its WHERE statement to only one line.
I have seen solutions for that http://www.billmann.de/2011/12/01/jasperreports-subreport-datasource/ but when I try this, I get an error:
java.lang.ClassCastException: net.sf.jasperreports.engine.JRResultSetDataSource cannot be cast to net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
Are there other possibilities to clone a datasource? Or can I set something in Subreport, so that the datasource is not changed?
If I use Connection instead of DataSource, the Report works, but it renders 5 minutes and more, because every Subreport call generates its own Dataset.