强制加载其他惰性加载属性 [英] Force eager loading of otherwise lazy loaded properties
本文介绍了强制加载其他惰性加载属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Hibernate对象,它的属性都是懒加载的。大部分属性都是其他Hibernate对象或PersistentSets。
I've got a Hibernate object which's properties are all loaded lazy. Most of these properties are other Hibernate objects or PersistentSets.
现在我想迫使Hibernate急于加载这些属性一次。
Now I want to force Hibernate to eager load these properties for just one time.
当然,我可以用 object.getSite()。size()
来触碰每个属性,但也许还有另一种方法来实现我的目标。
Of course I could "touch" each of these properties with object.getSite().size()
but maybe there's another way to achieve my goal.
推荐答案
文档如下所示:
The documentation puts it like this:
您可以在HQL中使用
获取所有
来强制通常预先获取
属性
的属性。
You can force the usual eager fetching of properties using
fetch all properties
in HQL.
引用
- Hibernate核心参考指南
- 19.1.7。使用lazy属性抓取
- Hibernate Core Reference Guide
- 19.1.7. Using lazy property fetching
这篇关于强制加载其他惰性加载属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
References
查看全文