您如何以编程方式关闭休眠时的急切获取? [英] How do you programmatically turn off eager fetching with hibernate?

查看:22
本文介绍了您如何以编程方式关闭休眠时的急切获取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的映射中,我有一个关联到一个急切加载的集合 (lazy="false" fetch="subselect").当我进行查询时,如何使用 Hibernate 以编程方式将其关闭?

I have in my mapping an association to an eagerly loaded collection (lazy="false" fetch="subselect"). How can I turn that off programmatically with Hibernate when I do a query?

推荐答案

其实应该是反过来的.您在映射中将其关闭,并在特定用例中通过查询中的获取"激活它.

In fact, it is supposed to be the other way around. You turn it off in the mapping, and activate it on specific use cases with a "fetch" in the query.

这就是 Hibernate 团队的看法.在 Hibernate 中无法创建为属性指定no-fetch"的请求...

That's the way the Hibernate team sees it. There is no way in Hibernate to create a request that specifies "no-fetch" for a property...

这篇关于您如何以编程方式关闭休眠时的急切获取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆