Olá a todos!!
Estou tentando criar um subrelatório no Ireport (3.6.1), mas retorna apenas nulo os dados!!
Segue o código fonte:
As classes são: Employee, Address onde um employee pode ter um ou mais addresses!
<?xml version="1.0" encoding="UTF-8"?>
<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="employee" language="groovy" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<parameter name="IDEMP" class="java.lang.Long"/>
<queryString>
<![CDATA[select * from employee where id = $P{IDEMP}]]>
</queryString>
<field name="id" class="java.lang.Long">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="firstname" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="lastname" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<background>
<band/>
</background>
<title>
<band height="72">
<frame>
<reportElement mode="Opaque" x="-20" y="-20" width="595" height="92" backcolor="#006699"/>
<staticText>
<reportElement x="20" y="20" width="234" height="43" forecolor="#FFFFFF"/>
<textElement>
<font size="34" isBold="true"/>
</textElement>
<text><![CDATA[RELATORIO]]></text>
</staticText>
</frame>
</band>
</title>
<pageHeader>
<band height="13"/>
</pageHeader>
<columnHeader>
<band height="21">
<line>
<reportElement x="-20" y="20" width="595" height="1" forecolor="#666666"/>
</line>
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="185" height="20" forecolor="#006699" backcolor="#E6E6E6"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[id]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="185" y="0" width="185" height="20" forecolor="#006699" backcolor="#E6E6E6"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[firstname]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="370" y="0" width="185" height="20" forecolor="#006699" backcolor="#E6E6E6"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[lastname]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="161">
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="19" width="555" height="1"/>
</line>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="0" width="185" height="20"/>
<textElement>
<font size="14"/>
</textElement>
<textFieldExpression class="java.lang.Long"><![CDATA[$F{id}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="185" y="0" width="185" height="20"/>
<textElement>
<font size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{firstname}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="370" y="0" width="185" height="20"/>
<textElement>
<font size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{lastname}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="0" y="33" width="200" height="100"/>
<subreportParameter name="IDEMP">
<subreportParameterExpression><![CDATA[$F{id}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression class="java.lang.String"><![CDATA["C:\\Documents and Settings\\Fernando\\Desktop\\address.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<columnFooter>
<band/>
</columnFooter>
<pageFooter>
<band height="17">
<textField>
<reportElement mode="Opaque" x="0" y="4" width="515" height="13" backcolor="#E6E6E6"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.String"><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement mode="Opaque" x="515" y="4" width="40" height="13" backcolor="#E6E6E6"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement x="0" y="4" width="100" height="13"/>
<textElement/>
<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band/>
</summary>
</jasperReport>
Address
<?xml version="1.0" encoding="UTF-8"?>
<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="address" language="groovy" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<parameter name="IDEMP" class="java.lang.Long" isForPrompting="false"/>
<queryString language="SQL">
<![CDATA[select * from address, employee where address.idEmployee = employee.id]]>
</queryString>
<field name="id" class="java.lang.Long">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="city" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="country" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="estate" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="postalcode" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="street" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="idEmployee" class="java.lang.Long">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<background>
<band/>
</background>
<title>
<band height="4"/>
</title>
<pageHeader>
<band height="13"/>
</pageHeader>
<columnHeader>
<band height="21">
<line>
<reportElement x="-20" y="20" width="595" height="1" forecolor="#666666"/>
</line>
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="79" height="20" forecolor="#006699" backcolor="#E6E6E6"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[id]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="79" y="0" width="79" height="20" forecolor="#006699" backcolor="#E6E6E6"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[city]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="158" y="0" width="79" height="20" forecolor="#006699" backcolor="#E6E6E6"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[country]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="237" y="0" width="79" height="20" forecolor="#006699" backcolor="#E6E6E6"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[estate]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="316" y="0" width="79" height="20" forecolor="#006699" backcolor="#E6E6E6"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[postalcode]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="395" y="0" width="79" height="20" forecolor="#006699" backcolor="#E6E6E6"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[street]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="474" y="0" width="79" height="20" forecolor="#006699" backcolor="#E6E6E6"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[idEmployee]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20">
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="19" width="555" height="1"/>
</line>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="0" width="79" height="20"/>
<textElement>
<font size="14"/>
</textElement>
<textFieldExpression class="java.lang.Long"><![CDATA[$F{id}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="79" y="0" width="79" height="20"/>
<textElement>
<font size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{city}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="158" y="0" width="79" height="20"/>
<textElement>
<font size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{country}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="237" y="0" width="79" height="20"/>
<textElement>
<font size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{estate}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="316" y="0" width="79" height="20"/>
<textElement>
<font size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{postalcode}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="395" y="0" width="79" height="20"/>
<textElement>
<font size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{street}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="474" y="0" width="79" height="20"/>
<textElement>
<font size="14"/>
</textElement>
<textFieldExpression class="java.lang.Long"><![CDATA[$F{idEmployee}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band/>
</columnFooter>
<pageFooter>
<band height="4"/>
</pageFooter>
<summary>
<band/>
</summary>
</jasperReport>
Criei os dois relatórios separadamente, e depois adicionei o relatório do address ao rel. do employee como subrelatório!