I want to reduce hibernate session's overhead (to boost performance because session takes too much time to handle its stored objects) and try to use stateless session:
statelessSession.createQuery(
"SELECT me, me.mailSourceFile, me.linf " +
"FROM MessageEntry me " +
"WHERE me.mailSourceFile.archive.folder = :folder " +
"ORDER BY me.messageLength DESC")
.setString("folder", folder)
.scroll(ScrollMode.FORWARD_ONLY);
But .scroll(...) gives
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at com.mysql.jdbc.Buffer.<init>(Buffer.java:59)
at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1477)
at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:2936)
at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:477)
...
My code doesn't have memleaks, it works correctly with Session and .iterator(). How else should I use stateless session to avoid crash?
Thanx.