Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Heap exception while loading complete table data from database

 
Matt Josh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

In my project I am using JPA.
Recently we have created JPA pojo from existing Tables in schema using JPA Entities from Table tool.
Now I am using Spring JpaDaoSupport at DAO layer.
I started with simple query to fetch POJO based on primary key that works fine.
when I try to fetch all data for given entity it throws heap error.
My entity as strucuture something like this.




Please suggest if I can implemenet some kind of lazy initialization to avoid heap issue


I am very new to JPA based implementation request you to please give suggestion on initialization and load strategy.

Matt
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are already using lazy initialization. Could it be that you just don;t have enough heap space to load all Entity records?
 
Matt Josh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to set Lazy loading for OneToOne mapping ojects?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but you are not using OneToOne mappings?
 
Matt Josh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In database I have 207306 rows for Entity as part of process I have to read all this data and put to some cache.
Is it possible to implement some kind of paging or slicing which automatically fetch x number of rows get result which I can save in cache
again make call to get fix number of data.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have to put all 207306 rows in the cache? If so, paging will not help - you need a much bigger heap or a disk based cache.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic