Jump to content
Changes to the Jaspersoft community edition download ×

Different behaviour when datasource changes

s. bit.

Recommended Posts


- make a table-like sales report groupped by day.


- a group band shows the sales date.

- in the details band there is a table containing all the data for the selected day

- the main (root) dataset selects the days; there is another dataset (Dataset1) that selects all the data for all the days; the table is connected to this Dataset1;

- to show in the table only the data for the selected date in the group, I added a parameter in Dataset1 equal to the field "sales date" in the root table, and a filter in Dataset1 to select only the sales for that date:

    <datasetParameter name="pSalesDate">
    <filterExpression><![CDATA[new Boolean ($F{salesDate}.compareTo($P{pSalesDate}) == 0)]]></filterExpression>

For the report's design and testing, I use Jasper Studio 6.3.1 and I connect directly to the database.  In this phase, the report works as requested!


In production, I have to run the report from a Java application and I cannot use a direct connection to the DB. To achieve this goal, I did:

- in the report design, I changed the main dataset to "one empty record" and the table connected to Dataset1 to "Use a JRDatasource expression". for ex. $P(MyDataSource)

- in the Java app I did:

JasperFillManager.fillReport (MyFileName, MyParams, MyMainDataSource);


- MyParams contains a JRBeanCollectionDataSource with all the sales info for all the days.

- MyMainDataSource is an implementation of JRDataSource class which returns each date.

The data extracted in these beans is identical to the data extracted by the SQLs used in the testing phase.

The result is that the report shows perfect the data for the first day (so the filter created still works!), but for the other days, it is printing only the group band with the date, but not the table.

The logs show that JR is reading first the first day, then it parses all the data (for all the days) from the JRBeanCollectionDataSource, then it reads the rest of the days from the main source, without reparsing the JRBeanCollection...

I tried all the "Evaluation Time" options for the parameter "pSalesDate" (see the code above) with no success.


Why the program behaves different when it is connected directly to the database compared to when we feed the data thru JRBeanCollectionDataSource?

Any suggestion how to make it work?


Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...