简体   繁体   English

Hibernate的findByCriteria会导致Java堆内存问题吗?

[英]Will Hibernate findByCriteria cause Java heap memory issue?

I have little knowledge about Hibernate. 我对Hibernate知之甚少。 I am calling findByCriteria(DetachedCriteria criteria) method, but I noticed that it returns a List. 我在调用findByCriteria(DetachedCriteria条件)方法,但是我注意到它返回一个List。 My worry is if it will cause Java heap memory issue when the database returns very large result. 我担心的是,当数据库返回非常大的结果时,是否会导致Java堆内存问题。 In my next code, I am looping through this returned list and do something on reach record. 在我的下一个代码中,我遍历此返回的列表并在到达记录上做一些事情。 I noticed that findByCriteria(DetachedCriteria criteria) is internally calling findByCriteria(criteria, -1, -1). 我注意到findByCriteria(DetachedCriteria条件)在内部调用findByCriteria(criteria,-1,-1)。 Could someone enlighten me? 有人可以启发我吗?

That is why human created something for the pagination. 这就是为什么人类为分页创造了一些东西的原因。 Check this and this 检查这个这个

Apart from pagination , limiting what results you are displaying will avoid lot of data from getting into the java heap space. 除了分页之外,限制显示的结果将避免大量数据进入Java堆空间。 From my personal experience I was able to remove the issues with the memory by limiting the fields that I am displaying. 根据我的个人经验,我可以通过限制要显示的字段来消除内存问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM