No one knows about this ? It's a big issue, especially if I try to return a list of entities rather than just one. In this case the second select is executed for every entity, leading to hundreds of selects instead of one !
On 29 avr, 13:54, graphicsxp <graphic...@googlemail.com> wrote: > Hi, > > I have 3 tables : > > [Post] and [Region] are in sqlserver database called Media. > [User] is in sqlserver database called Admin. > > Region and User both have foreign keys to Post. So when I get a Post > record I'm expecting NH to join on Region and Post when I do eager- > fetching : > > return SessionManager.GetCurrentSession() > .CreateCriteria(typeof (Post)).Add(Restrictions.Eq > ("Id", pId)) > .SetFetchMode("theRegion", FetchMode.Eager) > .SetFetchMode("theUser", FetchMode.Eager).UniqueResult > () as Source; > > Here's the sql generated (reformated for better readability) : > > SELECT PostID > FROM Media.dbo.Post P > left outer join Media.dbo.Region R on R.RegionID = P.RegionID > WHERE P.PostId = 1 > > SELECT UserID > FROM Admin.dbo.User > WHERE UserId = 549 > > Why is there 2 SQL statements ? I was expecting NH to join on > Admin.dbo.User as well. Is there a way to change that as it's not > very efficient ! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---