|
From: <fab...@us...> - 2009-04-24 06:40:22
|
Revision: 4210
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4210&view=rev
Author: fabiomaulo
Date: 2009-04-24 06:40:17 +0000 (Fri, 24 Apr 2009)
Log Message:
-----------
Fix NH-1742 by Richard Brown
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/DomainClass.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2009-04-24 06:17:30 UTC (rev 4209)
+++ trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2009-04-24 06:40:17 UTC (rev 4210)
@@ -713,7 +713,7 @@
{
for (int index = 0; index < namedParameterLocations.Count; index++)
{
- if (namedParameterLocations[index] == existingParameterLocation)
+ if (namedParameterLocations[index] >= existingParameterLocation)
namedParameterLocations[index]++;
}
}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/DomainClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/DomainClass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/DomainClass.cs 2009-04-24 06:40:17 UTC (rev 4210)
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH1742
+{
+ public class Event
+ {
+ private readonly IList<Description> descriptions = new List<Description>();
+
+ public virtual IList<Description> Descriptions
+ {
+ get { return descriptions; }
+ }
+
+ public virtual int ID { get; set; }
+ public virtual Device SendedBy { get; set; }
+ public virtual DateTime Date { get; set; }
+ }
+
+ public class Device
+ {
+ public virtual int ID { get; set; }
+ }
+
+ public class Description
+ {
+ public virtual Event Event { get; set; }
+ public virtual int ID { get; set; }
+ public virtual string LanguageID { get; set; }
+ public virtual string Value { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Fixture.cs 2009-04-24 06:40:17 UTC (rev 4210)
@@ -0,0 +1,79 @@
+using System;
+using System.Collections.Generic;
+using NHibernate.Dialect;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1742
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ private ISession session;
+ private ITransaction transaction;
+ private Device device;
+ private DateTime date = new DateTime(2000, 1, 1);
+
+ protected override void OnSetUp()
+ {
+ base.OnSetUp();
+
+ session = OpenSession();
+ transaction = session.BeginTransaction();
+
+ device = new Device();
+ session.Save(device);
+
+ var ev = new Event {Date = date, SendedBy = device};
+ session.Save(ev);
+
+ var d = new Description {Event = ev, Value = "Test", LanguageID = "it"};
+ session.Save(d);
+
+ IFilter f = session.EnableFilter("LanguageFilter").SetParameter("LanguageID", "it");
+
+ f.Validate();
+ }
+
+ protected override void OnTearDown()
+ {
+ transaction.Rollback();
+ session.Close();
+
+ base.OnTearDown();
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect as MsSql2000Dialect != null;
+ }
+
+ [Test]
+ public void BugTest()
+ {
+ IQuery query =
+ session.CreateQuery("SELECT e FROM Event e " + " inner join fetch e.descriptions d "
+ + " WHERE (e.SendedBy in( :dev)) " + " AND (e.Date >= :from) " + " AND (e.Date <= :to)"
+ + " ORDER BY d.Value");
+
+ var devices = new List<Device> {device};
+
+ query.SetParameterList("dev", devices).SetDateTime("from", date).SetDateTime("to", date.AddMonths(1));
+
+ Assert.AreEqual(1, query.List<Event>().Count);
+ }
+
+ [Test]
+ public void WorkingTest()
+ {
+ IQuery query =
+ session.CreateQuery("SELECT e FROM Event e " + " inner join fetch e.descriptions d " + " WHERE (e.Date >= :from) "
+ + " AND (e.Date <= :to)" + " AND (e.SendedBy in( :dev)) " + " ORDER BY d.Value");
+
+ var devices = new List<Device> {device};
+
+ query.SetParameterList("dev", devices).SetDateTime("from", date).SetDateTime("to", date.AddMonths(1));
+
+ Assert.AreEqual(1, query.List<Event>().Count);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1742/Mappings.hbm.xml 2009-04-24 06:40:17 UTC (rev 4210)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1742"
+ default-lazy="false">
+
+ <class name="Event" table="tblEventi" >
+ <id name="ID" column="ID">
+ <generator class="identity" />
+ </id>
+ <many-to-one name="SendedBy" column="IDStrumento" class="Device"
+ access="property" />
+ <property name="Date" column="Data"/>
+ <bag name="descriptions" lazy="false" access="field" inverse="true" cascade="none" >
+ <key column="IDEvento" />
+ <one-to-many class="Description" />
+ <filter name="LanguageFilter" condition=":LanguageID = IDLingua"/>
+ </bag>
+ </class>
+
+ <class name="Device" table="tblStrumenti">
+ <id name="ID" column="ID" type="Int32" unsaved-value="0">
+ <generator class="identity" />
+ </id>
+ </class>
+
+ <class name="Description" table="tblDescrizioni">
+ <id name="ID" column="ID">
+ <generator class="identity" />
+ </id>
+ <many-to-one name="Event" column="IDEvento" class="Event"
+ access="property" />
+ <property name="Value" column="Descrizione"/>
+ <property name="LanguageID" column="IDLingua"/>
+ <filter name="LanguageFilter" condition=":LanguageID = IDLingua"/>
+ </class>
+
+ <filter-def name="LanguageFilter">
+ <filter-param name="LanguageID" type="String"/>
+ </filter-def>
+
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-04-24 06:17:30 UTC (rev 4209)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-04-24 06:40:17 UTC (rev 4210)
@@ -326,6 +326,8 @@
<Compile Include="NHSpecificTest\NH1716\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1741\Domain.cs" />
<Compile Include="NHSpecificTest\NH1741\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1742\DomainClass.cs" />
+ <Compile Include="NHSpecificTest\NH1742\Fixture.cs" />
<Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" />
<Compile Include="HQL\HQLFunctions.cs" />
<Compile Include="HQL\Human.cs" />
@@ -1719,6 +1721,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1742\Mappings.hbm.xml" />
<EmbeddedResource Include="HQL\Ast\SimpleClass.hbm.xml" />
<EmbeddedResource Include="HQL\Ast\TestQueries.xml" />
<EmbeddedResource Include="HQL\Ast\TestQueriesWithResults.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|