我们如何减少不必要的对象加载? [英] How can we reduce the unnecessary loading of objects?
问题描述
由于这个我的应用程序运行缓慢..
有几种方法可以实现这一点:
-
启用缓存。虽然SQL不会改变,但Hibernate会比较数据库的结果并重用现有的对象。这不会大大提升,但实现和维护起来很简单。
创建第二个映射(相同的表,不同的对象)只加载一个子集。 -
将很少使用的数据移动到第二个表中。
使用自定义原生SQL查询加载对象。在这里,你必须确保你知道已经装载了多少以及如何填补空白。
In hibernate as well as simple ORM strategy,i am normally loading all the values for the objects.Is there any way to avoid this. Due to this my app running slowly..
There are several ways to achieve this:
Enable caching. While the SQL won't change, Hibernate will compare the results from the database and reuse existing objects. This doesn't give an enormous boost but it's simple to implement and maintain.
Create a second mapping (same tables, different object) to load just a subset of the values.
Move the rarely used data into a second table.
Load your objects with a custom native SQL query. Here, you must make sure that you know how much has been loaded and how to "fill the gaps".
这篇关于我们如何减少不必要的对象加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!