使用getResultList()检索查询结果花费的时间太长

时间:2017-03-12 06:38:58

标签: java list entitymanager

我有以下表格的查询

Query query = getEm().createNativeQuery("SELECT i.claimid, i.attachmentfilename, i.invoiceid, i.invoicedate, i.invoicenumber, "
                + "i.invoicetypeid, i.dealerinvoicenumber, i.bdxid, i.capturedate, i.paid, i.paymentdate "
                + "FROM invoice i WHERE i.claimid = "+claimId
                        + " AND i.invoicetypeid = 2 order by i.invoicedate DESC LIMIT 1", Invoice.class);
        logger.info(claimId+"=starting..");
        List<Invoice> invoices = query.getResultList();
        logger.info(claimId+"=ending..");

问题是一旦打印出“开始......”,它会挂起长达10分钟,只能拉出1或2个结果。 1或2条记录如何花费这么长时间?

Invoice和Claim之间存在一对一的关系,但它仅从Invoice定义。

有人可以解释为什么这条线需要这么长时间吗?

0 个答案:

没有答案