0
String reportQuery="Select pr from ProductivityReport pr where pr.reportDate=:reportDate";
Query query = entityDao.getEntityManager().createQuery(reportQuery,ProductivityReport.class).setHint("org.hibernate.readOnly", Boolean.TRUE);
    

Here I am trying to fetch a result on the basis of date where I get

Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded

As I have went for solution to related sites and the solutions are: To implement ScrollableResults if you wants to fetch millions of records but this method is not defined in Query interface in our product.

To apply pagination, but if I hit ResultList more than once, I'm facing an exception

java.lang.IllegalStateException: Session/EntityManager is closed that is due to session closed.

query.setHint("eclipselink.read-only", "true"); also not working.

Please suggest me an another solution for fetching millions of rows through JPA as I get stuck to those exceptions which in result gives me an unexpected behaviour while generating report i.e. page gets unresponsive.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • You're trying to retrieve so many rows that your JavaVM instance runs out of RAM. It isn't a garbage-collector (GC) issue, it's a too-much-data to handle at once issue. You must figure out how to fetch those rows one at a time or in batches, not all at once. – O. Jones Dec 05 '20 at 22:54
  • Can fetch data in batches like monthwise. – Nakul Goyal Dec 07 '20 at 05:30

0 Answers0