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.