如何更改hibernate的默认抓取策略?
我知道hibernate的默认获取策略对于集合来说是LAZY,有没有办法通过配置文件更改系统范围内的默认获取策略?
I know hibernate's default fetching strategy is LAZY for collections, is there a way to change the default fetching strategy system wide through configuration file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道有什么好的答案可以满足您的需求,抱歉。 :-(
但我可以挑战你的要求吗?;-)
如果你启用集合的早期获取(即 XToMany,或父子关系),很可能它也足以启用另一边 (XToOne),这更有可能是需要的。
我们推断甚至您的实体最简单的请求将加载整个数据库!
这就是为什么我认为这“不太可能是一个好主意”。
I don't know any good answer for your need, sorry. :-(
But may I dare challenging your requirement? ;-)
If you enable early fetching for collections (ie. XToMany, or parent to child relationship), it is probable that it is also adequate to enable the other side (XToOne), that is much more likely needed.
Considering that often, your entities are not fully partitionned, that is "there is a chain of entities allowing to go from any entity to any other entity"...
We deduce that even your simplest request will load the entire database !
This is the reason why I think it is "unlikely a good idea".