From: Roy J. (JIRA) <nh...@gm...> - 2011-05-13 13:28:11
|
[ http://216.121.112.228/browse/NH-2703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21071#action_21071 ] Roy Jacobs commented on NH-2703: -------------------------------- I did some more research: The problem is that "JoinWalker.WalkEntityAssociationTree" is adding joins in the order in which the associations are added in the mapping. So in my above test-case, if I place the "OtherChildren" association above "Children" in the mapping for the "Parent" class, the test succeeds. Is this by design, or should this still be fixed? > Using a "with" restriction in outer joins result in wrong SQL > ------------------------------------------------------------- > > Key: NH-2703 > URL: http://216.121.112.228/browse/NH-2703 > Project: NHibernate > Issue Type: Bug > Components: QueryOver > Affects Versions: 3.2.0Beta1 > Reporter: Roy Jacobs > Priority: Major > Attachments: JoinTest.zip > > > I have a Parent class that has two types of children: "Child" in a list called "Children" and "Other" in a list called "OtherChildren". > If I do a QueryOver on Parent, and outer join both Child and Other tables then everything works. > If I add a "With" on the "Child" join, linking it to "Other" (e.g. child.MyProp == other.OtherProp) then the SQL that is generated does not work in SQL Server 2008: > SELECT child2_.MyProp as y0_ > FROM Parent this_ > left outer join Child child2_ on this_.Id=child2_.parent_id and ( child2_.MyProp = other1_.OtherProp ) > left outer join Other other1_ on this_.Id=other1_.parent_id > The error message is: > System.Data.SqlClient.SqlException : The multi-part identifier "other1_.OtherProp" could not be bound. > This is because SQL Server expects "other1_" to be joined *BEFORE* "child2_". If I manually change the join order around in the SQL, it works. > Reshuffling the order in which I perform the joins in C# does not help, the emitted SQL is always incorrect. > I have attached a failing test that can be added to NHibernate.Test which demonstrates this problem. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |