Sorry, the gist of this problem is here:
var query = session.CreateSQLQuery(@"SELECT {person.*},
{address.*} FROM People {person} LEFT OUTER JOIN
Address {address} on {address}.Id = {person}.Id
WHERE {person}.Id = 1");
query.AddEntity("person", "LazyLoadSql.Models.Person");
query.AddJoin("address", "person.Address");
var person = query.UniqueResult<Person>();
If an address if found for the person, great! If not, N+1 :(
If there anything I can do about this?
On Mon, Jul 27, 2009 at 12:41 AM, Len Smith <[email protected]> wrote:
> So, when I use custom SQL and I join to an entity say "Address"... if no
> Address is found NHibernate is going and making a second sql call for the
> Address, and hence I'm ending up with an N+1 SELECT problem.
>
> An example of this problem is here;
>
> http://bit.ly/4boQqN
>
> But I can summarize:
>
>
>
> It really sucks to break into custom sql for performance only to have an
> N+1 SELECT problem :(
>
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---