0

I have a Stock and StockRecords classes with one to many relationship.

In Stock.hbm.xml , i have a collection defined like this

<bag name="stockRecords" table="stockRecords" inverse="true" lazy="true"
  fetch="select">
<key>
    <column name="stock_Records" not-null="true" />
</key>
    <one-to-many class="com.my.model.objects.StockRecords" /> 
</bag>

I am accesing one stock at a time. here is the problem

Stockrecords has one filed (String type) which will contain 500000 characters in it on an average

In StockRecords.hbm.xml

<property name="summary" type="string" lazy="true"  >
        <column name="summary" />
    </property>

While i am accesing one of the stock entity based on id, i am trying to build a string of all the summary fields from all the stock records of that stock. I am getting java heap space error her i have my jvm setting set to 512m. is this hibernate or java thing?

hibernate 4.xx java 1.7

1
  • May be you will need to change 512m to 1024m. That might help. Commented Dec 6, 2016 at 20:45

1 Answer 1

1

Make sure you purge the entities from the Hibernate context with session.evict(obj) as soon as you don't need it anymore. Otherwise all these entities will fill your memory quite quickly.

You can also clear the whole context with session.clear() if being agressive is not an issue for your algorithm.

If this is not enough, you should consider increasing the Java heap size.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.