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
- Fetch the Mixes page you want, without any Tracks or Tags.
- 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.
精彩评论