- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
为什么下面的查询在 JasperReports 中没有返回所需的结果。
SELECT bbd.Bill_Id, bbd.ItemName, bbd.ItemQuantity, bbd.ItemPrice, bbd.Date FROM `borrowerbillsdetails` bbd JOIN `borrowerbills` as bb ON bbd.`Bill_Id` = bb.`Bill_Id` WHERE $X{IN ,Bill_Id, billIds}
它只返回 3 个结果,而在我传递的参数列表中有 7 个 ID,所有 ID 在数据库表中都有数据。
我传递参数的 Controller 代码:
String cnic = txtCnic.getText();
String borrowerHistorypath = "/home/JRXML/BorrowerHistory.jrxml";
Connection con = null;
try {
con = DBConnection.getConnection();
List<BorrowerBill> borrowerBillLists = borrowerBillService.getAllBillsByCnic(cnic);
List<Integer> billIds = new ArrayList<>();
for(BorrowerBill borrowerBill:borrowerBillLists){
billIds.add(borrowerBill.getBillId());
}
FileInputStream fileInputStream = new FileInputStream(borrowerHistorypath);
BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
Map map = new HashMap();
map.put("cnic", cnic);
map.put("billIds",billIds);
JasperReport jasperReport = (JasperReport) JasperCompileManager.compileReport(bufferedInputStream);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, map, con);
JasperViewer jasperViewer = new JasperViewer(jasperPrint, false);
jasperViewer.viewReport(jasperPrint,false);
相关的 jasper 报告 Jrxml 文件如下(用于 BorrowerBillItems)
数据集
<subDataset name="BillItemsDataSet" uuid="39900337-1c6a-403d-a889-82ee3ca1fd8a">
<parameter name="billIds" class="java.util.List"/>
<queryString language="SQL">
<![CDATA[SELECT bbd.Bill_Id, bbd.ItemName, bbd.ItemQuantity, bbd.ItemPrice, bbd.Date FROM `borrowerbillsdetails` bbd JOIN `borrowerbills` as bb ON bbd.`Bill_Id` = bb.`Bill_Id` WHERE $X{IN ,Bill_Id, billIds}]]>
</queryString>
<field name="Bill_Id" class="java.lang.Integer">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="ItemName" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="ItemQuantity" class="java.lang.Double">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="ItemPrice" class="java.lang.Double">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="Date" class="java.sql.Date">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
</subDataset>
表格
<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">
<datasetRun subDataset="BillItemsDataSet" uuid="ccd44e17-2c5d-417c-b4a7-554d197ce483">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="113" uuid="44bd8219-2732-4853-bf2e-960be7c528be">
<jr:tableHeader style="table 5_TH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="113" height="30" uuid="bebb3df5-79aa-4905-b478-6995f7c53f05"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[S No]]></text>
</staticText>
</jr:tableHeader>
<jr:detailCell style="table 8_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="113" height="20" uuid="5a44f3b8-f7e4-48ce-bf0a-fc2ca083a979"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{Bill_Id}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="135" uuid="c76aecbd-16aa-4ca2-90c9-613c7e5abee1">
<jr:tableHeader style="table 5_TH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="135" height="30" uuid="6441c557-38b8-47dc-bfdc-e2d476da830c"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Item Name]]></text>
</staticText>
</jr:tableHeader>
<jr:detailCell style="table 8_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="135" height="20" uuid="5a44f3b8-f7e4-48ce-bf0a-fc2ca083a979"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{ItemName}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="118" uuid="a98065a6-a07d-4bda-9e08-6d81552ce2ff">
<jr:tableHeader style="table 5_TH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="118" height="30" uuid="6928b4cb-519c-4020-930f-44ddaf1ddd6a"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Quantity]]></text>
</staticText>
</jr:tableHeader>
<jr:detailCell style="table 8_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="118" height="20" uuid="5a44f3b8-f7e4-48ce-bf0a-fc2ca083a979"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{ItemQuantity}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="119" uuid="fdeb9dac-b4ec-4cf1-936e-ac3c70846b61">
<jr:tableHeader style="table 5_TH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="119" height="30" uuid="f6afc863-f4f1-49d6-97ce-13bf049013f8"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Price]]></text>
</staticText>
</jr:tableHeader>
<jr:detailCell style="table 8_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="119" height="20" uuid="5a44f3b8-f7e4-48ce-bf0a-fc2ca083a979"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{ItemPrice}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="145" uuid="476a5c33-5b9a-4c33-8366-3027b490cab6">
<jr:tableHeader style="table 5_TH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="145" height="30" uuid="235f9670-1447-4079-a00a-5fe046d68514"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Date]]></text>
</staticText>
</jr:tableHeader>
<jr:detailCell style="table 8_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="145" height="20" uuid="5a44f3b8-f7e4-48ce-bf0a-fc2ca083a979"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{Date}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
这是我得到的结果。
借款人账单项目是主要关注点。
在调试时,从上述查询生成的查询是当我指定它为 jasper 文件时,在 Debug模式下没有打印任何参数。
SQL query string: SELECT bbd.Bill_Id, bbd.ItemName, bbd.ItemQuantity, bbd.ItemPrice, bbd.Date FROM `borrowerbillsdetails` bbd JOIN `borrowerbills` as bb ON bbd.`Bill_Id` = bb.`Bill_Id` WHERE 0 = 0
而对于其他人,它会创建正确的查询,例如
SQL query string: Select * from borrowerbills where cnic = ?
2016-10-09 22:20:10 DEBUG JRJdbcQueryExecuter:509 - Parameter #1 (cnic of type java.lang.String): 1610186922393
最佳答案
您的代码正在传递主数据集的值。您应该将参数的值传递给 subDataset。
在您的情况下,代码将是:
<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">
<datasetRun subDataset="BillItemsDataSet" uuid="ccd44e17-2c5d-417c-b4a7-554d197ce483">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<datasetParameter name="billIds">
<datasetParameterExpression><![CDATA[$P{billIds}]]></datasetParameterExpression>
</datasetParameter>
</datasetRun>
或者您可以借助 $P{REPORT_PARAMETERS_MAP}
传递所有参数
<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">
<datasetRun subDataset="BillItemsDataSet" uuid="ccd44e17-2c5d-417c-b4a7-554d197ce483">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
</datasetRun>
关于java - 碧 Jade 报告 : IN Clause is empty in case using subDataset with parameter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39946608/
我经常在 ATS 中看到使用 case、case+ 或 case- 形成的 case 表达式。有什么区别? 最佳答案 如果表达式不详尽,使用 case 会发出警告,case+ 会产生错误,而 case
我有一个导入时全部大写的表,我想将其转换为正确的大小写。你们用什么脚本来完成这个? 最佳答案 这个函数: “正确大小写”由空格分隔的所有“大写”单词 保留“小写单词” 即使对于非英语字母也能正常工作
#include int main() { switch(2) { case 1: if(1)
我已经四处寻找了一段时间,如果我使用的术语不当,请原谅我... 代码的目标是在输入为 0 时更新 Aout1 和 Aout0,输出对应于 7 段显示,但出现以下错误: “错误 (10170):Four
我正在尝试按照 PostgreSQL 手册中的说明进行操作。 PostgreSQL: Documentation: 9.1: Control Structures 我的 PostgreSQL 服务器是
我有一个状态机,其中有几个非常相似的状态。我可以为每个状态编写它,如下例所示: module CHECK_FSM ( GO, DONE, CLK, RESETN ); input GO;
如何使用或创建案例? 就像是: string str; case (str) "abc" || "dfg": begin //some code end "yfg":
这个问题已经有答案了: Are double and single quotes interchangeable in JavaScript? (23 个回答) 已关闭 9 年前。 我正在学习Java
汽车 Make | Model | Year | Color Honda | Accord | 12 | Red Lexus | IS | 14 |
如何使用当前 case 语句的值跳转到 switch-case 条件下的另一个 case 语句? 是否可以使用 switch case 来实现这种事情,或者是否有其他实现方式? 有可能实现吗?如果没有
我理解下面的代码。 var day = 2; switch (day) { case 1: document.write("Monday"); break;
这是有效的。 object FilesToDFDS { case class Student(id: Int, name: String, dept:String) def main(
我对 VHDL 还是个新手。我需要在 CASE 语句中为多个信号赋值,如下所示: CASE input24 IS WHEN "00" THEN output0
我有这个 case 语句,它给出了一个错误“变量 constant1 未使用”。它似乎忽略了变量并返回了第一行,因此变量显然没有范围。如果我用数字 1 替换常量,那么它就可以工作。在 Elixir 中
在 MySQL 中,是否可以在 SELECT 子句中有两个 CASE 语句,其中第二个 CASE 语句依赖于第一个 CASE 语句? 例如,考虑以下查询: SELECT CASE WHEN `user
我正在尝试一个挑战,我需要获得一个随机数,并在没有重复的情况下打印数字内的数字总和:例如,123 将打印 6 ( 1 + 2 + 3 ),而 32111 将做同样的事情(因为我们没有在我们的总和中添加
当有人试图更新当前未存储在我的散列中的值时,我想立即返回 when 'add' 而无需重新启动整个 case声明,因为我已经知道他们想要添加并且不想再次提示他们。 有没有一种方法可以在不重新启动整个案
老 C 程序员可以在 Swift 方面得到一些帮助。 我不太了解 if-case 语法。例如: if case 20...30 = age { print ("in range.") } cas
老 C 程序员可以在 Swift 方面得到一些帮助。 我不太了解 if-case 语法。例如: if case 20...30 = age { print ("in range.") } cas
我有一个 ArrayList,其中包含以下字符串:[name, age, gender, salary] . 有没有办法可以将 ArrayList 中的值用作 case 表达式? 显而易见的答案是否定
我是一名优秀的程序员,十分优秀!