title: java.lang.OutOfMemoryError: Java heap space in hibernate while picking 200 thousand rows
body: <p>I am using hibernate 4.3.10, java 1.8 and eclipse neon.
  I have been trying to execute the following statement in my code. But </p>
  
  <blockquote>
    <p>java.lang.OutOfMemoryError: Java heap space</p>
  </blockquote>
  
  <p>is thrown at the second line after a few minutes. </p>
  
  <pre><code>Query query = mySqlSession.createSQLQuery("select * from hops where processed is null");
  List&lt;Object[]&gt; lis=query.list();
  </code></pre>
  
  <p>The problem is this query return about 200k results which is causing the problem. I have refered
   <a href="https://stackoverflow.com/questions/37335/how-to-deal-with-java-lang-outofmemoryerror-java-heap-space-error-64mb-heap">How to deal with &quot;java.lang.OutOfMemoryError: Java heap space&quot; error (64MB heap size)</a></p>
  
  <p>after reading solutions from the above link, I changed the memory to 2 GB. Still there seems to be a problem.
  Any suggestions?</p>