title: How to use a JRMapCollectionDataSource with Fields and Lists?
body: <p>I am trying to create a report which populates a table of data. I have all the data within a collection of this structure:</p>
  
  <pre><code>Collection&lt;Map&lt;String, ?&gt;&gt; dataSource = new ArrayList&lt;&gt;();
  </code></pre>
  
  <p>I create the data as follows:</p>
  
  <pre><code>Collection&lt;BatchValue&gt; cashBatches = new ArrayList&lt;BatchValue&gt;();
  Collection&lt;BatchValue&gt; checkBatches = new ArrayList&lt;BatchValue&gt;();
  Collection&lt;Map&lt;String, ?&gt;&gt; dataSource = new ArrayList&lt;&gt;();    
  Map&lt;String, Object&gt; depositMap = new HashMap&lt;&gt;();
  depositMap.put("phoneNumber",   deposit.getControllersPhoneNumber());
  depositMap.put("accountNumber", deposit.getAccountNumber());
  depositMap.put("depositNumber", deposit.getDepositNumber().toString());
  depositMap.put("depositDate",   dateFormat.format(deposit.getDepositDate()));
  depositMap.put("checkCount", Long.toString(deposit.getTotalPayments()));
  depositMap.put("depositAmount", NumberFormat.getCurrencyInstance(Locale.US).format(deposit.getTotalDepositAmount()));
  depositMap.put("cashBatches", cashBatches); //Collection of objects
  depositMap.put("checkBatches", checkBatches); //Collection of objects
  
  dataSource.add(depositMap);
  </code></pre>
  
  <p>The object in the collection looks like this:</p>
  
  <pre><code>public class BatchValue {
  
      public BatchValue(String batchNumber, String batchTotal, String checkTotal) {
          super();
          this.batchNumber = batchNumber;
          this.batchTotal = batchTotal;
          this.checkTotal = checkTotal;
      }
      public String batchNumber;
      public String batchTotal;
      public String checkTotal;
      public String getBatchNumber() {
          return batchNumber;
      }
      public String getBatchTotal() {
          return batchTotal;
      }
      public String getCheckTotal() {
          return checkTotal;
      }
  }
  </code></pre>
  
  <p>Printing out works except my table data is null.  The report looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!-- Created with Jaspersoft Studio version 6.1.1.final using JasperReports Library version 6.1.1  --&gt;
  &lt;!-- 2016-01-07T13:29:51 --&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="cashReceiptsBalanceTape" pageWidth="260" pageHeight="600" columnWidth="220" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c88ca9b5-e46e-4379-a4a6-aa91568a6750"&gt;
      &lt;property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/&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;/style&gt;
      &lt;style name="Table 1_TH" mode="Opaque" backcolor="#FFFFFF"&gt;
          &lt;box&gt;
              &lt;pen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
              &lt;topPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
              &lt;leftPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
              &lt;bottomPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
              &lt;rightPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="Table 1_CH" mode="Opaque" backcolor="rgba(255, 191, 191, 0.0)"&gt;
          &lt;box&gt;
              &lt;pen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
              &lt;topPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
              &lt;leftPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
              &lt;bottomPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
              &lt;rightPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="Table 1_TD" mode="Opaque" backcolor="#FFFFFF"&gt;
          &lt;box&gt;
              &lt;pen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
              &lt;topPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
              &lt;leftPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
              &lt;bottomPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
              &lt;rightPen lineWidth="0.5" lineColor="rgba(0, 0, 0, 0.0)"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;subDataset name="cashBatches" uuid="d4f4efbb-3bc1-4134-b8a7-4f6fae0756b2"&gt;
          &lt;queryString&gt;
              &lt;![CDATA[]]&gt;
          &lt;/queryString&gt;
          &lt;field name="batchNumber" class="java.lang.String"/&gt;
          &lt;field name="checkCount" class="java.lang.String"/&gt;
          &lt;field name="batchTotal" class="java.lang.String"&gt;
              &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
          &lt;/field&gt;
      &lt;/subDataset&gt;
      &lt;subDataset name="checkBatches" uuid="b40af45e-8c43-49eb-815a-592bec1f5140"&gt;
          &lt;queryString&gt;
              &lt;![CDATA[]]&gt;
          &lt;/queryString&gt;
          &lt;field name="batchNumber" class="java.lang.String"/&gt;
          &lt;field name="checkCount" class="java.lang.String"/&gt;
          &lt;field name="batchTotal" class="java.lang.String"&gt;
              &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
          &lt;/field&gt;
      &lt;/subDataset&gt;
      &lt;queryString&gt;
          &lt;![CDATA[]]&gt;
      &lt;/queryString&gt;
      &lt;field name="accountNumber" class="java.lang.String"&gt;
          &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
      &lt;/field&gt;
      &lt;field name="phoneNumber" class="java.lang.String"&gt;
          &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
      &lt;/field&gt;
      &lt;field name="depositNumber" class="java.lang.String"&gt;
          &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
      &lt;/field&gt;
      &lt;field name="depositDate" class="java.lang.String"&gt;
          &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
      &lt;/field&gt;
      &lt;field name="checkCount" class="java.lang.String"&gt;
          &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
      &lt;/field&gt;
      &lt;field name="depositAmount" class="java.lang.String"&gt;
          &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
      &lt;/field&gt;
      &lt;field name="checkList" class="java.lang.String"&gt;
          &lt;fieldDescription&gt;&lt;![CDATA[]]&gt;&lt;/fieldDescription&gt;
      &lt;/field&gt;
      &lt;field name="cashBatches" class="java.util.Collection"/&gt;
      &lt;background&gt;
          &lt;band splitType="Stretch"/&gt;
      &lt;/background&gt;
      &lt;title&gt;
          &lt;band height="18" splitType="Stretch"&gt;
              &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
              &lt;printWhenExpression&gt;&lt;![CDATA[$V{PAGE_NUMBER} == 1]]&gt;&lt;/printWhenExpression&gt;
              &lt;staticText&gt;
                  &lt;reportElement x="9" y="1" width="196" height="16" uuid="7151aef5-2d0d-4982-a07f-602530cd14db"&gt;
                      &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
                  &lt;/reportElement&gt;
                  &lt;textElement textAlignment="Center"/&gt;
                  &lt;text&gt;&lt;![CDATA[Deposit Tape]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
          &lt;/band&gt;
      &lt;/title&gt;
      &lt;pageHeader&gt;
          &lt;band height="35" splitType="Stretch"&gt;
              &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
              &lt;printWhenExpression&gt;&lt;![CDATA[$V{PAGE_NUMBER} == 1]]&gt;&lt;/printWhenExpression&gt;
              &lt;staticText&gt;
                  &lt;reportElement x="9" y="4" width="60" height="16" uuid="2b6a4e34-7d68-4acf-8cd5-fd97ca24e16b"/&gt;
                  &lt;textElement verticalAlignment="Top"/&gt;
                  &lt;text&gt;&lt;![CDATA[Date Printed]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
              &lt;textField pattern="M/d/yy h:mm a"&gt;
                  &lt;reportElement x="69" y="3" width="136" height="16" uuid="2b533300-6aae-428b-a2be-117ea5560848"&gt;
                      &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
                  &lt;/reportElement&gt;
                  &lt;textElement verticalAlignment="Top"/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[new java.util.Date()]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;staticText&gt;
                  &lt;reportElement x="9" y="19" width="100" height="16" uuid="3b875843-da5d-424a-8540-f305c8d2b189"&gt;
                      &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
                  &lt;/reportElement&gt;
                  &lt;text&gt;&lt;![CDATA[State Insurance Fund]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
          &lt;/band&gt;
      &lt;/pageHeader&gt;
      &lt;detail&gt;
          &lt;band height="400" splitType="Stretch"&gt;
              &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
              &lt;property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/&gt;
              &lt;textField&gt;
                  &lt;reportElement x="69" y="1" width="100" height="16" uuid="3884d87f-bc02-408a-8de8-60bc9869532d"&gt;
                      &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
                  &lt;/reportElement&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{accountNumber}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField&gt;
                  &lt;reportElement x="9" y="19" width="100" height="16" uuid="b6c1b69a-4353-4315-99ba-19dd7e75b209"&gt;
                      &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
                  &lt;/reportElement&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{phoneNumber}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField&gt;
                  &lt;reportElement x="113" y="41" width="85" height="16" uuid="070b177a-3384-4886-aac1-1a0fda6e6109"&gt;
                      &lt;property name="com.jaspersoft.studio.unit.width" value="pixel"/&gt;
                  &lt;/reportElement&gt;
                  &lt;textElement textAlignment="Right"/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{depositNumber}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;staticText&gt;
                  &lt;reportElement x="9" y="41" width="100" height="16" uuid="4e698823-3523-4b98-884e-72541da8e37e"&gt;
                      &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
                  &lt;/reportElement&gt;
                  &lt;text&gt;&lt;![CDATA[Deposit No.]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
              &lt;textField&gt;
                  &lt;reportElement x="113" y="57" width="85" height="16" uuid="a3c67e6f-15a1-4f90-ad44-dfca3259a96d"&gt;
                      &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
                  &lt;/reportElement&gt;
                  &lt;textElement textAlignment="Right"/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{depositDate}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;staticText&gt;
                  &lt;reportElement x="9" y="57" width="100" height="16" uuid="3dacca23-94c7-4f5b-829e-406147029ed0"/&gt;
                  &lt;text&gt;&lt;![CDATA[Deposit Date]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
              &lt;textField&gt;
                  &lt;reportElement x="113" y="73" width="85" height="16" uuid="38c09b4e-33ad-48d5-828b-43ccb09d408e"&gt;
                      &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
                  &lt;/reportElement&gt;
                  &lt;textElement textAlignment="Right"/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{checkCount}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;staticText&gt;
                  &lt;reportElement x="9" y="73" width="100" height="16" uuid="176c17e0-40c0-458e-adb2-5b7df73586a1"/&gt;
                  &lt;text&gt;&lt;![CDATA[Check Count]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
              &lt;staticText&gt;
                  &lt;reportElement x="9" y="89" width="100" height="16" uuid="22f6ee5c-7e7f-4436-b363-7a7611c20a1a"/&gt;
                  &lt;text&gt;&lt;![CDATA[Deposit Amount]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
              &lt;textField&gt;
                  &lt;reportElement x="113" y="89" width="85" height="16" uuid="111ecf32-09d9-4fc8-99a6-f83fed971e99"&gt;
                      &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
                  &lt;/reportElement&gt;
                  &lt;textElement textAlignment="Right"/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{depositAmount}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;staticText&gt;
                  &lt;reportElement x="9" y="1" width="60" height="16" uuid="28512e49-36e3-4f4d-970d-97fe1996cb0f"&gt;
                      &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
                  &lt;/reportElement&gt;
                  &lt;text&gt;&lt;![CDATA[Account No.]]&gt;&lt;/text&gt;
              &lt;/staticText&gt;
              &lt;componentElement&gt;
                  &lt;reportElement x="16" y="137" width="189" height="103" isPrintWhenDetailOverflows="true" uuid="4709e78f-8a76-440c-a660-261c3ece5482"&gt;
                      &lt;property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/&gt;
                      &lt;property name="net.sf.jasperreports.export.headertoolbar.table.name" value="cashBatches"/&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" whenNoDataType="AllSectionsNoDetail"&gt;
                      &lt;datasetRun subDataset="cashBatches" uuid="9bd659a0-e16c-47fa-abcf-d0ee807cd1c2"&gt;
                          &lt;dataSourceExpression&gt;&lt;![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]&gt;&lt;/dataSourceExpression&gt;
                      &lt;/datasetRun&gt;
                      &lt;jr:column width="50" uuid="d09b02c6-a73e-4020-8198-8a742bfbe7ee"&gt;
                          &lt;jr:columnHeader style="Table 1_CH" height="30"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement x="0" y="0" width="50" height="30" uuid="3ba095fd-0b7c-4e85-b2ad-52c4c0d959f4"/&gt;
                                  &lt;text&gt;&lt;![CDATA[Batch Number]]&gt;&lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:columnHeader&gt;
                          &lt;jr:detailCell style="Table 1_TD" height="30"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement x="0" y="0" width="50" height="30" uuid="cb8ca692-b96f-41d5-af5f-b6bbd325166a"/&gt;
                                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{batchNumber}]]&gt;&lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                      &lt;jr:column width="30" uuid="0b05b7df-e05c-45c7-ab76-467eb9679a15"&gt;
                          &lt;jr:columnHeader style="Table 1_CH" height="30"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement x="0" y="0" width="30" height="30" uuid="de68b063-cc82-4b37-a849-827f9c9d2b59"/&gt;
                                  &lt;text&gt;&lt;![CDATA[Check Count]]&gt;&lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:columnHeader&gt;
                          &lt;jr:detailCell style="Table 1_TD" height="30"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement x="0" y="0" width="30" height="30" uuid="f6756213-69f2-4d88-9d7b-0d7de889a9c5"/&gt;
                                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{checkCount}]]&gt;&lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                      &lt;jr:column width="102" uuid="6038b058-f354-4322-9c1a-e425c6301ae7"&gt;
                          &lt;jr:columnHeader style="Table 1_CH" height="30"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement x="0" y="0" width="102" height="30" uuid="f5fc6b01-aa5c-44c3-95f6-da3c1c9c8357"/&gt;
                                  &lt;text&gt;&lt;![CDATA[Batch Total]]&gt;&lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:columnHeader&gt;
                          &lt;jr:detailCell style="Table 1_TD" height="30"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement x="0" y="0" width="102" height="30" uuid="b4a9187e-7b20-49e5-873a-9ee67ae2a555"/&gt;
                                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{batchTotal}]]&gt;&lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                  &lt;/jr:table&gt;
              &lt;/componentElement&gt;
              &lt;textField&gt;
                  &lt;reportElement x="-11" y="250" width="191" height="150" uuid="93ad77fe-963b-49df-b4c7-abb6891ea914"/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{cashBatches}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
          &lt;/band&gt;
      &lt;/detail&gt;
      &lt;summary&gt;
          &lt;band height="48" splitType="Stretch"&gt;
              &lt;textField&gt;
                  &lt;reportElement x="95" y="10" width="85" height="16" uuid="a6ca03fc-5921-489a-b9f1-5049e0a7a0e0"&gt;
                      &lt;property name="com.jaspersoft.studio.unit.height" value="pixel"/&gt;
                  &lt;/reportElement&gt;
                  &lt;textElement textAlignment="Right"/&gt;
                  &lt;textFieldExpression&gt;&lt;![CDATA[$F{depositAmount}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;line&gt;
                  &lt;reportElement x="84" y="4" width="98" height="1" uuid="3a51cf9c-87c4-4017-8bab-e0e868443242"/&gt;
              &lt;/line&gt;
          &lt;/band&gt;
      &lt;/summary&gt;
  &lt;/jasperReport&gt;
  </code></pre>
  
  <p>However if I print the field - the data is there as you can see in this image.</p>
  
  <p><a href="https://i.stack.imgur.com/sjXO4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sjXO4l.png" alt="Result"></a></p>