I have a query in the following form
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..");
The issue is once it prints "starting..", it's hanging for as long as 10min, only to pull 1 or 2 results. How can 1 or 2 records take so long?
There is a one-to-one relationship between Invoice and Claim, but it's only defined from Invoice.
Can anyone explain why that line takes so long?