Note that there are some explanatory texts on larger screens.

plurals
  1. POOut of heap space with hibernate - what's the problem?
    text
    copied!<p>I'm running into the following (common) error after I added a new DB table, hibernate class, and other classes to access the hibernate class:</p> <p>java.lang.OutOfMemoryError: Java heap space</p> <p>Here's the relevant code:</p> <p>From .jsp:</p> <pre><code>&lt;% com.companyconnector.model.HomepageBean homepage = new com.companyconnector.model.HomepageBean(); %&gt; </code></pre> <p>From HomepageBean:</p> <pre><code>public class HomepageBean { ... private ReviewBean review1; private ReviewBean review2; private ReviewBean review3; public HomepageBean () { ... GetSurveyResults gsr = new GetSurveyResults(); List&lt;ReviewBean&gt; rbs = gsr.getRecentReviews(); review1 = rbs.get(0); review2 = rbs.get(1); review3 = rbs.get(2); } </code></pre> <p>From GetSurveyResults:</p> <pre><code>public List&lt;ReviewBean&gt; getRecentReviews() { List&lt;OpenResponse&gt; ors = DatabaseBean.getRecentReviews(); List&lt;ReviewBean&gt; rbs = new ArrayList&lt;ReviewBean&gt;(); for(int x = 0; ors.size() &gt; x; x =+ 2) { String employer = ""; rbs.add(new ReviewBean(ors.get(x).getUid(), employer, ors.get(x).getResponse(), ors.get(x+1).getResponse())); } return rbs; } </code></pre> <p>and lastly, from DatabaseBean:</p> <pre><code>public static List&lt;OpenResponse&gt; getRecentReviews() { SessionFactory session = HibernateUtil.getSessionFactory(); Session sess = session.openSession(); Transaction tx = sess.beginTransaction(); List results = sess.createQuery( "from OpenResponse where (uid = 46) or (uid = 50) or (uid = 51)" ).list(); tx.commit(); sess.flush(); sess.close(); return results; } </code></pre> <p>Sorry for all the code and such a long message, but I'm getting over a million instances of ReviewBean (I used jProfiler to find this). Am I doing something wrong in the for loop in GetSurveyResults? Any other problems?</p> <p>I'm happy to provide more code if necessary.</p> <p>Thanks for the help.</p> <p>Joe</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload