I have a table in the database that has about 2.3 million records.
I need to export this data to a csv file through a java / web application.
I'm using JPA / Hibernate. But I'm having trouble.
HibernateEntityManager hem = this.getEntityManager().unwrap(HibernateEntityManager.class);
Session session = hem.getSession();
org.hibernate.Query qu =
session.createSQLQuery("select li.* from ligacoes li").
setFetchSize(Integer.MIN_VALUE).setReadOnly(true);
ScrollableResults r = qu.scroll(ScrollMode.FORWARD_ONLY);
int count = 0;
while (r.next()) {
But when the program reads about 200,000 records it throws an exception:
Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]"
java.lang.OutOfMemoryError: Java heap space
I've tried other means, but I'm still having difficulties. I can't export the data directly from the database. The data must be exported through this application.
Can anyone help?