title: How to use same JRBeanCollectionDataSource on multiple sub reports?
body: <p>I call two subreports with same datasource, however when I print this report, only my 1st sub-report is populated with table.</p>
  
  <p>This is how I pass the <code>statsData1</code> to report.</p>
  
  <pre><code>List&lt;BasicStats&gt; summaryList = new ArrayList&lt;&gt;();
  summaryList.add(new BasicStats("A", 5d, 6.5d, 25d));
  summaryList.add(new BasicStats("B", 1.47d, 2.7d, 72d));
  summaryList.add(new BasicStats("c", .39d, 9.5d, 91d));
  summaryList.add(new BasicStats("D", 8.2d, 1.3d, 37d));
  summaryList.add(new BasicStats("E", 6.8d, 4.5d, 19d));
  
  Map&lt;String, Object&gt; paramsMap = new HashMap&lt;&gt;();
  JRBeanCollectionDataSource jbcdSummary = new JRBeanCollectionDataSource(summaryList);
  paramsMap.put("statsData1", jbcdSummary);
  </code></pre>
  
  <p>Although, I have notice that if I pass 2 different objects like below, it works (with relevant modifications to jrxml below) I get both sub-report tables.</p>
  
  <pre><code>paramsMap.put("statsData1", new JRBeanCollectionDataSource(summaryList));
  paramsMap.put("statsData2", new JRBeanCollectionDataSource(summaryList));
  </code></pre>
  
  <p>Does this have something to do with <code>JRBeanCollectionDataSource</code> being a consumable object or something?</p>
  
  <p><strong>This is my main jrxml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  --&gt;
  &lt;jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="main" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="6a63a79b-6f04-46c7-b3b9-a067e835ea4d"&gt;
      &lt;parameter name="subRptTitle" class="java.lang.String"/&gt;
      &lt;parameter name="statsData1" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/&gt;
      &lt;background&gt;
          &lt;band splitType="Stretch"/&gt;
      &lt;/background&gt;
      &lt;title&gt;
          &lt;band height="79" splitType="Stretch"&gt;
              &lt;textField&gt;
                  &lt;reportElement x="250" y="20" width="100" height="30" uuid="42f86896-5b37-4ee3-8f0c-29bf90eb3846"/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$P{subRptTitle}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
          &lt;/band&gt;
      &lt;/title&gt;
      &lt;summary&gt;
          &lt;band height="203" splitType="Stretch"&gt;
              &lt;subreport&gt;
                  &lt;reportElement x="10" y="31" width="281" height="161" uuid="73d60b1f-1b66-44b1-a8a5-d9738067aaf1"/&gt;
                  &lt;subreportParameter name="statsData"&gt;
                      &lt;subreportParameterExpression&gt;&lt;![CDATA[$P{statsData1}]]&gt;&lt;/subreportParameterExpression&gt;
                  &lt;/subreportParameter&gt;
                  &lt;dataSourceExpression&gt;&lt;![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]&gt;&lt;/dataSourceExpression&gt;
                  &lt;subreportExpression&gt;&lt;![CDATA["sub-table.jasper"]]&gt;&lt;/subreportExpression&gt;
              &lt;/subreport&gt;
              &lt;subreport&gt;
                  &lt;reportElement x="310" y="31" width="273" height="161" uuid="686bb10d-7018-4cf1-b72b-c17e534ec5e0"/&gt;
                  &lt;subreportParameter name="statsData"&gt;
                      &lt;subreportParameterExpression&gt;&lt;![CDATA[$P{statsData1}]]&gt;&lt;/subreportParameterExpression&gt;
                  &lt;/subreportParameter&gt;
                  &lt;dataSourceExpression&gt;&lt;![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]&gt;&lt;/dataSourceExpression&gt;
                  &lt;subreportExpression&gt;&lt;![CDATA["sub-table.jasper"]]&gt;&lt;/subreportExpression&gt;
              &lt;/subreport&gt;
          &lt;/band&gt;
      &lt;/summary&gt;
  &lt;/jasperReport&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>This is my sub-report, <code>sub-table.jrxml</code></strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  --&gt;
  &lt;jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="main" pageWidth="200" pageHeight="842" columnWidth="200" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="6a63a79b-6f04-46c7-b3b9-a067e835ea4d"&gt;
      &lt;style name="Table_TH" mode="Opaque" backcolor="#F0F8FF"&gt;
          &lt;box&gt;
              &lt;pen lineWidth="0.5" lineColor="#000000"/&gt;
              &lt;topPen lineWidth="0.5" lineColor="#000000"/&gt;
              &lt;leftPen lineWidth="0.5" lineColor="#000000"/&gt;
              &lt;bottomPen lineWidth="0.5" lineColor="#000000"/&gt;
              &lt;rightPen lineWidth="0.5" lineColor="#000000"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="Table_CH" mode="Opaque" backcolor="#BFE1FF"&gt;
          &lt;box&gt;
              &lt;pen lineWidth="0.5" lineColor="#000000"/&gt;
              &lt;topPen lineWidth="0.5" lineColor="#000000"/&gt;
              &lt;leftPen lineWidth="0.5" lineColor="#000000"/&gt;
              &lt;bottomPen lineWidth="0.5" lineColor="#000000"/&gt;
              &lt;rightPen lineWidth="0.5" lineColor="#000000"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="Table_TD" mode="Opaque" backcolor="#FFFFFF"&gt;
          &lt;box&gt;
              &lt;pen lineWidth="0.5" lineColor="#000000"/&gt;
              &lt;topPen lineWidth="0.5" lineColor="#000000"/&gt;
              &lt;leftPen lineWidth="0.5" lineColor="#000000"/&gt;
              &lt;bottomPen lineWidth="0.5" lineColor="#000000"/&gt;
              &lt;rightPen lineWidth="0.5" lineColor="#000000"/&gt;
          &lt;/box&gt;
          &lt;conditionalStyle&gt;
              &lt;conditionExpression&gt;&lt;![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]&gt;&lt;/conditionExpression&gt;
              &lt;style backcolor="#FBFDFF"/&gt;
          &lt;/conditionalStyle&gt;
      &lt;/style&gt;
      &lt;subDataset name="tableDataSet" uuid="2914f7c6-c2d7-448b-b0c1-090970e18ed6"&gt;
          &lt;field name="subEntity" class="java.lang.String"/&gt;
          &lt;field name="total" class="java.lang.Double"/&gt;
          &lt;field name="pending" class="java.lang.Double"/&gt;
          &lt;field name="percentage" class="java.lang.Double"/&gt;
          &lt;variable name="vTotalSum" class="java.lang.Double" calculation="Sum"&gt;
              &lt;variableExpression&gt;&lt;![CDATA[$F{total}]]&gt;&lt;/variableExpression&gt;
          &lt;/variable&gt;
          &lt;variable name="vPendingSum" class="java.lang.Double" calculation="Sum"&gt;
              &lt;variableExpression&gt;&lt;![CDATA[$F{pending}]]&gt;&lt;/variableExpression&gt;
          &lt;/variable&gt;
          &lt;variable name="vPercentageSum" class="java.lang.Double" calculation="Sum"&gt;
              &lt;variableExpression&gt;&lt;![CDATA[$F{percentage}]]&gt;&lt;/variableExpression&gt;
          &lt;/variable&gt;
      &lt;/subDataset&gt;
      &lt;parameter name="subRptTitle" class="java.lang.String"/&gt;
      &lt;parameter name="statsData" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/&gt;
      &lt;background&gt;
          &lt;band splitType="Stretch"/&gt;
      &lt;/background&gt;
      &lt;title&gt;
          &lt;band height="79" splitType="Stretch"&gt;
              &lt;textField&gt;
                  &lt;reportElement x="50" y="30" width="100" height="30" uuid="42f86896-5b37-4ee3-8f0c-29bf90eb3846"/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$P{subRptTitle}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
          &lt;/band&gt;
      &lt;/title&gt;
      &lt;summary&gt;
          &lt;band height="203" splitType="Stretch"&gt;
              &lt;componentElement&gt;
                  &lt;reportElement x="9" y="11" width="182" height="181" uuid="7451c7aa-8532-471e-ad02-eb98ca21d171"&gt;
                      &lt;property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/&gt;
                      &lt;property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/&gt;
                      &lt;property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/&gt;
                      &lt;property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/&gt;
                  &lt;/reportElement&gt;
                  &lt;jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"&gt;
                      &lt;datasetRun subDataset="tableDataSet" uuid="eecbe24c-593f-42fa-a7ab-2fbe8b59cb34"&gt;
                          &lt;dataSourceExpression&gt;&lt;![CDATA[$P{statsData}]]&gt;&lt;/dataSourceExpression&gt;
                      &lt;/datasetRun&gt;
                      &lt;jr:column width="45" uuid="6ea97833-5ba6-48f1-9096-66bb2d6d5978"&gt;
                          &lt;jr:tableHeader style="Table_TH" height="30"/&gt;
                          &lt;jr:tableFooter style="Table_TH" height="30"/&gt;
                          &lt;jr:columnHeader style="Table_CH" height="30"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement x="0" y="0" width="45" height="30" uuid="afce87c3-7a33-4b79-9627-2c2f37d78609"/&gt;
                                  &lt;text&gt;&lt;![CDATA[subEntity]]&gt;&lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:columnHeader&gt;
                          &lt;jr:columnFooter style="Table_CH" height="30"/&gt;
                          &lt;jr:detailCell style="Table_TD" height="30"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement x="0" y="0" width="45" height="30" uuid="f312e4dc-bd65-4cf6-8c2c-27c1d88940b9"/&gt;
                                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{subEntity}]]&gt;&lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                      &lt;jr:column width="45" uuid="89672e7b-ee57-4a0d-8f6e-885c189a9c1d"&gt;
                          &lt;jr:tableHeader style="Table_TH" height="30"/&gt;
                          &lt;jr:tableFooter style="Table_TH" height="30"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement x="0" y="0" width="45" height="30" uuid="c8ef39c5-ea48-41e4-a069-9d07e1ce301b"/&gt;
                                  &lt;textFieldExpression&gt;&lt;![CDATA[$V{vTotalSum}]]&gt;&lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:tableFooter&gt;
                          &lt;jr:columnHeader style="Table_CH" height="30"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement x="0" y="0" width="45" height="30" uuid="c57bbc8c-b840-45fd-b21a-3b7121c29f71"/&gt;
                                  &lt;text&gt;&lt;![CDATA[total]]&gt;&lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:columnHeader&gt;
                          &lt;jr:columnFooter style="Table_CH" height="30"/&gt;
                          &lt;jr:detailCell style="Table_TD" height="30"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement x="0" y="0" width="45" height="30" uuid="bf1068c6-42f2-4cb4-b1f0-8b195d362247"/&gt;
                                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{total}]]&gt;&lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                      &lt;jr:column width="45" uuid="4b3eea40-3cca-48a8-961f-6fbe9edfb973"&gt;
                          &lt;jr:tableHeader style="Table_TH" height="30"/&gt;
                          &lt;jr:tableFooter style="Table_TH" height="30"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement x="0" y="0" width="45" height="30" uuid="f4787fdd-5f5b-4f03-97e7-05e4c2c34f0f"/&gt;
                                  &lt;textFieldExpression&gt;&lt;![CDATA[$V{vPendingSum}]]&gt;&lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:tableFooter&gt;
                          &lt;jr:columnHeader style="Table_CH" height="30"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement x="0" y="0" width="45" height="30" uuid="5aa2afde-3b32-480e-b115-9ffddf95ab64"/&gt;
                                  &lt;text&gt;&lt;![CDATA[pending]]&gt;&lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:columnHeader&gt;
                          &lt;jr:columnFooter style="Table_CH" height="30"/&gt;
                          &lt;jr:detailCell style="Table_TD" height="30"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement x="0" y="0" width="45" height="30" uuid="89a528bc-2e09-467f-b709-7434bc6732da"/&gt;
                                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{pending}]]&gt;&lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                      &lt;jr:column width="45" uuid="a7c26c8f-361f-4d33-820a-abd2cb3268ad"&gt;
                          &lt;jr:tableHeader style="Table_TH" height="30"/&gt;
                          &lt;jr:tableFooter style="Table_TH" height="30"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement x="0" y="0" width="45" height="30" uuid="7e1115c0-35fb-48d2-b0bd-b36e5a782d67"/&gt;
                                  &lt;textFieldExpression&gt;&lt;![CDATA[$V{vPercentageSum}]]&gt;&lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:tableFooter&gt;
                          &lt;jr:columnHeader style="Table_CH" height="30"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement x="0" y="0" width="45" height="30" uuid="20743d33-811c-411a-b7d1-c78e57ccd018"/&gt;
                                  &lt;text&gt;&lt;![CDATA[percentage]]&gt;&lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:columnHeader&gt;
                          &lt;jr:columnFooter style="Table_CH" height="30"/&gt;
                          &lt;jr:detailCell style="Table_TD" height="30"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement x="0" y="0" width="45" height="30" uuid="ebeb9419-af5d-4475-a8f7-ab13ab4a7b9f"/&gt;
                                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{percentage}]]&gt;&lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                  &lt;/jr:table&gt;
              &lt;/componentElement&gt;
          &lt;/band&gt;
      &lt;/summary&gt;
  &lt;/jasperReport&gt;
  </code></pre>
  
  <p>Changes to <code>sub-table.jrxml</code> to make it work with 2 parameters</p>
  
  <pre><code>&lt;parameter name="statsData1" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/&gt;
  &lt;parameter name="statsData2" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/&gt;
  &lt;subreport&gt;
                      &lt;reportElement x="310" y="31" width="273" height="161" uuid="686bb10d-7018-4cf1-b72b-c17e534ec5e0"/&gt;
                      &lt;subreportParameter name="statsData"&gt;
                          &lt;subreportParameterExpression&gt;&lt;![CDATA[$P{statsData2}]]&gt;&lt;/subreportParameterExpression&gt;
                      &lt;/subreportParameter&gt;
                      &lt;dataSourceExpression&gt;&lt;![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]&gt;&lt;/dataSourceExpression&gt;
                      &lt;subreportExpression&gt;&lt;![CDATA["sub-table.jasper"]]&gt;&lt;/subreportExpression&gt;
                  &lt;/subreport&gt;
  </code></pre>
  
  <p>What is a better workaround for this?</p>