I've a situation similar to the following:
Blog - one to many - Posts - lazy
Post - one to many - Comments - not lazy (right now)
I've a page that needs to scan through all the comments for the blog, but it needs to do it through the Blog object.
The issue is that I've got two SQL Statements for the blog & the posts, and then a sql query per each post, for all the comments.
The code I've right now does something like:
Code:
foreach(Post post in blog.Posts)
{
//Do processing on the post
foreach(Comment comment in post.Comments)
{
// do processing on the comment
}
}
P.S:
There is no connection between the comment & the blog, so I can't use HQL directly to do that (I think).
P.S.S:
I may need to take it another level or two down, (and here the blog analogy breaks), so it's important to find a way to do it.
P.S.S:
I _think_ that I can write a manual query that loads all the comments when I have all the posts, but that would require a big assed IN(), and I understand that this is not performant.
Thanks in advance,
Ayende Rahien