|
From: <ric...@us...> - 2009-08-28 11:53:04
|
Revision: 4702
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4702&view=rev
Author: ricbrown
Date: 2009-08-28 11:52:50 +0000 (Fri, 28 Aug 2009)
Log Message:
-----------
Merge r4701 (Fix NH-1905)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905/Model.cs
Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-08-28 11:52:04 UTC (rev 4701)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-08-28 11:52:50 UTC (rev 4702)
@@ -496,7 +496,13 @@
//
///////////////////////////////////////////////////////////////////////////////
- if ( elem == null )
+ bool found = elem != null;
+ // even though we might find a pre-existing element by join path, for FromElements originating in a from-clause
+ // we should only ever use the found element if the aliases match (null != null here). Implied joins are
+ // always (?) ok to reuse.
+ bool useFoundFromElement = found && ( elem.IsImplied || ( AreSame(classAlias, elem.ClassAlias ) ) );
+
+ if ( ! useFoundFromElement )
{
// If this is an implied join in a from element, then use the impled join type which is part of the
// tree parser's state (set by the gramamar actions).
@@ -531,6 +537,11 @@
FromElement = elem; // This 'dot' expression now refers to the resulting from element.
}
+ private bool AreSame(String alias1, String alias2) {
+ // again, null != null here
+ return !StringHelper.IsEmpty( alias1 ) && !StringHelper.IsEmpty( alias2 ) && alias1.Equals( alias2 );
+ }
+
private void SetImpliedJoin(FromElement elem)
{
_impliedJoin = elem;
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905
___________________________________________________________________
Added: bugtraq:url
+ http://jira.nhibernate.org/browse/%BUGID%
Added: bugtraq:logregex
+ NH-\d+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905/Fixture.cs 2009-08-28 11:52:50 UTC (rev 4702)
@@ -0,0 +1,22 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using NHibernate.Cfg;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1905
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ [Test]
+ public void Query()
+ {
+ using (ISession s = OpenSession())
+ {
+ s.CreateQuery("select d from Det d left join d.Mas m where (SELECT count(e) FROM d.Mas.Els e WHERE e.Descr='e1')>0")
+ .List();
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905/Mappings.hbm.xml 2009-08-28 11:52:50 UTC (rev 4702)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1905">
+
+
+ <class name="Mas" table="mas" >
+ <id name="Id" type="Int32" >
+ <generator class="assigned" />
+ </id>
+ <set name="Els" table="MasEls" >
+ <key column="IdMas" />
+ <many-to-many column="IdEls" class="El"/>
+ </set>
+ </class>
+
+ <class name="Det" table="det" >
+ <id name="Id" type="Int32" >
+ <generator class="assigned" />
+ </id>
+ <many-to-one class="Mas" name="Mas" column="IdMas" />
+ </class>
+
+ <class name="El" table="Els" >
+ <id name="Id" type="Int32" >
+ <generator class="assigned" />
+ </id>
+ <property name="Descr" type="String" />
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905/Model.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1905/Model.cs 2009-08-28 11:52:50 UTC (rev 4702)
@@ -0,0 +1,60 @@
+using Iesi.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH1905
+{
+ public class Mas
+ {
+ private int _Id;
+
+ public virtual int Id
+ {
+ get { return _Id; }
+ set { _Id = value; }
+ }
+
+ private ISet<El> _Els;
+
+ public virtual ISet<El> Els
+ {
+ get { return _Els; }
+ set { _Els = value; }
+ }
+ }
+
+
+ public class Det
+ {
+ private int _Id;
+ private Mas _Mas;
+
+ public virtual int Id
+ {
+ get { return _Id; }
+ set { _Id = value; }
+ }
+
+ public virtual Mas Mas
+ {
+ get { return _Mas; }
+ set { _Mas = value; }
+ }
+ }
+
+ public class El
+ {
+ private int _Id;
+ private string _Descr;
+
+ public virtual int Id
+ {
+ get { return _Id; }
+ set { _Id = value; }
+ }
+
+ public virtual string Descr
+ {
+ get { return _Descr; }
+ set { _Descr = value; }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-28 11:52:04 UTC (rev 4701)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-28 11:52:50 UTC (rev 4702)
@@ -575,6 +575,8 @@
<Compile Include="NHSpecificTest\NH1899\SampleTest.cs" />
<Compile Include="NHSpecificTest\NH1904\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1904\Model.cs" />
+ <Compile Include="NHSpecificTest\NH1905\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1905\Model.cs" />
<Compile Include="NHSpecificTest\NH1907\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1907\MyType.cs" />
<Compile Include="NHSpecificTest\NH1908\Fixture.cs" />
@@ -2000,6 +2002,7 @@
<EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" />
<EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1905\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1939\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1911\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1920\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|