Hi All,
I have a very strange problem. Strange to me at least. I have a repository that I've added a findOne to.
The Snapshot domain has 4 collections and some other properties, 1 set and 3 lists. I can call findAll() with no issues, but when I call findOne(Long id) the thread eats up all the heap memory and throws the Java heap exception. If I remove one of the collections, the set or one of the lists I do not get the error anymore and it can be anyone of the collections I remove. Like I said I can call findAll() then get the last item in the list and display those results with no issue. It's only when I actually try to call findOne(Long id) by ID it goes absolutely nuts consuming memory. I'm calling the methods from a controller. Very strange because findAll() uses very little memory. I've profiled and observed using VisualVM. Any ideas? This has been a frustrating one. Could there be a serious bug in the CrudRepository?
Code and stack trace posted below.
I have a very strange problem. Strange to me at least. I have a repository that I've added a findOne to.
The Snapshot domain has 4 collections and some other properties, 1 set and 3 lists. I can call findAll() with no issues, but when I call findOne(Long id) the thread eats up all the heap memory and throws the Java heap exception. If I remove one of the collections, the set or one of the lists I do not get the error anymore and it can be anyone of the collections I remove. Like I said I can call findAll() then get the last item in the list and display those results with no issue. It's only when I actually try to call findOne(Long id) by ID it goes absolutely nuts consuming memory. I'm calling the methods from a controller. Very strange because findAll() uses very little memory. I've profiled and observed using VisualVM. Any ideas? This has been a frustrating one. Could there be a serious bug in the CrudRepository?
Code and stack trace posted below.
Code:
import com.cortive.dispatchboard.domain.Snapshot;
import org.springframework.data.repository.CrudRepository;
public interface SnapshotRepository extends CrudRepository<Snapshot, Long> {
List<Snapshot> findAll();
Snapshot findOne(Long id);
}
Code:
Caused by: java.lang.OutOfMemoryError: Java heap space
at com.mysql.jdbc.MysqlIO.nextRowFast(MysqlIO.java:2123)
at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1900)
at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:3401)
at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:483)
at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3096)
at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2266)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2687)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2719)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2318)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:56)
at org.hibernate.loader.Loader.getResultSet(Loader.java:2031)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1832)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1811)
at org.hibernate.loader.Loader.doQuery(Loader.java:899)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:311)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2111)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3917)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:460)
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:429)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:206)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:262)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:150)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1091)
at org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:174)
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2473)
at org.hibernate.internal.SessionImpl.get(SessionImpl.java:987)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:807)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:781)