Announcement Announcement Module
No announcement yet.
Spring and Jasper-reports: Some rows are duplicating when generating a report. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring and Jasper-reports: Some rows are duplicating when generating a report.


    My problem is, that when I am generating report with Jasper, some rows are duplicating.

    For Jasper/Spring framework, I pass a collection of beans (each containing information of one row in the report to be generated) and when the report is ready, there is more rows in the report than elements in the collection just passed for the Spring/Jasper framework. By viewing the generated report I noticed that the reason for the increased amount of rows was that some information was duplicated.

    If I removed something from the collection passed to Jasper, duplicates were still generated but now completely different rows were duplicated and I couldn't see if there was any link between the content of the row and duplication occuring. I also tried collections with many different sizes but always some duplicates were generated. For example collection of size 77 generated 1 duplicate and size of 2000 generated about 100 duplicates. One interesting thing I noticed was that, when I replaced information of all the rows (collection's bean fields) under two of my report's columns with some static text, duplicates didn't appear. I also tested different types of report formats like CSV, PDF and HTML...and duplicates were always generated.

    So, my questions are, why these duplicates appear and what I can do to prevent them appearing?

    Here is some kind of description about the sw-architecture where this phenomenon is occuring:

    I have Spring/Jasper based implementation.

    I am extending ParametrizableViewController in one class
    -in handleRequestInternal-method I construct the model and create and return the ModelAndView-class.
    -the model contains the collection returned by another class.
    -the view of the ModelAndView is defined in XML based view-resolver as below:

    <bean id="iacCsvReportView" class="org.springframework.web.servlet.view.jasper reports.JasperReportsCsvView">
    <property name="reportDataKey" value="reportData"/>
    <property name="url" value="/WEB-INF/jrxml/i_a_c_csv.jrxml"/>
    <property name="exporterParameters">
    <entry key="net.sf.jasperreports.engine.export.JRCsvExpor terParameter.FIELD_DELIMITER" value=";"/>

    If I check the size of the collection in the ModelAndView-object just before returning it in the handleRequestInternal-method It has the right amount of rows. After that everything is done automatically by the already existing Spring and Jasper implementations, the CSV report gets ready and it contains some duplicates.

    If you have some kind of knowledge about this kind of problem, please guide me. If I'm not giving enough information about my situation just ask me and I will tell more.

    If this is not the right/best possible forum to ask this kind of question let me know

    Thanks for your interest.


  • #2

    I don't think the duplication could be related to JasperReports.
    It is the first time I hear about such a problem and our bean collection data source implementation was published years ago.
    You could try put aside JasperReports for a moment and check your collection of beans by iterating through it.
    What implementing class it behind your bean collection?

    I hope this helps.