For now I just specified batch-size property on lazy load collection to
avoid SELECT N + 1. However this is no optimal as NHProf yields a warning
'Unbounded result set'. I don't know if you have any hints for my previous
question but I would greatly appreciate your help.

 

Thanks,

 

Thomas

 

De : [email protected] [mailto:[email protected]] De la part
de Thomas JASKULA
Envoyé : lundi 9 mai 2011 17:10
À : [email protected]
Objet : [nhusers] DistinctRootEntityTransformer and SetMaxResults or SELECT
N + 1

 

Hello group,

 

I have a little problem with eager loading of child collection and getting a
correct result.

 

Let's say I have a simple entities:

 

public class Post

{

                int Id {get; set;}

                Vote Votes {get; set;}

}

 

public class Vote

{

                int Id {get; set;}

}

 

At the beginning I had a Votes collection lazy loaded and it worked well
except of the SELECT N+1 statements.

 

I then tried to eagerly fetch vote collection which worked well but in order
to eliminate duplicates from the database (if one Post have 3 Votes, we will
have 3 rows in the resulting SQL query) I used DistinctRootEntityTransformer
which also worked well except with SetMaxResults. Because the SetMaxResults
limits the results on the database side we will have less results then
expected on the object side after applying DistinctRootEntityTransformer.

 

I looked through blog posts, StackOverflow questions, tried many things like
Fetch, LeftOuterJoins, Subqueries, detached criteria but didn't find any
solution for my issue. The issue is also described here
http://www.interworks.com/blogs/banderton/2009/06/26/nhibernate-eager-loadin
g-collections-rootentityresulttransformer-and-setm.

 

For now I see two solutions, get incorrect result number with setMaxResults
or keep SELECT N + 1

 

Is there any solution to solve it ?

 

Thanks in advance,

 

Thomas

-- 
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to