NHibernate 预加载集合 +寻呼

发布于 2024-09-08 15:10:39 字数 227 浏览 2 评论 0原文

这是我尝试使用急切加载的集合返回的实体的示例。

混合 ->曲目(集合) ->标签(集合)

我需要返回带有急切加载的曲目的混音分页列表标签,无需分页,通过使用 Future<>() 函数对曲目 + 标签运行多个查询相对简单。

因为这些数据需要分页...我怎样才能取回所有数据,以便 NHibernate 在显示我的数据时不会遇到 N+1 问题。

保罗

Here is an example of my entities that I am trying to return with eager loaded collections.

Mixes
-> Tracks (collection)
-> Tags (collection)

I need to return a paged list of Mixes with eager loaded tracks & tags, without paging it is relativly simple by using the Future<>() function to run multiple queries for the tracks + tags.

Because this data needs to be paged...how can I get all my data back so that NHibernate won't get the N+1 issue when displaying my data.

Paul

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

删除→记忆 2024-09-15 15:10:39
  1. 获取您想要的混音页面,任何曲目或标签。
  2. 获取与您在上述步骤中获取的所有混音相对应的所有曲目(左连接标签)(即,如果您使用 HQL,请使用 SetParameterList 传递所有 Mixes ID)

总计:2 个查询。

  1. Fetch the Mixes page you want, without any Tracks or Tags.
  2. Fetch all the Tracks (left join Tags) that correspond to the all the Mixes you fetched in the step above (i.e. if you're using HQL, use SetParameterList to pass all the Mixes IDs)

Total: 2 queries.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文