From: <ric...@us...> - 2009-08-10 15:41:14
|
Revision: 4688 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4688&view=rev Author: ricbrown Date: 2009-08-10 15:41:06 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Merge r4687 (Fix NH-1914) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/ForeignKeys.cs trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.cs trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.hbm.xml trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Model.cs Modified: trunk/nhibernate/src/NHibernate/Engine/ForeignKeys.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/ForeignKeys.cs 2009-08-10 15:31:22 UTC (rev 4687) +++ trunk/nhibernate/src/NHibernate/Engine/ForeignKeys.cs 2009-08-10 15:41:06 UTC (rev 4688) @@ -1,3 +1,5 @@ +using log4net; +using NHibernate.Id; using NHibernate.Persister.Entity; using NHibernate.Proxy; using NHibernate.Type; @@ -7,6 +9,8 @@ /// <summary> Algorithms related to foreign key constraint transparency </summary> public static class ForeignKeys { + private static readonly ILog log = LogManager.GetLogger(typeof(ForeignKeys)); + public class Nullifier { private readonly bool isDelete; @@ -195,6 +199,17 @@ if (assumed.HasValue) return assumed.Value; + if (persister.IdentifierGenerator is Assigned) + { + // When using assigned identifiers we cannot tell if an entity + // is transient or detached without querying the database. + // This could potentially cause Select N+1 in cascaded saves, so warn the user. + log.Warn("Unable to determine if " + entity.ToString() + + " with assigned identifier " + persister.GetIdentifier(entity, session.EntityMode) + + " is transient or detached; querying the database." + + " Use explicit Save() or Update() in session to prevent this."); + } + // hit the database, after checking the session cache for a snapshot System.Object[] snapshot = session.PersistenceContext.GetDatabaseSnapshot(persister.GetIdentifier(entity, session.EntityMode), persister); Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-08-10 15:31:22 UTC (rev 4687) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-08-10 15:41:06 UTC (rev 4688) @@ -3630,7 +3630,19 @@ // check the id unsaved-value bool? result2 = entityMetamodel.IdentifierProperty.UnsavedValue.IsUnsaved(id); if (result2.HasValue) - return result2; + { + if (IdentifierGenerator is Assigned) + { + // if using assigned identifier, we can only make assumptions + // if the value is a known unsaved-value + if (result2.Value) + return true; + } + else + { + return result2; + } + } // check to see if it is in the second-level cache if (HasCache) Added: trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.cs 2009-08-10 15:41:06 UTC (rev 4688) @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.IdTest +{ + public class Parent + { + public string Id { get; set; } + public string Name { get; set; } + public IList<Child> Children { get; set; } + } + + public class Child + { + public string Id { get; set; } + public Parent Parent { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedClass.hbm.xml 2009-08-10 15:41:06 UTC (rev 4688) @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false"> + + <class name="NHibernate.Test.IdTest.Parent, NHibernate.Test"> + <id name="Id"> + <generator class="assigned" /> + </id> + + <property name="Name" /> + + <bag name="Children" inverse="true" cascade="all"> + <key column="Parent"/> + <one-to-many class="NHibernate.Test.IdTest.Child, NHibernate.Test"/> + </bag> + </class> + + <class name="NHibernate.Test.IdTest.Child, NHibernate.Test"> + <id name="Id"> + <generator class="assigned" /> + </id> + + <many-to-one name="Parent" class="NHibernate.Test.IdTest.Parent, NHibernate.Test" /> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/IdTest/AssignedFixture.cs 2009-08-10 15:41:06 UTC (rev 4688) @@ -0,0 +1,255 @@ +using System; +using System.Collections.Generic; +using log4net; +using log4net.Core; +using NUnit.Framework; + +namespace NHibernate.Test.IdTest +{ + + [TestFixture] + public class AssignedFixture : IdFixtureBase + { + + private string[] GetAssignedIdentifierWarnings(LogSpy ls) + { + List<string> warnings = new List<string>(); + + foreach (string logEntry in ls.GetWholeLog().Split('\n')) + if (logEntry.Contains("Unable to determine if") && logEntry.Contains("is transient or detached")) + warnings.Add(logEntry); + + return warnings.ToArray(); + } + + protected override string TypeName + { + get { return "Assigned"; } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.CreateQuery("delete from Child").ExecuteUpdate(); + s.CreateQuery("delete from Parent").ExecuteUpdate(); + t.Commit(); + } + } + + [Test] + public void SaveOrUpdate_Save() + { + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Children = new List<Child>(), + }; + + s.SaveOrUpdate(parent); + t.Commit(); + + long actual = s.CreateQuery("select count(p) from Parent p").UniqueResult<long>(); + Assert.That(actual, Is.EqualTo(1)); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(1)); + Assert.IsTrue(warnings[0].Contains("parent")); + } + } + + [Test] + public void SaveNoWarning() + { + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Children = new List<Child>(), + }; + + s.Save(parent); + t.Commit(); + + long actual = s.CreateQuery("select count(p) from Parent p").UniqueResult<long>(); + Assert.That(actual, Is.EqualTo(1)); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(0)); + } + } + + [Test] + public void SaveOrUpdate_Update() + { + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + s.Save(new Parent() { Id = "parent", Name = "before" }); + t.Commit(); + } + + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Name = "after", + }; + + s.SaveOrUpdate(parent); + t.Commit(); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(1)); + Assert.IsTrue(warnings[0].Contains("parent")); + } + + using (ISession s = OpenSession()) + { + Parent parent = s.CreateQuery("from Parent").UniqueResult<Parent>(); + Assert.That(parent.Name, Is.EqualTo("after")); + } + } + + [Test] + public void UpdateNoWarning() + { + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + s.Save(new Parent() { Id = "parent", Name = "before" }); + t.Commit(); + } + + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Name = "after", + }; + + s.Update(parent); + t.Commit(); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(0)); + } + + using (ISession s = OpenSession()) + { + Parent parent = s.CreateQuery("from Parent").UniqueResult<Parent>(); + Assert.That(parent.Name, Is.EqualTo("after")); + } + } + + [Test] + public void InsertCascade() + { + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + s.Save(new Child() { Id = "detachedChild" }); + t.Commit(); + } + + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Children = new List<Child>(), + }; + + parent.Children.Add(new Child() { Id = "detachedChild", Parent = parent }); + parent.Children.Add(new Child() { Id = "transientChild", Parent = parent }); + + s.Save(parent); + t.Commit(); + + long actual = s.CreateQuery("select count(c) from Child c").UniqueResult<long>(); + Assert.That(actual, Is.EqualTo(2)); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(2)); + Assert.IsTrue(warnings[0].Contains("detachedChild")); + Assert.IsTrue(warnings[1].Contains("transientChild")); + } + } + + [Test] + public void InsertCascadeNoWarning() + { + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + s.Save(new Child() { Id = "persistedChild" }); + t.Commit(); + } + + using (LogSpy ls = new LogSpy(LogManager.GetLogger("NHibernate"), Level.Warn)) + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + + Parent parent = + new Parent() + { + Id = "parent", + Children = new List<Child>(), + }; + + s.Save(parent); + + Child child1 = s.Load<Child>("persistedChild"); + child1.Parent = parent; + parent.Children.Add(child1); + + Child child2 = new Child() { Id = "transientChild", Parent = parent }; + s.Save(child2); + parent.Children.Add(child2); + + t.Commit(); + + long actual = s.CreateQuery("select count(c) from Child c").UniqueResult<long>(); + Assert.That(actual, Is.EqualTo(2)); + + string[] warnings = GetAssignedIdentifierWarnings(ls); + Assert.That(warnings.Length, Is.EqualTo(0)); + } + } + + } + +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Fixture.cs 2009-08-10 15:41:06 UTC (rev 4688) @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1914 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + [Test] + public void CascadeInsertAssigned() + { + IDS _IDS = new IDS(); + _IDS.Identifier = Guid.NewGuid().ToString(); + _IDS.Name = "IDS"; + _IDS.CRSPLUTs = new Dictionary<String, ListOfHLUT>(); + _IDS.CRSPLUTs.Add("a", new ListOfHLUT()); + + + HLUT _HLUT = new HLUT(); + _HLUT.Identifier = 1123; + _HLUT.Name = "HLUT"; + _HLUT.Entries = new List<Entry>(); + _HLUT.Entries.Add(new Entry(1.1, .1)); + _HLUT.Entries.Add(new Entry(2.2, .2)); + + _IDS.CRSPLUTs["a"].Values.Add(_HLUT); + + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + s.Save(_IDS); + t.Commit(); + } + + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + IDS _IDSRead = s.Load<IDS>(_IDS.Identifier); + + Assert.IsNotNull(_IDSRead); + Assert.IsNotNull(_IDSRead.CRSPLUTs); + Assert.IsNotNull(_IDSRead.CRSPLUTs["a"]); + Assert.IsNotNull(_IDSRead.CRSPLUTs["a"].Values[0]); + Assert.IsNotNull(_IDSRead.CRSPLUTs["a"].Values[0].Entries); + + s.Delete(_IDSRead); + t.Commit(); + } + } + + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Mappings.hbm.xml 2009-08-10 15:41:06 UTC (rev 4688) @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1914" + default-lazy="false"> + + <class name="IDS" table="IDS"> + <id name="Identifier"> + <generator class="assigned" /> + </id> + <property name="Name" not-null="true" /> + <map name="CRSPLUTs" table="CRSPLUTs" cascade="all-delete-orphan"> + <key column="ParentID"/> + <index column="OrganID" type="String"/> + <one-to-many class="ListOfHLUT"/> + </map> + </class> + + <class name="ListOfHLUT" table="ListOfHLUT"> + <id name="ID" column="CollectionID"> + <generator class="native" /> + </id> + <list name="Values" table="CustomValues" cascade="all"> + <key column="ParentID"/> + <index column="Indexer" type="Int32"/> + <one-to-many class="HLUT"/> + </list> + </class> + + <class name="HLUT" table="HLUT"> + + <!--NotWorking with below id generation.--> + <id name="Identifier" unsaved-value="0"> + <generator class="assigned" /> + </id> + + <!--Working with below id generation.--> + <!-- + <id name="Identifier" unsaved-value="any"> + <generator class="native" /> + </id>--> + + <property name="Name" not-null="true" /> + <list name="Entries" table="Entries" cascade="all"> + <key column="ParentID"/> + <index column="Indexer" type="Int32"/> + <composite-element class="Entry"> + <property name="Key1" type="Double" access="field" /> + <property name="Value" type="Double" access="field"/> + </composite-element> + </list> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1914/Model.cs 2009-08-10 15:41:06 UTC (rev 4688) @@ -0,0 +1,269 @@ +using System; +using System.Xml.Serialization; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +using NHibernate; +using NHibernate.Classic; + +namespace NHibernate.Test.NHSpecificTest.NH1914 +{ + public class IDS + { + public String Identifier { get; set; } + + public String Name { get; set; } + + public IDictionary<String,ListOfHLUT> CRSPLUTs { get; set; } + } + + public class ListOfHLUT : CustomList<HLUT> + { + public ListOfHLUT() : base() { } + public ListOfHLUT(IEnumerable<HLUT> theValues) : base(theValues) { } + } + + public class HLUT : LUT + { + public String Name { get; set; } + } + + public class LUT + { + public long Identifier { get; set; } + + public IList<Entry> Entries { get; set; } + } + + public struct Entry + { + public Entry(Double theKey, Double theValue) + { + Key1 = theKey; + Value = theValue; + } + + public Double Key1; + + public Double Value; + } + + public class CustomList<T> : IList<T>, IList, ILifecycle + { + #region Constructors + + public CustomList() + { + myValues = new List<T>(); + } + + public CustomList(IEnumerable<T> theValues) + { + myValues = new List<T>(theValues); + } + #endregion + + #region Member Variables + protected IList<T> myValues; + #endregion + + #region NHibernate Members + [XmlIgnore] + public virtual String Identifier { get; set; } + + [XmlIgnore] + public virtual long ID { get; set; } + + [XmlIgnore] + public virtual IList<T> Values + { + get + { + return myValues; + } + set + { + myValues = value; + } + } + #endregion + + #region ILifecycle Members + + public LifecycleVeto OnDelete(ISession s) + { + return LifecycleVeto.NoVeto; + } + + public void OnLoad(ISession s, object id) + { + + } + + public LifecycleVeto OnSave(ISession s) + { + return LifecycleVeto.NoVeto; + } + + public LifecycleVeto OnUpdate(ISession s) + { + return LifecycleVeto.NoVeto; + } + + #endregion + + #region IList<T> Members + + public int IndexOf(T item) + { + return myValues.IndexOf(item); + } + + public void Insert(int index, T item) + { + myValues.Insert(index, item); + } + + public void RemoveAt(int index) + { + myValues.RemoveAt(index); + } + + public T this[int index] + { + get + { + return myValues[index]; + } + set + { + myValues[index] = value; + } + } + + #endregion + + #region ICollection<T> Members + + public void Add(T item) + { + myValues.Add(item); + } + + public void Clear() + { + myValues.Clear(); + } + + public bool Contains(T item) + { + return myValues.Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + myValues.CopyTo(array, arrayIndex); + } + + public int Count + { + get { return myValues.Count; } + } + + public bool IsReadOnly + { + get { return myValues.IsReadOnly; } + } + + public bool Remove(T item) + { + return myValues.Remove(item); + } + + #endregion + + #region IEnumerable<T> Members + + public IEnumerator<T> GetEnumerator() + { + return myValues.GetEnumerator(); + } + + #endregion + + #region IEnumerable Members + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + + #region IList Members + + public int Add(object value) + { + return ((IList)myValues).Add(value); + } + + public bool Contains(object value) + { + return ((IList)myValues).Contains(value); + } + + public int IndexOf(object value) + { + return ((IList)myValues).IndexOf(value); + } + + public void Insert(int index, object value) + { + ((IList)myValues).Insert(index, value); + } + + public bool IsFixedSize + { + get { return ((IList)myValues).IsFixedSize; } + } + + public void Remove(object value) + { + ((IList)myValues).Remove(value); + } + + object IList.this[int index] + { + get + { + return ((IList)myValues)[index]; + } + set + { + ((IList)myValues)[index] = value; + } + } + + #endregion + + #region ICollection Members + + public void CopyTo(Array array, int index) + { + ((IList)myValues).CopyTo(array, index); + } + + public bool IsSynchronized + { + get { return ((IList)myValues).IsSynchronized; } + } + + public object SyncRoot + { + get { return ((IList)myValues).SyncRoot; } + } + + #endregion + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-10 15:31:22 UTC (rev 4687) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-10 15:41:06 UTC (rev 4688) @@ -355,6 +355,8 @@ <Compile Include="HQL\Ast\WithClauseFixture.cs" /> <Compile Include="HQL\Ast\Zoo.cs" /> <Compile Include="HQL\BaseFunctionFixture.cs" /> + <Compile Include="IdTest\AssignedClass.cs" /> + <Compile Include="IdTest\AssignedFixture.cs" /> <Compile Include="IdTest\TableGeneratorFixture.cs" /> <Compile Include="LazyOneToOne\Employee.cs" /> <Compile Include="LazyOneToOne\Employment.cs" /> @@ -562,6 +564,8 @@ <Compile Include="NHSpecificTest\NH1907\MyType.cs" /> <Compile Include="NHSpecificTest\NH1908\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1908\Model.cs" /> + <Compile Include="NHSpecificTest\NH1914\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1914\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1975,6 +1979,8 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="IdTest\AssignedClass.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1914\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1904\Mappings.hbm.xml" /> <EmbeddedResource Include="FilterTest\SimpleFiltered.hbm.xml" /> <EmbeddedResource Include="FilterTest\SimpleFilteredFiltersDefsOk.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-08-14 17:06:48
|
Revision: 4693 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4693&view=rev Author: ricbrown Date: 2009-08-14 17:06:41 +0000 (Fri, 14 Aug 2009) Log Message: ----------- Merge r4692 (Fix NH-1920) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Model.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-08-14 16:53:29 UTC (rev 4692) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-08-14 17:06:41 UTC (rev 4693) @@ -106,21 +106,6 @@ return dialect.ApplyLocksToSql(sql, aliasedLockModes, keyColumnNames); } - protected override int BindParameterValues(IDbCommand statement, QueryParameters queryParameters, int startIndex, - ISessionImplementor session) - { - int position = startIndex; - - IList<IParameterSpecification> parameterSpecs = _queryTranslator.CollectedParameterSpecifications; - - foreach (var spec in parameterSpecs) - { - position += spec.Bind(statement, queryParameters, session, position); - } - - return position - startIndex; - } - protected override string[] Aliases { get { return _sqlAliases; } Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920 ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Fixture.cs 2009-08-14 17:06:41 UTC (rev 4693) @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1920 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + [Test] + public void Can_Query_Without_Collection_Size_Condition() + { + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.SaveOrUpdate(new Customer() { IsDeleted = false }); + tx.Commit(); + } + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.EnableFilter("state").SetParameter("deleted", false); + var result = sess + .CreateQuery("from Customer c join c.Orders o where c.id > :cid") + .SetParameter("cid", 0) + .List(); + Assert.That(result.Count == 0); + tx.Commit(); + } + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.Delete("from System.Object"); + tx.Commit(); + } + } + + [Test] + public void Can_Query_With_Collection_Size_Condition() + { + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.SaveOrUpdate(new Customer() { IsDeleted = false }); + tx.Commit(); + } + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.EnableFilter("state").SetParameter("deleted", false); + var result = sess + .CreateQuery("from Customer c join c.Orders o where c.id > :cid and c.Orders.size > 0") + .SetParameter("cid", 0) + .List(); + Assert.That(result.Count == 0); + tx.Commit(); + } + using (ISession sess = OpenSession()) + using (ITransaction tx = sess.BeginTransaction()) + { + sess.Delete("from System.Object"); + tx.Commit(); + } + } + + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Mappings.hbm.xml 2009-08-14 17:06:41 UTC (rev 4693) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1920"> + + <class name="Customer" table="Customers"> + <id name="Id"> + <generator class="native" /> + </id> + <bag name="Orders"> + <key column="Customer_Id" /> + <one-to-many class="Order" /> + <filter name="state" condition=":deleted = IsDeleted" /> + </bag> + <property name="IsDeleted" not-null="true" /> + </class> + + <class name="Order" table="Orders"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="IsDeleted" not-null="true" /> + <property name="Memo" not-null="false" /> + <many-to-one name="Customer" class="Customer" column="Customer_Id" /> + <filter name="state" condition=":deleted = IsDeleted" /> + </class> + + <filter-def name="state" condition=":deleted = IsDeleted"> + <filter-param name="deleted" type="Boolean"/> + </filter-def> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1920/Model.cs 2009-08-14 17:06:41 UTC (rev 4693) @@ -0,0 +1,28 @@ +using System; +using System.Xml.Serialization; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +using NHibernate; +using NHibernate.Classic; + +namespace NHibernate.Test.NHSpecificTest.NH1920 +{ + + public class Customer + { + public virtual int Id { get; set; } + public virtual bool IsDeleted { get; set; } + public virtual IList<Order> Orders { get; set; } + } + + public class Order + { + public virtual int Id { get; set; } + public virtual bool IsDeleted { get; set; } + public virtual string Memo { get; set; } + public virtual Customer Customer { get; set; } + } + +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-14 16:53:29 UTC (rev 4692) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-14 17:06:41 UTC (rev 4693) @@ -581,6 +581,8 @@ <Compile Include="NHSpecificTest\NH1908\Model.cs" /> <Compile Include="NHSpecificTest\NH1914\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1914\Model.cs" /> + <Compile Include="NHSpecificTest\NH1920\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1920\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1994,6 +1996,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1920\Mappings.hbm.xml" /> <EmbeddedResource Include="Linq\Mappings\Customer.hbm.xml" /> <EmbeddedResource Include="Linq\Mappings\Employee.hbm.xml" /> <EmbeddedResource Include="Linq\Mappings\Order.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-08-17 20:50:44
|
Revision: 4695 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4695&view=rev Author: ricbrown Date: 2009-08-17 20:50:37 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Merge r4694 (Fix NH-1911) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/AggregateProjection.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Model.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/AggregateProjection.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/AggregateProjection.cs 2009-08-17 20:40:40 UTC (rev 4694) +++ trunk/nhibernate/src/NHibernate/Criterion/AggregateProjection.cs 2009-08-17 20:50:37 UTC (rev 4695) @@ -57,7 +57,7 @@ { aggregate, "(", StringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, loc, criteriaQuery, - enabledFilters)).ToString(), ") as y", + enabledFilters)), ") as y", loc.ToString(), "_" }); } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Fixture.cs 2009-08-17 20:50:37 UTC (rev 4695) @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; +using NHibernate.Criterion; + +namespace NHibernate.Test.NHSpecificTest.NH1911 +{ + + [TestFixture] + public class Fixture : BugTestCase + { + + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + s.Save(new LogEvent() { Name = "name parameter", Level = "Fatal" }); + s.Save(new LogEvent() { Name = "name parameter", Level = "NonFatal" }); + s.Save(new LogEvent() { Name = "name parameter", Level = "Fatal" }); + t.Commit(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + base.OnSetUp(); + using (ISession s = OpenSession()) + { + ITransaction t = s.BeginTransaction(); + s.CreateQuery("delete from System.Object").ExecuteUpdate(); + t.Commit(); + } + } + + [Test] + public void ConditionalAggregateProjection() + { + IProjection isError = + Projections.Conditional( + Expression.Eq("Level", "Fatal"), + Projections.Constant(1), + Projections.Constant(0)); + + using (ISession s = OpenSession()) + { + IList<object[]> actual = + s.CreateCriteria<LogEvent>() + .Add(Expression.Eq("Name", "name parameter")) + .SetProjection(Projections.ProjectionList() + .Add(Projections.RowCount()) + .Add(Projections.Sum(isError))) + .List<object[]>(); + + Assert.That(actual.Count, Is.EqualTo(1)); + Assert.That(actual[0][0], Is.EqualTo(3)); + Assert.That(actual[0][1], Is.EqualTo(2)); + } + } + + } + +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Mappings.hbm.xml 2009-08-17 20:50:37 UTC (rev 4695) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1911"> + + <class name="LogEvent"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + <property name="Level" /> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1911/Model.cs 2009-08-17 20:50:37 UTC (rev 4695) @@ -0,0 +1,20 @@ +using System; +using System.Xml.Serialization; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +using NHibernate; +using NHibernate.Classic; + +namespace NHibernate.Test.NHSpecificTest.NH1911 +{ + + public class LogEvent + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual string Level { get; set; } + } + +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-17 20:40:40 UTC (rev 4694) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-17 20:50:37 UTC (rev 4695) @@ -579,6 +579,8 @@ <Compile Include="NHSpecificTest\NH1907\MyType.cs" /> <Compile Include="NHSpecificTest\NH1908\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1908\Model.cs" /> + <Compile Include="NHSpecificTest\NH1911\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1911\Model.cs" /> <Compile Include="NHSpecificTest\NH1914\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1914\Model.cs" /> <Compile Include="NHSpecificTest\NH1920\Fixture.cs" /> @@ -1996,6 +1998,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1911\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1920\Mappings.hbm.xml" /> <EmbeddedResource Include="Linq\Mappings\Customer.hbm.xml" /> <EmbeddedResource Include="Linq\Mappings\Employee.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dav...@us...> - 2009-08-19 19:44:07
|
Revision: 4698 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4698&view=rev Author: davybrion Date: 2009-08-19 19:43:56 +0000 (Wed, 19 Aug 2009) Log Message: ----------- NH-1935 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Context/WcfOperationSessionContext.cs Added: trunk/nhibernate/src/NHibernate/Context/WcfOperationSessionContext.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Context/WcfOperationSessionContext.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Context/WcfOperationSessionContext.cs 2009-08-19 19:43:56 UTC (rev 4698) @@ -0,0 +1,52 @@ +using System; +using System.Collections; +using System.ServiceModel; + +using NHibernate.Engine; + +namespace NHibernate.Context +{ + /// <summary> + /// Provides a <see cref="ISessionFactory.GetCurrentSession()">current session</see> + /// for the current OperationContext in WCF. Works only during the lifetime of a WCF operation. + /// </summary> + public class WcfOperationSessionContext : MapBasedSessionContext + { + public WcfOperationSessionContext(ISessionFactoryImplementor factory) : base(factory) {} + + private static WcfStateExtension WcfOperationState + { + get + { + var extension = OperationContext.Current.Extensions.Find<WcfStateExtension>(); + + if (extension == null) + { + extension = new WcfStateExtension(); + OperationContext.Current.Extensions.Add(extension); + } + + return extension; + } + } + + protected override IDictionary GetMap() + { + return WcfOperationState.Map; + } + + protected override void SetMap(IDictionary value) + { + WcfOperationState.Map = value; + } + } + + public class WcfStateExtension : IExtension<OperationContext> + { + public IDictionary Map { get; set; } + + // we don't really need implementations for these methods in this case + public void Attach(OperationContext owner) { } + public void Detach(OperationContext owner) { } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-08-18 05:51:57 UTC (rev 4697) +++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-08-19 19:43:56 UTC (rev 4698) @@ -1154,6 +1154,8 @@ return new WebSessionContext(this); case "managed_web": return new ManagedWebSessionContext(this); + case "wcf_operation": + return new WcfOperationSessionContext(this); } try Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-18 05:51:57 UTC (rev 4697) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-19 19:43:56 UTC (rev 4698) @@ -62,6 +62,9 @@ </Reference> <Reference Include="System.Data" /> <Reference Include="System.Data.OracleClient" /> + <Reference Include="System.ServiceModel"> + <RequiredTargetFramework>3.0</RequiredTargetFramework> + </Reference> <Reference Include="System.Transactions" /> <Reference Include="System.Web" /> <Reference Include="System.Xml" /> @@ -490,6 +493,7 @@ <Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" /> <Compile Include="Cfg\MappingSchema\HbmVersion.cs" /> <Compile Include="Cfg\MappingSchema\IDecoratable.cs" /> + <Compile Include="Context\WcfOperationSessionContext.cs" /> <Compile Include="Criterion\GroupedProjection.cs" /> <Compile Include="Criterion\IPropertyProjection.cs" /> <Compile Include="Criterion\QueryOverFetchBuilder.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-08-25 12:45:19
|
Revision: 4700 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4700&view=rev Author: ricbrown Date: 2009-08-25 12:45:10 +0000 (Tue, 25 Aug 2009) Log Message: ----------- Merge r4699 (Fix NH-1939) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/AuxiliaryDatabaseObjectFactory.cs trunk/nhibernate/src/NHibernate/Mapping/AbstractAuxiliaryDatabaseObject.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDefinition.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/AuxType.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-08-25 12:44:30 UTC (rev 4699) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-08-25 12:45:10 UTC (rev 4700) @@ -2,7 +2,7 @@ /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -83,7 +83,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -110,7 +110,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -128,7 +128,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -193,7 +193,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -207,7 +207,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -372,7 +372,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -386,7 +386,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -413,7 +413,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCacheUsage { @@ -436,7 +436,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCacheInclude { @@ -451,7 +451,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -465,7 +465,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -524,7 +524,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmOndelete { @@ -539,7 +539,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -565,7 +565,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -586,7 +586,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -618,7 +618,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -632,7 +632,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -770,7 +770,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -784,7 +784,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmOuterJoinStrategy { @@ -803,7 +803,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmFetchMode { @@ -818,7 +818,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmLaziness { @@ -837,7 +837,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmNotFoundMode { @@ -852,7 +852,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -888,7 +888,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1005,7 +1005,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1023,7 +1023,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1041,7 +1041,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPropertyGeneration { @@ -1060,7 +1060,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1121,7 +1121,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1151,7 +1151,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1255,7 +1255,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1277,7 +1277,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmRestrictedLaziness { @@ -1292,7 +1292,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1329,7 +1329,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1343,7 +1343,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1373,7 +1373,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCustomSQLCheck { @@ -1392,7 +1392,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCollectionFetchMode { @@ -1411,7 +1411,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1591,7 +1591,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCollectionLazy { @@ -1610,7 +1610,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1829,7 +1829,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1851,7 +1851,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmTuplizerEntitymode { @@ -1870,7 +1870,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1920,7 +1920,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1970,7 +1970,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2015,7 +2015,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmUnsavedValueType { @@ -2034,7 +2034,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2086,7 +2086,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2104,7 +2104,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2158,7 +2158,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2185,7 +2185,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2271,7 +2271,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2335,7 +2335,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2520,7 +2520,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2714,7 +2714,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2733,7 +2733,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2752,7 +2752,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2778,7 +2778,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2808,7 +2808,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2843,7 +2843,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2878,7 +2878,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2971,7 +2971,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3113,7 +3113,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPrimitivearrayOuterjoin { @@ -3132,7 +3132,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPrimitivearrayFetch { @@ -3151,7 +3151,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3335,7 +3335,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3518,7 +3518,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3551,7 +3551,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3604,7 +3604,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmTimestampUnsavedvalue { @@ -3619,7 +3619,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmTimestampSource { @@ -3634,7 +3634,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmVersionGeneration { @@ -3649,7 +3649,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3710,7 +3710,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3762,7 +3762,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3845,7 +3845,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmJoinFetch { @@ -3860,7 +3860,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4021,7 +4021,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4042,7 +4042,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4073,7 +4073,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4095,7 +4095,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4109,7 +4109,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmLockMode { @@ -4136,7 +4136,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4175,7 +4175,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4189,7 +4189,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4220,7 +4220,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4238,7 +4238,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4313,7 +4313,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4331,7 +4331,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmFlushMode { @@ -4350,7 +4350,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCacheMode { @@ -4377,7 +4377,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4467,7 +4467,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4606,7 +4606,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4764,7 +4764,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPolymorphismType { @@ -4779,7 +4779,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmOptimisticLockMode { @@ -4802,7 +4802,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4816,7 +4816,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4836,7 +4836,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4845,12 +4845,16 @@ public partial class HbmDefinition { /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute("param")] + public HbmParam[] param; + + /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] public string @class; } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4864,7 +4868,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4882,7 +4886,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4908,7 +4912,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4926,7 +4930,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -5015,7 +5019,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -5037,7 +5041,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDefinition.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDefinition.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDefinition.cs 2009-08-25 12:45:10 UTC (rev 4700) @@ -0,0 +1,22 @@ +using System.Collections.Generic; + +namespace NHibernate.Cfg.MappingSchema +{ + partial class HbmDefinition : HbmBase + { + public IDictionary<string, string> FindParameterValues() + { + IDictionary<string, string> parameters = new Dictionary<string, string>(); + + if (param != null) + { + foreach (HbmParam parameter in param) + { + parameters.Add(parameter.name, parameter.GetText()); + } + } + + return parameters; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/AuxiliaryDatabaseObjectFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/AuxiliaryDatabaseObjectFactory.cs 2009-08-25 12:44:30 UTC (rev 4699) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/AuxiliaryDatabaseObjectFactory.cs 2009-08-25 12:45:10 UTC (rev 4700) @@ -49,6 +49,8 @@ customObject.AddDialectScope(dialectName); } + customObject.SetParameterValues(definitionSchema.FindParameterValues()); + return customObject; } catch (TypeLoadException exception) Modified: trunk/nhibernate/src/NHibernate/Mapping/AbstractAuxiliaryDatabaseObject.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/AbstractAuxiliaryDatabaseObject.cs 2009-08-25 12:44:30 UTC (rev 4699) +++ trunk/nhibernate/src/NHibernate/Mapping/AbstractAuxiliaryDatabaseObject.cs 2009-08-25 12:45:10 UTC (rev 4700) @@ -17,6 +17,7 @@ public abstract class AbstractAuxiliaryDatabaseObject : IAuxiliaryDatabaseObject { private readonly HashedSet<string> dialectScopes; + private IDictionary<string, string> parameters = new Dictionary<string, string>(); protected AbstractAuxiliaryDatabaseObject() { @@ -38,6 +39,11 @@ get { return dialectScopes; } } + public IDictionary<string, string> Parameters + { + get { return parameters; } + } + public bool AppliesToDialect(Dialect.Dialect dialect) { // empty means no scoping @@ -47,6 +53,10 @@ public abstract string SqlCreateString(Dialect.Dialect dialect, IMapping p, string defaultCatalog, string defaultSchema); public abstract string SqlDropString(Dialect.Dialect dialect, string defaultCatalog, string defaultSchema); - public void SetParameterValues(IDictionary<string, string> parameters) {} + public void SetParameterValues(IDictionary<string, string> parameters) + { + this.parameters = parameters; + } + } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-25 12:44:30 UTC (rev 4699) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-08-25 12:45:10 UTC (rev 4700) @@ -486,6 +486,7 @@ <Compile Include="Cfg\Loquacious\ITypeDefConfiguration.cs" /> <Compile Include="Cfg\Loquacious\MappingsConfiguration.cs" /> <Compile Include="Cfg\Loquacious\ProxyConfiguration.cs" /> + <Compile Include="Cfg\MappingSchema\HbmDefinition.cs" /> <Compile Include="Cfg\SchemaAutoAction.cs" /> <Compile Include="Cfg\SessionFactoryConfigurationBase.cs" /> <Compile Include="Cfg\ISessionFactoryConfiguration.cs" /> Modified: trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd =================================================================== --- trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2009-08-25 12:44:30 UTC (rev 4699) +++ trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2009-08-25 12:45:10 UTC (rev 4700) @@ -367,6 +367,9 @@ </xs:element> <xs:element name="definition"> <xs:complexType> + <xs:sequence> + <xs:element ref="param" minOccurs="0" maxOccurs="unbounded" /> + </xs:sequence> <xs:attribute name="class" use="required" type="xs:string" /> </xs:complexType> </xs:element> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/AuxType.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/AuxType.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/AuxType.cs 2009-08-25 12:45:10 UTC (rev 4700) @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using NHibernate; +using NHibernate.Engine; +using NHibernate.Mapping; + +namespace NHibernate.Test.NHSpecificTest.NH1939 +{ + public class AuxType : AbstractAuxiliaryDatabaseObject + { + + override public string SqlCreateString(Dialect.Dialect dialect, IMapping p, string defaultCatalog, string defaultSchema) + { + return "select '" + Parameters["scriptParameter"] + "'"; + } + + override public string SqlDropString(Dialect.Dialect dialect, string defaultCatalog, string defaultSchema) + { + return "select 'drop script'"; + } + + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Fixture.cs 2009-08-25 12:45:10 UTC (rev 4700) @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; +using NHibernate.Tool.hbm2ddl; +using System.Text; +using NHibernate.Cfg; + +namespace NHibernate.Test.NHSpecificTest.NH1939 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + private Configuration cfg; + private StringBuilder schemaBuilder; + + private void AddString(string sqlString) + { + schemaBuilder.Append(sqlString); + } + + protected override bool AppliesTo(NHibernate.Dialect.Dialect dialect) + { + return (dialect is Dialect.MsSql2000Dialect); + } + + protected override void Configure(Configuration configuration) + { + base.Configure(configuration); + cfg = configuration; + } + + [Test] + public void Can_Parameterise_Auxiliary_Database_Objects() + { + schemaBuilder = new StringBuilder(); + + SchemaExport schemaExport = new SchemaExport(cfg); + schemaExport.Execute(AddString, false, false); + + string schema = schemaBuilder.ToString(); + + Assert.That(schema.Contains("select 'drop script'"), Is.True, + "schema drop script not exported"); + + Assert.That(schema.Contains("select 'create script'"), Is.True, + "parameterised schema create script not exported"); + } + + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1939/Mappings.hbm.xml 2009-08-25 12:45:10 UTC (rev 4700) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1939"> + + <database-object> + <definition class="AuxType"> + <param name="scriptParameter">create script</param> + </definition> + </database-object> + +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-25 12:44:30 UTC (rev 4699) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-25 12:45:10 UTC (rev 4700) @@ -585,6 +585,8 @@ <Compile Include="NHSpecificTest\NH1914\Model.cs" /> <Compile Include="NHSpecificTest\NH1920\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1920\Model.cs" /> + <Compile Include="NHSpecificTest\NH1939\AuxType.cs" /> + <Compile Include="NHSpecificTest\NH1939\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1998,6 +2000,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1939\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1911\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1920\Mappings.hbm.xml" /> <EmbeddedResource Include="Linq\Mappings\Customer.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <ste...@us...> - 2009-08-31 12:54:02
|
Revision: 4704 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4704&view=rev Author: steverstrong Date: 2009-08-31 12:53:49 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Linq provider code. Nothing to see here, move along :) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlParser.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/SqlGenerator.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/SqlGenerator.g trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ASTNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ConstructorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/LiteralNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Util/LiteralProcessor.cs trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Customer.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Employee.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Northwind.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Order.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Product.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/ProductCategory.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Shipper.cs trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Supplier.cs trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Customer.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Employee.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Order.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Product.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/ProductCategory.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Shipper.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Supplier.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Removed Paths: ------------- trunk/nhibernate/src/NHibernate/Linq/LinqExpression.cs trunk/nhibernate/src/NHibernate/Linq/NhQueryProvider.cs trunk/nhibernate/src/NHibernate/Linq/Query.cs trunk/nhibernate/src/NHibernate/Linq/QueryProvider.cs trunk/nhibernate/src/NHibernate/Linq/TypeHelper.cs trunk/nhibernate/src/NHibernate.Test/Linq/BasicLinqTests.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs 2009-08-31 10:01:43 UTC (rev 4703) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlLexer.cs 2009-08-31 12:53:49 UTC (rev 4704) @@ -1,4 +1,4 @@ -// $ANTLR 3.1.2 /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g 2009-06-20 02:19:06 +// $ANTLR 3.1.2 /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g 2009-08-19 15:39:23 // The variable 'variable' is assigned but its value is never used. #pragma warning disable 168, 219 @@ -19,9 +19,9 @@ public partial class HqlLexer : Lexer { public const int EXPR_LIST = 73; public const int EXISTS = 19; - public const int COMMA = 98; + public const int COMMA = 99; public const int FETCH = 21; - public const int MINUS = 114; + public const int MINUS = 115; public const int AS = 7; public const int END = 56; public const int INTO = 30; @@ -29,7 +29,7 @@ public const int ELEMENTS = 17; public const int THEN = 58; public const int ALIAS = 70; - public const int BOR = 110; + public const int BOR = 111; public const int ON = 60; public const int DOT = 15; public const int ORDER = 41; @@ -38,46 +38,47 @@ public const int UNARY_MINUS = 88; public const int METHOD_CALL = 79; public const int RIGHT = 44; - public const int CONCAT = 108; + public const int CONCAT = 109; public const int PROPERTIES = 43; public const int SELECT = 45; - public const int LE = 106; + public const int LE = 107; public const int BETWEEN = 10; public const int NUM_INT = 93; public const int BOTH = 62; - public const int PLUS = 113; + public const int PLUS = 114; public const int VERSIONED = 52; public const int MEMBER = 65; + public const int NUM_DECIMAL = 95; public const int UNION = 50; public const int DISTINCT = 16; public const int RANGE = 85; public const int FILTER_ENTITY = 74; - public const int IDENT = 122; + public const int IDENT = 123; public const int WHEN = 59; public const int DESCENDING = 14; - public const int WS = 126; - public const int EQ = 99; + public const int WS = 127; + public const int EQ = 100; public const int NEW = 37; - public const int LT = 104; - public const int ESCqs = 125; + public const int LT = 105; + public const int ESCqs = 126; public const int OF = 67; - public const int T__130 = 130; public const int UPDATE = 51; public const int SELECT_FROM = 87; public const int LITERAL_by = 54; - public const int FLOAT_SUFFIX = 128; + public const int FLOAT_SUFFIX = 129; public const int ANY = 5; public const int UNARY_PLUS = 89; - public const int NUM_FLOAT = 95; - public const int GE = 107; + public const int NUM_FLOAT = 96; + public const int GE = 108; public const int CASE = 55; - public const int OPEN_BRACKET = 117; + public const int OPEN_BRACKET = 118; public const int ELSE = 57; - public const int OPEN = 100; + public const int OPEN = 101; public const int COUNT = 12; public const int NULL = 39; - public const int COLON = 119; - public const int DIV = 116; + public const int T__132 = 132; + public const int COLON = 120; + public const int DIV = 117; public const int HAVING = 25; public const int ALL = 4; public const int SET = 46; @@ -89,9 +90,9 @@ public const int WHERE = 53; public const int AGGREGATE = 69; public const int VECTOR_EXPR = 90; - public const int BNOT = 109; + public const int BNOT = 110; public const int LEADING = 64; - public const int CLOSE_BRACKET = 118; + public const int CLOSE_BRACKET = 119; public const int NUM_DOUBLE = 94; public const int INNER = 28; public const int QUERY = 84; @@ -102,16 +103,16 @@ public const int IS_NULL = 78; public const int GROUP = 24; public const int ESCAPE = 18; - public const int PARAM = 120; - public const int ID_LETTER = 124; + public const int PARAM = 121; public const int INDEX_OP = 76; - public const int HEX_DIGIT = 129; + public const int ID_LETTER = 125; + public const int HEX_DIGIT = 130; public const int LEFT = 33; public const int TRAILING = 68; public const int JOIN = 32; public const int NOT_BETWEEN = 80; public const int SUM = 48; - public const int BAND = 112; + public const int BAND = 113; public const int ROW_STAR = 86; public const int OUTER = 42; public const int NOT_IN = 81; @@ -121,15 +122,15 @@ public const int MAX = 35; public const int NOT_LIKE = 82; public const int EMPTY = 63; - public const int QUOTED_String = 121; + public const int QUOTED_String = 122; public const int ASCENDING = 8; - public const int NUM_LONG = 96; + public const int NUM_LONG = 97; public const int IS = 31; - public const int SQL_NE = 103; + public const int SQL_NE = 104; public const int IN_LIST = 75; public const int WEIRD_IDENT = 91; - public const int NE = 102; - public const int GT = 105; + public const int NE = 103; + public const int GT = 106; public const int MIN = 36; public const int LIKE = 34; public const int WITH = 61; @@ -137,15 +138,15 @@ public const int CONSTRUCTOR = 71; public const int SOME = 47; public const int CLASS = 11; - public const int EXPONENT = 127; - public const int ID_START_LETTER = 123; + public const int EXPONENT = 128; + public const int ID_START_LETTER = 124; public const int EOF = -1; - public const int CLOSE = 101; + public const int CLOSE = 102; public const int AVG = 9; - public const int BXOR = 111; - public const int STAR = 115; + public const int BXOR = 112; + public const int STAR = 116; public const int NOT = 38; - public const int JAVA_CONSTANT = 97; + public const int JAVA_CONSTANT = 98; // delegates // delegators @@ -1704,12 +1705,12 @@ } // $ANTLR end "TRAILING" - // $ANTLR start "T__130" - public void mT__130() // throws RecognitionException [2] + // $ANTLR start "T__131" + public void mT__131() // throws RecognitionException [2] { try { - int _type = T__130; + int _type = T__131; int _channel = DEFAULT_TOKEN_CHANNEL; // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:73:8: ( 'ascending' ) // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:73:10: 'ascending' @@ -1726,14 +1727,14 @@ { } } - // $ANTLR end "T__130" + // $ANTLR end "T__131" - // $ANTLR start "T__131" - public void mT__131() // throws RecognitionException [2] + // $ANTLR start "T__132" + public void mT__132() // throws RecognitionException [2] { try { - int _type = T__131; + int _type = T__132; int _channel = DEFAULT_TOKEN_CHANNEL; // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:74:8: ( 'descending' ) // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:74:10: 'descending' @@ -1750,7 +1751,7 @@ { } } - // $ANTLR end "T__131" + // $ANTLR end "T__132" // $ANTLR start "EQ" public void mEQ() // throws RecognitionException [2] @@ -1759,8 +1760,8 @@ { int _type = EQ; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:670:3: ( '=' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:670:5: '=' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:672:3: ( '=' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:672:5: '=' { Match('='); if (state.failed) return ; @@ -1782,8 +1783,8 @@ { int _type = LT; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:671:3: ( '<' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:671:5: '<' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:673:3: ( '<' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:673:5: '<' { Match('<'); if (state.failed) return ; @@ -1805,8 +1806,8 @@ { int _type = GT; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:672:3: ( '>' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:672:5: '>' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:674:3: ( '>' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:674:5: '>' { Match('>'); if (state.failed) return ; @@ -1828,8 +1829,8 @@ { int _type = SQL_NE; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:673:7: ( '<>' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:673:9: '<>' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:675:7: ( '<>' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:675:9: '<>' { Match("<>"); if (state.failed) return ; @@ -1852,7 +1853,7 @@ { int _type = NE; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:674:3: ( '!=' | '^=' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:676:3: ( '!=' | '^=' ) int alt1 = 2; int LA1_0 = input.LA(1); @@ -1875,7 +1876,7 @@ switch (alt1) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:674:5: '!=' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:676:5: '!=' { Match("!="); if (state.failed) return ; @@ -1883,7 +1884,7 @@ } break; case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:674:12: '^=' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:676:12: '^=' { Match("^="); if (state.failed) return ; @@ -1908,8 +1909,8 @@ { int _type = LE; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:675:3: ( '<=' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:675:5: '<=' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:677:3: ( '<=' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:677:5: '<=' { Match("<="); if (state.failed) return ; @@ -1932,8 +1933,8 @@ { int _type = GE; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:676:3: ( '>=' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:676:5: '>=' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:678:3: ( '>=' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:678:5: '>=' { Match(">="); if (state.failed) return ; @@ -1956,8 +1957,8 @@ { int _type = BOR; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:678:5: ( '|' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:678:8: '|' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:680:5: ( '|' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:680:8: '|' { Match('|'); if (state.failed) return ; @@ -1979,8 +1980,8 @@ { int _type = BXOR; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:679:6: ( '^' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:679:8: '^' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:681:6: ( '^' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:681:8: '^' { Match('^'); if (state.failed) return ; @@ -2002,8 +2003,8 @@ { int _type = BAND; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:680:6: ( '&' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:680:8: '&' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:682:6: ( '&' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:682:8: '&' { Match('&'); if (state.failed) return ; @@ -2025,8 +2026,8 @@ { int _type = BNOT; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:681:6: ( '!' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:681:8: '!' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:683:6: ( '!' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:683:8: '!' { Match('!'); if (state.failed) return ; @@ -2048,8 +2049,8 @@ { int _type = COMMA; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:683:6: ( ',' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:683:8: ',' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:685:6: ( ',' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:685:8: ',' { Match(','); if (state.failed) return ; @@ -2071,8 +2072,8 @@ { int _type = OPEN; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:685:5: ( '(' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:685:7: '(' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:687:5: ( '(' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:687:7: '(' { Match('('); if (state.failed) return ; @@ -2094,8 +2095,8 @@ { int _type = CLOSE; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:686:6: ( ')' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:686:8: ')' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:688:6: ( ')' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:688:8: ')' { Match(')'); if (state.failed) return ; @@ -2117,8 +2118,8 @@ { int _type = OPEN_BRACKET; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:687:13: ( '[' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:687:15: '[' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:689:13: ( '[' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:689:15: '[' { Match('['); if (state.failed) return ; @@ -2140,8 +2141,8 @@ { int _type = CLOSE_BRACKET; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:688:14: ( ']' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:688:16: ']' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:690:14: ( ']' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:690:16: ']' { Match(']'); if (state.failed) return ; @@ -2163,8 +2164,8 @@ { int _type = CONCAT; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:690:7: ( '||' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:690:9: '||' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:692:7: ( '||' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:692:9: '||' { Match("||"); if (state.failed) return ; @@ -2187,8 +2188,8 @@ { int _type = PLUS; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:691:5: ( '+' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:691:7: '+' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:693:5: ( '+' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:693:7: '+' { Match('+'); if (state.failed) return ; @@ -2210,8 +2211,8 @@ { int _type = MINUS; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:692:6: ( '-' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:692:8: '-' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:694:6: ( '-' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:694:8: '-' { Match('-'); if (state.failed) return ; @@ -2233,8 +2234,8 @@ { int _type = STAR; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:693:5: ( '*' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:693:7: '*' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:695:5: ( '*' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:695:7: '*' { Match('*'); if (state.failed) return ; @@ -2256,8 +2257,8 @@ { int _type = DIV; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:694:4: ( '/' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:694:6: '/' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:696:4: ( '/' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:696:6: '/' { Match('/'); if (state.failed) return ; @@ -2279,8 +2280,8 @@ { int _type = COLON; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:695:6: ( ':' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:695:8: ':' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:697:6: ( ':' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:697:8: ':' { Match(':'); if (state.failed) return ; @@ -2302,8 +2303,8 @@ { int _type = PARAM; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:696:6: ( '?' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:696:8: '?' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:698:6: ( '?' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:698:8: '?' { Match('?'); if (state.failed) return ; @@ -2325,11 +2326,11 @@ { int _type = IDENT; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:699:2: ( ID_START_LETTER ( ID_LETTER )* ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:699:4: ID_START_LETTER ( ID_LETTER )* + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:701:2: ( ID_START_LETTER ( ID_LETTER )* ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:701:4: ID_START_LETTER ( ID_LETTER )* { mID_START_LETTER(); if (state.failed) return ; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:699:20: ( ID_LETTER )* + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:701:20: ( ID_LETTER )* do { int alt2 = 2; @@ -2344,7 +2345,7 @@ switch (alt2) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:699:22: ID_LETTER + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:701:22: ID_LETTER { mID_LETTER(); if (state.failed) return ; @@ -2376,7 +2377,7 @@ { try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:704:5: ( '_' | '$' | 'a' .. 'z' | 'A' .. 'Z' | '\\u0080' .. '\\ufffe' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:706:5: ( '_' | '$' | 'a' .. 'z' | 'A' .. 'Z' | '\\u0080' .. '\\ufffe' ) // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g: { if ( input.LA(1) == '$' || (input.LA(1) >= 'A' && input.LA(1) <= 'Z') || input.LA(1) == '_' || (input.LA(1) >= 'a' && input.LA(1) <= 'z') || (input.LA(1) >= '\u0080' && input.LA(1) <= '\uFFFE') ) @@ -2406,7 +2407,7 @@ { try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:713:5: ( ID_START_LETTER | '0' .. '9' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:715:5: ( ID_START_LETTER | '0' .. '9' ) // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g: { if ( input.LA(1) == '$' || (input.LA(1) >= '0' && input.LA(1) <= '9') || (input.LA(1) >= 'A' && input.LA(1) <= 'Z') || input.LA(1) == '_' || (input.LA(1) >= 'a' && input.LA(1) <= 'z') || (input.LA(1) >= '\u0080' && input.LA(1) <= '\uFFFE') ) @@ -2438,11 +2439,11 @@ { int _type = QUOTED_String; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:718:4: ( '\\'' ( ( ESCqs )=> ESCqs | ~ '\\'' )* '\\'' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:718:6: '\\'' ( ( ESCqs )=> ESCqs | ~ '\\'' )* '\\'' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:720:4: ( '\\'' ( ( ESCqs )=> ESCqs | ~ '\\'' )* '\\'' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:720:6: '\\'' ( ( ESCqs )=> ESCqs | ~ '\\'' )* '\\'' { Match('\''); if (state.failed) return ; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:718:11: ( ( ESCqs )=> ESCqs | ~ '\\'' )* + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:720:11: ( ( ESCqs )=> ESCqs | ~ '\\'' )* do { int alt3 = 3; @@ -2468,14 +2469,14 @@ switch (alt3) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:718:13: ( ESCqs )=> ESCqs + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:720:13: ( ESCqs )=> ESCqs { mESCqs(); if (state.failed) return ; } break; case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:718:31: ~ '\\'' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:720:31: ~ '\\'' { if ( (input.LA(1) >= '\u0000' && input.LA(1) <= '&') || (input.LA(1) >= '(' && input.LA(1) <= '\uFFFF') ) { @@ -2519,8 +2520,8 @@ { try { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:723:2: ( '\\'' '\\'' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:724:3: '\\'' '\\'' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:725:2: ( '\\'' '\\'' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:726:3: '\\'' '\\'' { Match('\''); if (state.failed) return ; Match('\''); if (state.failed) return ; @@ -2541,10 +2542,10 @@ { int _type = WS; int _channel = DEFAULT_TOKEN_CHANNEL; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:727:5: ( ( ' ' | '\\t' | '\\r' '\\n' | '\\n' | '\\r' ) ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:727:9: ( ' ' | '\\t' | '\\r' '\\n' | '\\n' | '\\r' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:729:5: ( ( ' ' | '\\t' | '\\r' '\\n' | '\\n' | '\\r' ) ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:729:9: ( ' ' | '\\t' | '\\r' '\\n' | '\\n' | '\\r' ) { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:727:9: ( ' ' | '\\t' | '\\r' '\\n' | '\\n' | '\\r' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:729:9: ( ' ' | '\\t' | '\\r' '\\n' | '\\n' | '\\r' ) int alt4 = 5; switch ( input.LA(1) ) { @@ -2587,21 +2588,21 @@ switch (alt4) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:727:13: ' ' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:729:13: ' ' { Match(' '); if (state.failed) return ; } break; case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:728:7: '\\t' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:730:7: '\\t' { Match('\t'); if (state.failed) return ; } break; case 3 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:729:7: '\\r' '\\n' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:731:7: '\\r' '\\n' { Match('\r'); if (state.failed) return ; Match('\n'); if (state.failed) return ; @@ -2609,14 +2610,14 @@ } break; case 4 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:730:7: '\\n' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:732:7: '\\n' { Match('\n'); if (state.failed) return ; } break; case 5 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:731:7: '\\r' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:733:7: '\\r' { Match('\r'); if (state.failed) return ; @@ -2654,7 +2655,7 @@ IToken f4 = null; bool isDecimal=false; IToken t=null; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:740:2: ( '.' ( ( '0' .. '9' )+ ( EXPONENT )? (f1= FLOAT_SUFFIX )? )? | ( '0' ( ( 'x' ) ( HEX_DIGIT )+ | ( '0' .. '7' )+ )? | ( '1' .. '9' ) ( '0' .. '9' )* ) ( ( 'l' ) | {...}? ( '.' ( '0' .. '9' )* ( EXPONENT )? (f2= FLOAT_SUFFIX )? | EXPONENT (f3= FLOAT_SUFFIX )? | f4= FLOAT_SUFFIX ) )? ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:742:2: ( '.' ( ( '0' .. '9' )+ ( EXPONENT )? (f1= FLOAT_SUFFIX )? )? | ( '0' ( ( 'x' ) ( HEX_DIGIT )+ | ( '0' .. '7' )+ )? | ( '1' .. '9' ) ( '0' .. '9' )* ) ( ( 'l' ) | {...}? ( '.' ( '0' .. '9' )* ( EXPONENT )? (f2= FLOAT_SUFFIX )? | EXPONENT (f3= FLOAT_SUFFIX )? | f4= FLOAT_SUFFIX ) )? ) int alt20 = 2; int LA20_0 = input.LA(1); @@ -2677,14 +2678,14 @@ switch (alt20) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:740:6: '.' ( ( '0' .. '9' )+ ( EXPONENT )? (f1= FLOAT_SUFFIX )? )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:742:6: '.' ( ( '0' .. '9' )+ ( EXPONENT )? (f1= FLOAT_SUFFIX )? )? { Match('.'); if (state.failed) return ; if ( (state.backtracking==0) ) { _type = DOT; } - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:741:4: ( ( '0' .. '9' )+ ( EXPONENT )? (f1= FLOAT_SUFFIX )? )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:743:4: ( ( '0' .. '9' )+ ( EXPONENT )? (f1= FLOAT_SUFFIX )? )? int alt8 = 2; int LA8_0 = input.LA(1); @@ -2695,9 +2696,9 @@ switch (alt8) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:741:6: ( '0' .. '9' )+ ( EXPONENT )? (f1= FLOAT_SUFFIX )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:743:6: ( '0' .. '9' )+ ( EXPONENT )? (f1= FLOAT_SUFFIX )? { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:741:6: ( '0' .. '9' )+ + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:743:6: ( '0' .. '9' )+ int cnt5 = 0; do { @@ -2713,7 +2714,7 @@ switch (alt5) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:741:7: '0' .. '9' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:743:7: '0' .. '9' { MatchRange('0','9'); if (state.failed) return ; @@ -2733,7 +2734,7 @@ loop5: ; // Stops C# compiler whinging that label 'loop5' has no statements - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:741:18: ( EXPONENT )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:743:18: ( EXPONENT )? int alt6 = 2; int LA6_0 = input.LA(1); @@ -2744,7 +2745,7 @@ switch (alt6) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:741:19: EXPONENT + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:743:19: EXPONENT { mEXPONENT(); if (state.failed) return ; @@ -2753,18 +2754,18 @@ } - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:741:30: (f1= FLOAT_SUFFIX )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:743:30: (f1= FLOAT_SUFFIX )? int alt7 = 2; int LA7_0 = input.LA(1); - if ( (LA7_0 == 'd' || LA7_0 == 'f') ) + if ( (LA7_0 == 'd' || LA7_0 == 'f' || LA7_0 == 'm') ) { alt7 = 1; } switch (alt7) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:741:31: f1= FLOAT_SUFFIX + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:743:31: f1= FLOAT_SUFFIX { int f1Start1018 = CharIndex; mFLOAT_SUFFIX(); if (state.failed) return ; @@ -2786,6 +2787,10 @@ { _type = NUM_FLOAT; } + else if (t != null && t.Text.ToUpperInvariant().IndexOf('M')>=0) + { + _type = NUM_DECIMAL; + } else { _type = NUM_DOUBLE; // assume double @@ -2802,9 +2807,9 @@ } break; case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:753:4: ( '0' ( ( 'x' ) ( HEX_DIGIT )+ | ( '0' .. '7' )+ )? | ( '1' .. '9' ) ( '0' .. '9' )* ) ( ( 'l' ) | {...}? ( '.' ( '0' .. '9' )* ( EXPONENT )? (f2= FLOAT_SUFFIX )? | EXPONENT (f3= FLOAT_SUFFIX )? | f4= FLOAT_SUFFIX ) )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:759:4: ( '0' ( ( 'x' ) ( HEX_DIGIT )+ | ( '0' .. '7' )+ )? | ( '1' .. '9' ) ( '0' .. '9' )* ) ( ( 'l' ) | {...}? ( '.' ( '0' .. '9' )* ( EXPONENT )? (f2= FLOAT_SUFFIX )? | EXPONENT (f3= FLOAT_SUFFIX )? | f4= FLOAT_SUFFIX ) )? { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:753:4: ( '0' ( ( 'x' ) ( HEX_DIGIT )+ | ( '0' .. '7' )+ )? | ( '1' .. '9' ) ( '0' .. '9' )* ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:759:4: ( '0' ( ( 'x' ) ( HEX_DIGIT )+ | ( '0' .. '7' )+ )? | ( '1' .. '9' ) ( '0' .. '9' )* ) int alt13 = 2; int LA13_0 = input.LA(1); @@ -2827,14 +2832,14 @@ switch (alt13) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:753:6: '0' ( ( 'x' ) ( HEX_DIGIT )+ | ( '0' .. '7' )+ )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:759:6: '0' ( ( 'x' ) ( HEX_DIGIT )+ | ( '0' .. '7' )+ )? { Match('0'); if (state.failed) return ; if ( (state.backtracking==0) ) { isDecimal = true; } - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:754:4: ( ( 'x' ) ( HEX_DIGIT )+ | ( '0' .. '7' )+ )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:760:4: ( ( 'x' ) ( HEX_DIGIT )+ | ( '0' .. '7' )+ )? int alt11 = 3; int LA11_0 = input.LA(1); @@ -2849,16 +2854,16 @@ switch (alt11) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:754:6: ( 'x' ) ( HEX_DIGIT )+ + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:760:6: ( 'x' ) ( HEX_DIGIT )+ { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:754:6: ( 'x' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:754:7: 'x' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:760:6: ( 'x' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:760:7: 'x' { Match('x'); if (state.failed) return ; } - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:755:5: ( HEX_DIGIT )+ + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:761:5: ( HEX_DIGIT )+ int cnt9 = 0; do { @@ -2924,7 +2929,7 @@ switch (alt9) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:762:7: HEX_DIGIT + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:768:7: HEX_DIGIT { mHEX_DIGIT(); if (state.failed) return ; @@ -2948,9 +2953,9 @@ } break; case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:764:6: ( '0' .. '7' )+ + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:770:6: ( '0' .. '7' )+ { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:764:6: ( '0' .. '7' )+ + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:770:6: ( '0' .. '7' )+ int cnt10 = 0; do { @@ -2966,7 +2971,7 @@ switch (alt10) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:764:7: '0' .. '7' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:770:7: '0' .. '7' { MatchRange('0','7'); if (state.failed) return ; @@ -2996,16 +3001,16 @@ } break; case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:766:5: ( '1' .. '9' ) ( '0' .. '9' )* + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:772:5: ( '1' .. '9' ) ( '0' .. '9' )* { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:766:5: ( '1' .. '9' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:766:6: '1' .. '9' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:772:5: ( '1' .. '9' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:772:6: '1' .. '9' { MatchRange('1','9'); if (state.failed) return ; } - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:766:16: ( '0' .. '9' )* + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:772:16: ( '0' .. '9' )* do { int alt12 = 2; @@ -3020,7 +3025,7 @@ switch (alt12) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:766:17: '0' .. '9' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:772:17: '0' .. '9' { MatchRange('0','9'); if (state.failed) return ; @@ -3045,7 +3050,7 @@ } - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:768:3: ( ( 'l' ) | {...}? ( '.' ( '0' .. '9' )* ( EXPONENT )? (f2= FLOAT_SUFFIX )? | EXPONENT (f3= FLOAT_SUFFIX )? | f4= FLOAT_SUFFIX ) )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:774:3: ( ( 'l' ) | {...}? ( '.' ( '0' .. '9' )* ( EXPONENT )? (f2= FLOAT_SUFFIX )? | EXPONENT (f3= FLOAT_SUFFIX )? | f4= FLOAT_SUFFIX ) )? int alt19 = 3; int LA19_0 = input.LA(1); @@ -3053,17 +3058,17 @@ { alt19 = 1; } - else if ( (LA19_0 == '.' || (LA19_0 >= 'd' && LA19_0 <= 'f')) ) + else if ( (LA19_0 == '.' || (LA19_0 >= 'd' && LA19_0 <= 'f') || LA19_0 == 'm') ) { alt19 = 2; } switch (alt19) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:768:5: ( 'l' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:774:5: ( 'l' ) { - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:768:5: ( 'l' ) - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:768:6: 'l' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:774:5: ( 'l' ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:774:6: 'l' { Match('l'); if (state.failed) return ; @@ -3077,14 +3082,14 @@ } break; case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:771:5: {...}? ( '.' ( '0' .. '9' )* ( EXPONENT )? (f2= FLOAT_SUFFIX )? | EXPONENT (f3= FLOAT_SUFFIX )? | f4= FLOAT_SUFFIX ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:777:5: {...}? ( '.' ( '0' .. '9' )* ( EXPONENT )? (f2= FLOAT_SUFFIX )? | EXPONENT (f3= FLOAT_SUFFIX )? | f4= FLOAT_SUFFIX ) { if ( !((isDecimal)) ) { if ( state.backtracking > 0 ) {state.failed = true; return ;} throw new FailedPredicateException(input, "NUM_INT", "isDecimal"); } - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:772:4: ( '.' ( '0' .. '9' )* ( EXPONENT )? (f2= FLOAT_SUFFIX )? | EXPONENT (f3= FLOAT_SUFFIX )? | f4= FLOAT_SUFFIX ) + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:778:4: ( '.' ( '0' .. '9' )* ( EXPONENT )? (f2= FLOAT_SUFFIX )? | EXPONENT (f3= FLOAT_SUFFIX )? | f4= FLOAT_SUFFIX ) int alt18 = 3; switch ( input.LA(1) ) { @@ -3100,6 +3105,7 @@ break; case 'd': case 'f': + case 'm': { alt18 = 3; } @@ -3115,10 +3121,10 @@ switch (alt18) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:772:8: '.' ( '0' .. '9' )* ( EXPONENT )? (f2= FLOAT_SUFFIX )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:778:8: '.' ( '0' .. '9' )* ( EXPONENT )? (f2= FLOAT_SUFFIX )? { Match('.'); if (state.failed) return ; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:772:12: ( '0' .. '9' )* + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:778:12: ( '0' .. '9' )* do { int alt14 = 2; @@ -3133,7 +3139,7 @@ switch (alt14) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:772:13: '0' .. '9' + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:778:13: '0' .. '9' { MatchRange('0','9'); if (state.failed) return ; @@ -3148,7 +3154,7 @@ loop14: ; // Stops C# compiler whining that label 'loop14' has no statements - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:772:24: ( EXPONENT )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:778:24: ( EXPONENT )? int alt15 = 2; int LA15_0 = input.LA(1); @@ -3159,7 +3165,7 @@ switch (alt15) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:772:25: EXPONENT + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:778:25: EXPONENT { mEXPONENT(); if (state.failed) return ; @@ -3168,18 +3174,18 @@ } - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:772:36: (f2= FLOAT_SUFFIX )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:778:36: (f2= FLOAT_SUFFIX )? int alt16 = 2; int LA16_0 = input.LA(1); - if ( (LA16_0 == 'd' || LA16_0 == 'f') ) + if ( (LA16_0 == 'd' || LA16_0 == 'f' || LA16_0 == 'm') ) { alt16 = 1; } switch (alt16) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:772:37: f2= FLOAT_SUFFIX + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:778:37: f2= FLOAT_SUFFIX { int f2Start1220 = CharIndex; mFLOAT_SUFFIX(); if (state.failed) return ; @@ -3198,21 +3204,21 @@ } break; case 2 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:773:8: EXPONENT (f3= FLOAT_SUFFIX )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:779:8: EXPONENT (f3= FLOAT_SUFFIX )? { mEXPONENT(); if (state.failed) return ; - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:773:17: (f3= FLOAT_SUFFIX )? + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:779:17: (f3= FLOAT_SUFFIX )? int alt17 = 2; int LA17_0 = input.LA(1); - if ( (LA17_0 == 'd' || LA17_0 == 'f') ) + if ( (LA17_0 == 'd' || LA17_0 == 'f' || LA17_0 == 'm') ) { alt17 = 1; } switch (alt17) { case 1 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:773:18: f3= FLOAT_SUFFIX + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:779:18: f3= FLOAT_SUFFIX { int f3Start1238 = CharIndex; mFLOAT_SUFFIX(); if (state.failed) return ; @@ -3231,7 +3237,7 @@ } break; case 3 : - // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:774:8: f4= FLOAT_SUFFIX + // /Users/Steve/Projects/NHibernate/Trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:780:8: f4= FLOAT_SUFFIX ... [truncated message content] |
From: <ric...@us...> - 2009-09-08 11:14:38
|
Revision: 4708 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4708&view=rev Author: ricbrown Date: 2009-09-08 11:14:30 +0000 (Tue, 08 Sep 2009) Log Message: ----------- Merge r4707 (Fix NH-1938) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/LikeExpression.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938/Model.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/LikeExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/LikeExpression.cs 2009-09-08 11:13:42 UTC (rev 4707) +++ trunk/nhibernate/src/NHibernate/Criterion/LikeExpression.cs 2009-09-08 11:14:30 UTC (rev 4708) @@ -74,7 +74,19 @@ lhs.Add(columns[0]); criteriaQuery.AddUsedTypedValues(GetTypedValues(criteria, criteriaQuery)); - lhs.Add(" like ").AddParameter(); + + if (ignoreCase) + { + Dialect.Dialect dialect = criteriaQuery.Factory.Dialect; + lhs.Add(" like ") + .Add(dialect.LowercaseFunction) + .Add(StringHelper.OpenParen) + .AddParameter() + .Add(StringHelper.ClosedParen); + } + else + lhs.Add(" like ").AddParameter(); + if (escapeChar.HasValue) lhs.Add(" escape '" + escapeChar + "'"); return lhs.ToSqlString(); Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938 ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938/Fixture.cs 2009-09-08 11:14:30 UTC (rev 4708) @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; +using NHibernate.Criterion; + +namespace NHibernate.Test.NHSpecificTest.NH1938 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + protected override bool AppliesTo(NHibernate.Dialect.Dialect dialect) + { + // Database needs to be case-sensitive + return (dialect is NHibernate.Dialect.Oracle10gDialect); + } + + [Test] + public void Can_Query_By_Example_Case_Insensitive() + { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new Person() { Name = "John Smith" }); + + Person examplePerson = new Person() { Name = "oHn" }; + IList<Person> matchingPeople; + + matchingPeople = + s.CreateCriteria<Person>() + .Add(Example + .Create(examplePerson) + .EnableLike(MatchMode.Anywhere) + .IgnoreCase()) + .List<Person>(); + + Assert.That(matchingPeople.Count, Is.EqualTo(1)); + + matchingPeople = + s.CreateCriteria<Person>() + .Add(Example + .Create(examplePerson) + .EnableLike(MatchMode.Anywhere)) + .List<Person>(); + + Assert.That(matchingPeople.Count, Is.EqualTo(0)); + + t.Rollback(); + } + } + + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938/Mappings.hbm.xml 2009-09-08 11:14:30 UTC (rev 4708) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1938"> + + <class name="Person"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name"/> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1938/Model.cs 2009-09-08 11:14:30 UTC (rev 4708) @@ -0,0 +1,19 @@ +using System; +using System.Xml.Serialization; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +using NHibernate; +using NHibernate.Classic; + +namespace NHibernate.Test.NHSpecificTest.NH1938 +{ + + public class Person + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + } + +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-08 11:13:42 UTC (rev 4707) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-08 11:14:30 UTC (rev 4708) @@ -588,6 +588,8 @@ <Compile Include="NHSpecificTest\NH1914\Model.cs" /> <Compile Include="NHSpecificTest\NH1920\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1920\Model.cs" /> + <Compile Include="NHSpecificTest\NH1938\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1938\Model.cs" /> <Compile Include="NHSpecificTest\NH1939\AuxType.cs" /> <Compile Include="NHSpecificTest\NH1939\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> @@ -2003,6 +2005,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1938\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1905\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1939\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1911\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-09-08 13:15:42
|
Revision: 4710 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4710&view=rev Author: ricbrown Date: 2009-09-08 13:15:32 +0000 (Tue, 08 Sep 2009) Log Message: ----------- Merge r4709 (Fix NH-1926) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/DatabaseMetadata.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/MigrationFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/1_Person.hbm.xml trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/2_Person.hbm.xml trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/Person.cs Modified: trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/DatabaseMetadata.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/DatabaseMetadata.cs 2009-09-08 13:13:49 UTC (rev 4709) +++ trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/DatabaseMetadata.cs 2009-09-08 13:15:32 UTC (rev 4710) @@ -117,7 +117,7 @@ using (IDataReader rs = statement.ExecuteReader()) { while (rs.Read()) - sequences.Add(((string) rs[1]).ToLower().Trim()); + sequences.Add(((string) rs[0]).ToLower().Trim()); } } } Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-08 13:13:49 UTC (rev 4709) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-08 13:15:32 UTC (rev 4710) @@ -1257,6 +1257,7 @@ <Compile Include="Tools\hbm2ddl\SchemaMetadataUpdaterTest\HeavyEntity.cs" /> <Compile Include="Tools\hbm2ddl\SchemaMetadataUpdaterTest\SchemaMetadataUpdaterFixture.cs" /> <Compile Include="Tools\hbm2ddl\SchemaUpdate\MigrationFixture.cs" /> + <Compile Include="Tools\hbm2ddl\SchemaUpdate\Person.cs" /> <Compile Include="Tools\hbm2ddl\SchemaUpdate\Version.cs" /> <Compile Include="SecondLevelCacheTest\AnotherItem.cs" /> <Compile Include="SecondLevelCacheTest\Item.cs" /> @@ -2005,6 +2006,8 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="Tools\hbm2ddl\SchemaUpdate\1_Person.hbm.xml" /> + <EmbeddedResource Include="Tools\hbm2ddl\SchemaUpdate\2_Person.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1938\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1905\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1939\Mappings.hbm.xml" /> Added: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/1_Person.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/1_Person.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/1_Person.hbm.xml 2009-09-08 13:15:32 UTC (rev 4710) @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.Tools.hbm2ddl.SchemaUpdate" + assembly="NHibernate.Test"> + + <class name="Person"> + <id name="Id"> + <generator class="native"/> + </id> + <property name="Name"/> + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/2_Person.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/2_Person.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/2_Person.hbm.xml 2009-09-08 13:15:32 UTC (rev 4710) @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.Tools.hbm2ddl.SchemaUpdate" + assembly="NHibernate.Test"> + + <class name="Person"> + <id name="Id"> + <generator class="native"/> + </id> + <property name="FirstName"/> + <property name="LastName"/> + </class> + +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/MigrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/MigrationFixture.cs 2009-09-08 13:13:49 UTC (rev 4709) +++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/MigrationFixture.cs 2009-09-08 13:15:32 UTC (rev 4710) @@ -10,12 +10,9 @@ [TestFixture] public class MigrationFixture { - [Test] - public void SimpleColumnAddition() + + private void MigrateSchema(string resource1, string resource2) { - String resource2 = "NHibernate.Test.Tools.hbm2ddl.SchemaUpdate.2_Version.hbm.xml"; - String resource1 = "NHibernate.Test.Tools.hbm2ddl.SchemaUpdate.1_Version.hbm.xml"; - Configuration v1cfg = TestConfigurationHelper.GetDefaultConfiguration(); using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource1)) v1cfg.AddInputStream(stream); @@ -24,16 +21,40 @@ Tool.hbm2ddl.SchemaUpdate v1schemaUpdate = new Tool.hbm2ddl.SchemaUpdate(v1cfg); v1schemaUpdate.Execute(true, true); + foreach (Exception e in v1schemaUpdate.Exceptions) + Console.WriteLine(e); + Assert.AreEqual(0, v1schemaUpdate.Exceptions.Count); Configuration v2cfg = TestConfigurationHelper.GetDefaultConfiguration(); using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource2)) v2cfg.AddInputStream(stream); - Tool.hbm2ddl.SchemaUpdate v2schemaUpdate = new Tool.hbm2ddl.SchemaUpdate(v2cfg); v2schemaUpdate.Execute(true, true); + + foreach (Exception e in v2schemaUpdate.Exceptions) + Console.WriteLine(e); + Assert.AreEqual(0, v2schemaUpdate.Exceptions.Count); } + + [Test] + public void SimpleColumnAddition() + { + String resource2 = "NHibernate.Test.Tools.hbm2ddl.SchemaUpdate.2_Version.hbm.xml"; + String resource1 = "NHibernate.Test.Tools.hbm2ddl.SchemaUpdate.1_Version.hbm.xml"; + + MigrateSchema(resource1, resource2); + } + + [Test] + public void SimpleColumnReplace() + { + String resource2 = "NHibernate.Test.Tools.hbm2ddl.SchemaUpdate.2_Person.hbm.xml"; + String resource1 = "NHibernate.Test.Tools.hbm2ddl.SchemaUpdate.1_Person.hbm.xml"; + + MigrateSchema(resource1, resource2); + } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/Person.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/Person.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/Person.cs 2009-09-08 13:15:32 UTC (rev 4710) @@ -0,0 +1,10 @@ +namespace NHibernate.Test.Tools.hbm2ddl.SchemaUpdate +{ + public class Person + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual string FirstName { get; set; } + public virtual string LastName { get; set; } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-09-15 14:26:12
|
Revision: 4712 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4712&view=rev Author: steverstrong Date: 2009-09-15 14:26:02 +0000 (Tue, 15 Sep 2009) Log Message: ----------- Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs trunk/nhibernate/src/NHibernate/Linq/CommandData.cs trunk/nhibernate/src/NHibernate/Linq/HqlNodeStack.cs trunk/nhibernate/src/NHibernate/Linq/NhExpressionTreeVisitor.cs trunk/nhibernate/src/NHibernate/Linq/Nominator.cs trunk/nhibernate/src/NHibernate/Linq/ProjectionEvaluator.cs trunk/nhibernate/src/NHibernate/Linq/QueryModelVisitor.cs trunk/nhibernate/src/NHibernate/Linq/ResultTransformer.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs trunk/nhibernate/src/NHibernate.Test/Linq/LinqQuerySamples.cs trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Product.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/ProductCategory.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/ReadonlyTestCase.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Linq/AggregateDetectionVisitor.cs trunk/nhibernate/src/NHibernate/Linq/AggregatingGroupByRewriter.cs trunk/nhibernate/src/NHibernate/Linq/ClientSideTransformOperator.cs trunk/nhibernate/src/NHibernate/Linq/EnumerableHelper.cs trunk/nhibernate/src/NHibernate/Linq/GroupBySelectClauseVisitor.cs trunk/nhibernate/src/NHibernate/Linq/GroupBySelectorVisitor.cs trunk/nhibernate/src/NHibernate/Linq/HqlGeneratorExpressionTreeVisitor.cs trunk/nhibernate/src/NHibernate/Linq/NhThrowingExpressionTreeVisitor.cs trunk/nhibernate/src/NHibernate/Linq/NonAggregatingGroupBy.cs trunk/nhibernate/src/NHibernate/Linq/NonAggregatingGroupByRewriter.cs Property Changed: ---------------- trunk/nhibernate/src/NHibernate/Linq/ Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-09-10 18:24:03 UTC (rev 4711) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -496,11 +496,11 @@ // /////////////////////////////////////////////////////////////////////////////// - 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 ) ) ); + 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 ) { @@ -537,10 +537,10 @@ 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 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) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs 2009-09-10 18:24:03 UTC (rev 4711) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -8,7 +8,7 @@ { public class HqlTreeBuilder { - private readonly ASTFactory _factory; + private readonly IASTFactory _factory; public HqlTreeBuilder() { @@ -85,6 +85,11 @@ return new HqlIdent(_factory, ident); } + public HqlIdent Ident(System.Type type) + { + return new HqlIdent(_factory, type); + } + public HqlAlias Alias(string alias) { return new HqlAlias(_factory, alias); @@ -179,6 +184,11 @@ } } + public HqlOrderBy OrderBy() + { + return new HqlOrderBy(_factory); + } + public HqlOrderBy OrderBy(HqlTreeNode expression, HqlDirection hqlDirection) { return new HqlOrderBy(_factory, expression, hqlDirection); @@ -249,6 +259,11 @@ return new HqlGreaterThanOrEqual(_factory); } + public HqlCount Count() + { + return new HqlCount(_factory); + } + public HqlCount Count(HqlTreeNode child) { return new HqlCount(_factory, child); @@ -299,11 +314,21 @@ return new HqlMin(_factory); } + public HqlMin Min(HqlTreeNode expression) + { + return new HqlMin(_factory, expression); + } + public HqlMax Max() { return new HqlMax(_factory); } + public HqlMax Max(HqlTreeNode expression) + { + return new HqlMax(_factory, expression); + } + public HqlAnd And(HqlTreeNode left, HqlTreeNode right) { return new HqlAnd(_factory, left, right); @@ -328,5 +353,26 @@ { return new HqlElements(_factory); } + + public HqlDistinct Distinct() + { + return new HqlDistinct(_factory); + } + + public HqlDirectionAscending Ascending() + { + return new HqlDirectionAscending(_factory); + } + + public HqlDirectionDescending Descending() + { + return new HqlDirectionDescending(_factory); + } + + public HqlGroupBy GroupBy() + { + return new HqlGroupBy(_factory); + } } + } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs 2009-09-10 18:24:03 UTC (rev 4711) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -82,6 +82,13 @@ _children.Add(child); _node.AddChild(child.AstNode); } + + public void AddChild(int index, HqlTreeNode node) + { + _children.Insert(index, node); + _node.InsertChild(index, node.AstNode); + } + } public class HqlQuery : HqlTreeNode @@ -99,6 +106,41 @@ : base(HqlSqlWalker.IDENT, ident, factory) { } + + internal HqlIdent(IASTFactory factory, System.Type type) + : base(HqlSqlWalker.IDENT, "", factory) + { + if (IsNullableType(type)) + { + type = ExtractUnderlyingTypeFromNullable(type); + } + + switch (System.Type.GetTypeCode(type)) + { + case TypeCode.Int32: + _node.Text = "integer"; + break; + case TypeCode.Decimal: + _node.Text = "decimal"; + break; + case TypeCode.DateTime: + _node.Text = "datetime"; + break; + default: + throw new NotSupportedException(string.Format("Don't currently support idents of type {0}", type.Name)); + } + } + + private static System.Type ExtractUnderlyingTypeFromNullable(System.Type type) + { + return type.GetGenericArguments()[0]; + } + + private static bool IsNullableType(System.Type type) + { + return (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)); + } + } public class HqlRange : HqlTreeNode @@ -276,6 +318,11 @@ public class HqlOrderBy : HqlTreeNode { + public HqlOrderBy(IASTFactory factory) + : base(HqlSqlWalker.ORDER, "", factory) + { + } + public HqlOrderBy(IASTFactory factory, HqlTreeNode expression, HqlDirection hqlDirection) : base(HqlSqlWalker.ORDER, "", factory, expression, hqlDirection == HqlDirection.Ascending ? @@ -405,6 +452,12 @@ public class HqlCount : HqlTreeNode { + + public HqlCount(IASTFactory factory) + : base(HqlSqlWalker.COUNT, "count", factory) + { + } + public HqlCount(IASTFactory factory, HqlTreeNode child) : base(HqlSqlWalker.COUNT, "count", factory, child) { @@ -430,41 +483,9 @@ { public HqlCast(IASTFactory factory, HqlTreeNode expression, System.Type type) : base(HqlSqlWalker.METHOD_CALL, "method", factory) { - HqlIdent typeIdent; - - if (IsNullableType(type)) - { - type = ExtractUnderlyingTypeFromNullable(type); - } - - switch (System.Type.GetTypeCode(type)) - { - case TypeCode.Int32: - typeIdent = new HqlIdent(factory, "integer"); - break; - case TypeCode.Decimal: - typeIdent = new HqlIdent(factory, "decimal"); - break; - case TypeCode.DateTime: - typeIdent = new HqlIdent(factory, "datetime"); - break; - default: - throw new NotSupportedException(string.Format("Don't currently support casts to {0}", type.Name)); - } - AddChild(new HqlIdent(factory, "cast")); - AddChild(new HqlExpressionList(factory, expression, typeIdent)); + AddChild(new HqlExpressionList(factory, expression, new HqlIdent(factory, type))); } - - private static System.Type ExtractUnderlyingTypeFromNullable(System.Type type) - { - return type.GetGenericArguments()[0]; - } - - private static bool IsNullableType(System.Type type) - { - return (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)); - } } public class HqlExpressionList : HqlTreeNode @@ -518,14 +539,24 @@ public HqlMax(IASTFactory factory) : base(HqlSqlWalker.AGGREGATE, "max", factory) { } - } + public HqlMax(IASTFactory factory, HqlTreeNode expression) + : base(HqlSqlWalker.AGGREGATE, "max", factory, expression) + { + } +} + public class HqlMin : HqlTreeNode { public HqlMin(IASTFactory factory) : base(HqlSqlWalker.AGGREGATE, "min", factory) { } + + public HqlMin(IASTFactory factory, HqlTreeNode expression) + : base(HqlSqlWalker.AGGREGATE, "min", factory, expression) + { + } } public class HqlAnd : HqlTreeNode @@ -563,4 +594,18 @@ } } + public class HqlDistinct : HqlTreeNode + { + public HqlDistinct(IASTFactory factory) : base(HqlSqlWalker.DISTINCT, "distinct", factory) + { + } + } + + public class HqlGroupBy : HqlTreeNode + { + public HqlGroupBy(IASTFactory factory) : base(HqlSqlWalker.GROUP, "group by", factory) + { + } + } + } \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate/Linq ___________________________________________________________________ Added: svn:ignore + _ReSharper.TempSolution Added: trunk/nhibernate/src/NHibernate/Linq/AggregateDetectionVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/AggregateDetectionVisitor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/AggregateDetectionVisitor.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -0,0 +1,54 @@ +using System.Linq; +using System.Linq.Expressions; +using Remotion.Data.Linq.Clauses.Expressions; +using Remotion.Data.Linq.Clauses.ResultOperators; +using Remotion.Data.Linq.Parsing; + +namespace NHibernate.Linq +{ + // TODO: This needs strengthening. For example, it doesn't recurse into SubQueries at present + internal class AggregateDetectionVisitor : ExpressionTreeVisitor + { + public bool ContainsAggregateMethods { get; private set; } + + public bool Visit(Expression expression) + { + ContainsAggregateMethods = false; + + VisitExpression(expression); + + return ContainsAggregateMethods; + } + + protected override Expression VisitMethodCallExpression(MethodCallExpression m) + { + if (m.Method.DeclaringType == typeof (Queryable) || + m.Method.DeclaringType == typeof (Enumerable)) + { + switch (m.Method.Name) + { + case "Count": + case "Min": + case "Max": + case "Sum": + case "Average": + ContainsAggregateMethods = true; + break; + } + } + + return base.VisitMethodCallExpression(m); + } + + protected override Expression VisitSubQueryExpression(SubQueryExpression expression) + { + if (expression.QueryModel.ResultOperators.Count == 1 + && typeof(ValueFromSequenceResultOperatorBase).IsAssignableFrom(expression.QueryModel.ResultOperators[0].GetType())) + { + ContainsAggregateMethods = true; + } + + return base.VisitSubQueryExpression(expression); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/AggregatingGroupByRewriter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/AggregatingGroupByRewriter.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/AggregatingGroupByRewriter.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -0,0 +1,57 @@ +using System; +using System.Linq; +using Remotion.Data.Linq; +using Remotion.Data.Linq.Clauses; +using Remotion.Data.Linq.Clauses.Expressions; +using Remotion.Data.Linq.Clauses.ResultOperators; + +namespace NHibernate.Linq +{ + public class AggregatingGroupByRewriter : QueryModelVisitorBase + { + public override void VisitMainFromClause(MainFromClause fromClause, QueryModel queryModel) + { + var subQueryExpression = fromClause.FromExpression as SubQueryExpression; + + if ((subQueryExpression != null) && + (subQueryExpression.QueryModel.ResultOperators.Count() == 1) && + (subQueryExpression.QueryModel.ResultOperators[0] is GroupResultOperator) && + (IsAggregatingGroupBy(queryModel))) + { + FlattenSubQuery(subQueryExpression, fromClause, queryModel); + } + + base.VisitMainFromClause(fromClause, queryModel); + } + + private static bool IsAggregatingGroupBy(QueryModel queryModel) + { + return new AggregateDetectionVisitor().Visit(queryModel.SelectClause.Selector); + } + + private void FlattenSubQuery(SubQueryExpression subQueryExpression, FromClauseBase fromClause, + QueryModel queryModel) + { + // Replace the outer select clause... + queryModel.SelectClause.TransformExpressions(GroupBySelectClauseVisitor.Visit); + + MainFromClause innerMainFromClause = subQueryExpression.QueryModel.MainFromClause; + CopyFromClauseData(innerMainFromClause, fromClause); + + // Move the result operator up + if (queryModel.ResultOperators.Count != 0) + { + throw new NotImplementedException(); + } + + queryModel.ResultOperators.Add(subQueryExpression.QueryModel.ResultOperators[0]); + } + + protected void CopyFromClauseData(FromClauseBase source, FromClauseBase destination) + { + destination.FromExpression = source.FromExpression; + destination.ItemName = source.ItemName; + destination.ItemType = source.ItemType; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/ClientSideTransformOperator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/ClientSideTransformOperator.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/ClientSideTransformOperator.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -0,0 +1,24 @@ +using System; +using Remotion.Data.Linq.Clauses; +using Remotion.Data.Linq.Clauses.StreamedData; + +namespace NHibernate.Linq +{ + public class ClientSideTransformOperator : ResultOperatorBase + { + public override IStreamedData ExecuteInMemory(IStreamedData input) + { + throw new NotImplementedException(); + } + + public override IStreamedDataInfo GetOutputDataInfo(IStreamedDataInfo inputInfo) + { + throw new NotImplementedException(); + } + + public override ResultOperatorBase Clone(CloneContext cloneContext) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/CommandData.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/CommandData.cs 2009-09-10 18:24:03 UTC (rev 4711) +++ trunk/nhibernate/src/NHibernate/Linq/CommandData.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Linq.Expressions; using NHibernate.Hql.Ast; @@ -7,37 +8,83 @@ { public class CommandData { - public CommandData(HqlQuery statement, NamedParameter[] namedParameters, LambdaExpression projectionExpression, List<Action<IQuery>> additionalCriteria) + private readonly List<LambdaExpression> _itemTransformers; + private readonly List<LambdaExpression> _listTransformers; + + public CommandData(HqlQuery statement, NamedParameter[] namedParameters, List<LambdaExpression> itemTransformers, List<LambdaExpression> listTransformers, List<Action<IQuery>> additionalCriteria) { + _itemTransformers = itemTransformers; + _listTransformers = listTransformers; + Statement = statement; NamedParameters = namedParameters; - ProjectionExpression = projectionExpression; AdditionalCriteria = additionalCriteria; } public HqlQuery Statement { get; private set; } public NamedParameter[] NamedParameters { get; private set; } - public LambdaExpression ProjectionExpression { get; set; } + public List<Action<IQuery>> AdditionalCriteria { get; set; } + public System.Type QueryResultType { get; set; } + public IQuery CreateQuery(ISession session, System.Type type) { var query = session.CreateQuery(new HqlExpression(Statement, type)); + SetParameters(query); + + SetResultTransformer(query); + + AddAdditionalCriteria(query); + + return query; + } + + private void SetParameters(IQuery query) + { foreach (var parameter in NamedParameters) + { query.SetParameter(parameter.Name, parameter.Value); - - if (ProjectionExpression != null) - { - query.SetResultTransformer(new ResultTransformer(ProjectionExpression)); } + } + private void AddAdditionalCriteria(IQuery query) + { foreach (var criteria in AdditionalCriteria) { criteria(query); } + } - return query; + private void SetResultTransformer(IQuery query) + { + var itemTransformer = MergeLambdas(_itemTransformers); + var listTransformer = MergeLambdas(_listTransformers); + + if (itemTransformer != null || listTransformer != null) + { + query.SetResultTransformer(new ResultTransformer(itemTransformer, listTransformer)); + } } + + private static LambdaExpression MergeLambdas(IList<LambdaExpression> transformations) + { + if (transformations == null || transformations.Count == 0) + { + return null; + } + + var listTransformLambda = transformations[0]; + + for (int i = 1; i < transformations.Count; i++) + { + var invoked = Expression.Invoke(transformations[i], listTransformLambda.Body); + + listTransformLambda = Expression.Lambda(invoked, listTransformLambda.Parameters.ToArray()); + } + + return listTransformLambda; + } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/EnumerableHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/EnumerableHelper.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/EnumerableHelper.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -0,0 +1,53 @@ +using System.Linq; +using System.Reflection; + +namespace NHibernate.Linq +{ + public static class EnumerableHelper + { + public static MethodInfo GetMethod(string name, System.Type[] parameterTypes) + { + return typeof(Enumerable).GetMethods(BindingFlags.Static | BindingFlags.Public) + .Where(m => m.Name == name && + ParameterTypesMatch(m.GetParameters(), parameterTypes)) + .Single(); + } + + public static MethodInfo GetMethod(string name, System.Type[] parameterTypes, System.Type[] genericTypeParameters) + { + return typeof(Enumerable).GetMethods(BindingFlags.Static | BindingFlags.Public) + .Where(m => m.Name == name && + m.ContainsGenericParameters && + m.GetGenericArguments().Count() == genericTypeParameters.Length && + ParameterTypesMatch(m.GetParameters(), parameterTypes)) + .Single() + .MakeGenericMethod(genericTypeParameters); + } + + private static bool ParameterTypesMatch(ParameterInfo[] parameters, System.Type[] types) + { + if (parameters.Length != types.Length) + { + return false; + } + + for (int i = 0; i < parameters.Length; i++) + { + if (parameters[i].ParameterType == types[i]) + { + continue; + } + + if (parameters[i].ParameterType.ContainsGenericParameters && types[i].ContainsGenericParameters && + parameters[i].ParameterType.GetGenericArguments().Length == types[i].GetGenericArguments().Length) + { + continue; + } + + return false; + } + + return true; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/GroupBySelectClauseVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/GroupBySelectClauseVisitor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/GroupBySelectClauseVisitor.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using Remotion.Data.Linq.Clauses; +using Remotion.Data.Linq.Clauses.Expressions; +using Remotion.Data.Linq.Clauses.ResultOperators; +using Remotion.Data.Linq.Parsing; + +namespace NHibernate.Linq +{ + internal class GroupBySelectClauseVisitor : ExpressionTreeVisitor + { + public static Expression Visit(Expression expression) + { + var visitor = new GroupBySelectClauseVisitor(); + return visitor.VisitExpression(expression); + } + + protected override Expression VisitMemberExpression(MemberExpression expression) + { + if (expression.Member.Name == "Key" && + expression.Member.DeclaringType.GetGenericTypeDefinition() == typeof (IGrouping<,>)) + { + var querySourceRef = expression.Expression as QuerySourceReferenceExpression; + + var fromClause = querySourceRef.ReferencedQuerySource as FromClauseBase; + + var subQuery = fromClause.FromExpression as SubQueryExpression; + + var groupBy = + subQuery.QueryModel.ResultOperators.Where(r => r is GroupResultOperator).Single() as + GroupResultOperator; + + return groupBy.KeySelector; + } + else + { + return base.VisitMemberExpression(expression); + } + } + + protected override Expression VisitSubQueryExpression(SubQueryExpression expression) + { + if (expression.QueryModel.ResultOperators.Count == 1) + { + ResultOperatorBase resultOperator = expression.QueryModel.ResultOperators[0]; + + if (resultOperator is AverageResultOperator) + { + return new AverageExpression(expression.QueryModel.SelectClause.Selector); + } + else if (resultOperator is MinResultOperator) + { + return new MinExpression(expression.QueryModel.SelectClause.Selector); + } + else if (resultOperator is MaxResultOperator) + { + return new MaxExpression(expression.QueryModel.SelectClause.Selector); + } + else if (resultOperator is CountResultOperator) + { + return new CountExpression(); + } + else if (resultOperator is SumResultOperator) + { + return new SumExpression(expression.QueryModel.SelectClause.Selector); + } + else + { + throw new NotImplementedException(); + } + } + else + { + return base.VisitSubQueryExpression(expression); + } + } + } + + public enum NhExpressionType + { + Average = 10000, + Min, + Max, + Sum, + Count, + Distinct + } + + public class NhAggregatedExpression : Expression + { + public Expression Expression { get; set; } + + public NhAggregatedExpression(Expression expression, NhExpressionType type) + : base((ExpressionType)type, expression.Type) + { + Expression = expression; + } + } + + public class AverageExpression : NhAggregatedExpression + { + public AverageExpression(Expression expression) : base(expression, NhExpressionType.Average) + { + } + } + + public class MinExpression : NhAggregatedExpression + { + public MinExpression(Expression expression) + : base(expression, NhExpressionType.Min) + { + } + } + + public class MaxExpression : NhAggregatedExpression + { + public MaxExpression(Expression expression) + : base(expression, NhExpressionType.Max) + { + } + } + + public class SumExpression : NhAggregatedExpression + { + public SumExpression(Expression expression) + : base(expression, NhExpressionType.Sum) + { + } + } + + public class DistinctExpression : NhAggregatedExpression + { + public DistinctExpression(Expression expression) + : base(expression, NhExpressionType.Distinct) + { + } + } + + public class CountExpression : Expression + { + public CountExpression() + : base((ExpressionType)NhExpressionType.Count, typeof(int)) + { + } + } +} Added: trunk/nhibernate/src/NHibernate/Linq/GroupBySelectorVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/GroupBySelectorVisitor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/GroupBySelectorVisitor.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -0,0 +1,26 @@ +using System.Linq.Expressions; +using Remotion.Data.Linq.Clauses.Expressions; +using Remotion.Data.Linq.Parsing; + +namespace NHibernate.Linq +{ + internal class GroupBySelectorVisitor : ExpressionTreeVisitor + { + private readonly ParameterExpression _parameter; + + public GroupBySelectorVisitor(ParameterExpression parameter) + { + _parameter = parameter; + } + + public Expression Visit(Expression expression) + { + return VisitExpression(expression); + } + + protected override Expression VisitQuerySourceReferenceExpression(QuerySourceReferenceExpression expression) + { + return _parameter; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/HqlGeneratorExpressionTreeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/HqlGeneratorExpressionTreeVisitor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/HqlGeneratorExpressionTreeVisitor.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -0,0 +1,353 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using NHibernate.Hql.Ast; +using Remotion.Data.Linq.Clauses.Expressions; +using Remotion.Data.Linq.Clauses.ExpressionTreeVisitors; + +namespace NHibernate.Linq +{ + public class HqlGeneratorExpressionTreeVisitor : NhThrowingExpressionTreeVisitor + { + protected readonly HqlTreeBuilder _hqlTreeBuilder; + protected readonly HqlNodeStack _stack; + private readonly ParameterAggregator _parameterAggregator; + + public HqlGeneratorExpressionTreeVisitor(ParameterAggregator parameterAggregator) + { + _parameterAggregator = parameterAggregator; + _hqlTreeBuilder = new HqlTreeBuilder(); + _stack = new HqlNodeStack(_hqlTreeBuilder); + } + + public IEnumerable<HqlTreeNode> GetHqlTreeNodes() + { + return _stack.Finish(); + } + + public virtual void Visit(Expression expression) + { + VisitExpression(expression); + } + + protected override Expression VisitNhAverage(AverageExpression expression) + { + var visitor = new HqlGeneratorExpressionTreeVisitor(_parameterAggregator); + visitor.Visit(expression.Expression); + + _stack.PushLeaf(_hqlTreeBuilder.Cast(_hqlTreeBuilder.Average(visitor.GetHqlTreeNodes().Single()), expression.Type)); + + return expression; + } + + protected override Expression VisitNhCount(CountExpression expression) + { + _stack.PushLeaf(_hqlTreeBuilder.Cast(_hqlTreeBuilder.Count(_hqlTreeBuilder.RowStar()), expression.Type)); + + return expression; + } + + protected override Expression VisitNhMin(MinExpression expression) + { + var visitor = new HqlGeneratorExpressionTreeVisitor(_parameterAggregator); + visitor.Visit(expression.Expression); + + _stack.PushLeaf(_hqlTreeBuilder.Cast(_hqlTreeBuilder.Min(visitor.GetHqlTreeNodes().Single()), expression.Type)); + + return expression; + } + + protected override Expression VisitNhMax(MaxExpression expression) + { + var visitor = new HqlGeneratorExpressionTreeVisitor(_parameterAggregator); + visitor.Visit(expression.Expression); + + _stack.PushLeaf(_hqlTreeBuilder.Cast(_hqlTreeBuilder.Max(visitor.GetHqlTreeNodes().Single()), expression.Type)); + + return expression; + } + + protected override Expression VisitNhSum(SumExpression expression) + { + var visitor = new HqlGeneratorExpressionTreeVisitor(_parameterAggregator); + visitor.Visit(expression.Expression); + + _stack.PushLeaf(_hqlTreeBuilder.Cast(_hqlTreeBuilder.Sum(visitor.GetHqlTreeNodes().Single()), expression.Type)); + + return expression; + } + + protected override Expression VisitNhDistinct(DistinctExpression expression) + { + var visitor = new HqlGeneratorExpressionTreeVisitor(_parameterAggregator); + visitor.Visit(expression.Expression); + + _stack.PushLeaf(_hqlTreeBuilder.Distinct()); + + foreach (var node in visitor.GetHqlTreeNodes()) + { + _stack.PushLeaf(node); + } + + return expression; + } + + protected override Expression VisitQuerySourceReferenceExpression(QuerySourceReferenceExpression expression) + { + _stack.PushLeaf(_hqlTreeBuilder.Ident(expression.ReferencedQuerySource.ItemName)); + + return expression; + } + + protected override Expression VisitBinaryExpression(BinaryExpression expression) + { + HqlTreeNode operatorNode = GetHqlOperatorNodeForBinaryOperator(expression); + + using (_stack.PushNode(operatorNode)) + { + VisitExpression(expression.Left); + + VisitExpression(expression.Right); + } + + return expression; + } + + private HqlTreeNode GetHqlOperatorNodeForBinaryOperator(BinaryExpression expression) + { + switch (expression.NodeType) + { + case ExpressionType.Equal: + return _hqlTreeBuilder.Equality(); + + case ExpressionType.NotEqual: + return _hqlTreeBuilder.Inequality(); + + case ExpressionType.And: + case ExpressionType.AndAlso: + return _hqlTreeBuilder.BooleanAnd(); + + case ExpressionType.Or: + case ExpressionType.OrElse: + return _hqlTreeBuilder.BooleanOr(); + + case ExpressionType.Add: + return _hqlTreeBuilder.Add(); + + case ExpressionType.Subtract: + return _hqlTreeBuilder.Subtract(); + + case ExpressionType.Multiply: + return _hqlTreeBuilder.Multiply(); + + case ExpressionType.Divide: + return _hqlTreeBuilder.Divide(); + + case ExpressionType.LessThan: + return _hqlTreeBuilder.LessThan(); + + case ExpressionType.LessThanOrEqual: + return _hqlTreeBuilder.LessThanOrEqual(); + + case ExpressionType.GreaterThan: + return _hqlTreeBuilder.GreaterThan(); + + case ExpressionType.GreaterThanOrEqual: + return _hqlTreeBuilder.GreaterThanOrEqual(); + } + + throw new InvalidOperationException(); + } + + protected override Expression VisitUnaryExpression(UnaryExpression expression) + { + HqlTreeNode operatorNode = GetHqlOperatorNodeforUnaryOperator(expression); + + using (_stack.PushNode(operatorNode)) + { + VisitExpression(expression.Operand); + } + + return expression; + } + + private HqlTreeNode GetHqlOperatorNodeforUnaryOperator(UnaryExpression expression) + { + switch (expression.NodeType) + { + case ExpressionType.Not: + return _hqlTreeBuilder.Not(); + } + + throw new InvalidOperationException(); + } + + protected override Expression VisitMemberExpression(MemberExpression expression) + { + using (_stack.PushNode(_hqlTreeBuilder.Dot())) + { + Expression newExpression = VisitExpression(expression.Expression); + + _stack.PushLeaf(_hqlTreeBuilder.Ident(expression.Member.Name)); + + if (newExpression != expression.Expression) + { + return Expression.MakeMemberAccess(newExpression, expression.Member); + } + } + + return expression; + } + + protected override Expression VisitConstantExpression(ConstantExpression expression) + { + if (expression.Value != null) + { + System.Type t = expression.Value.GetType(); + + if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof (NhQueryable<>)) + { + _stack.PushLeaf(_hqlTreeBuilder.Ident(t.GetGenericArguments()[0].Name)); + return expression; + } + } + + /* + var namedParameter = _parameterAggregator.AddParameter(expression.Value); + + _expression = _hqlTreeBuilder.Parameter(namedParameter.Name); + + return expression; + */ + // TODO - get parameter support in place in the HQLQueryPlan + _stack.PushLeaf(_hqlTreeBuilder.Constant(expression.Value)); + + return expression; + } + + protected override Expression VisitMethodCallExpression(MethodCallExpression expression) + { + if (expression.Method.DeclaringType == typeof(Enumerable) || + expression.Method.DeclaringType == typeof(Queryable)) + { + switch (expression.Method.Name) + { + case "Any": + // Any has one or two arguments. Arg 1 is the source and arg 2 is the optional predicate + using (_stack.PushNode(_hqlTreeBuilder.Exists())) + { + using (_stack.PushNode(_hqlTreeBuilder.Query())) + { + using (_stack.PushNode(_hqlTreeBuilder.SelectFrom())) + { + using (_stack.PushNode(_hqlTreeBuilder.From())) + { + using (_stack.PushNode(_hqlTreeBuilder.Range())) + { + VisitExpression(expression.Arguments[0]); + + if (expression.Arguments.Count > 1) + { + var expr = (LambdaExpression) expression.Arguments[1]; + _stack.PushLeaf(_hqlTreeBuilder.Alias(expr.Parameters[0].Name)); + } + } + } + } + if (expression.Arguments.Count > 1) + { + using (_stack.PushNode(_hqlTreeBuilder.Where())) + { + VisitExpression(expression.Arguments[1]); + } + } + } + } + break; + case "Min": + using (_stack.PushNode(_hqlTreeBuilder.Min())) + { + VisitExpression(expression.Arguments[1]); + } + break; + case "Max": + using (_stack.PushNode(_hqlTreeBuilder.Max())) + { + VisitExpression(expression.Arguments[1]); + } + break; + default: + throw new NotSupportedException(string.Format("The Enumerable method {0} is not supported", expression.Method.Name)); + } + + return expression; + } + else + { + return base.VisitMethodCallExpression(expression); // throws + } + } + + protected override Expression VisitLambdaExpression(LambdaExpression expression) + { + VisitExpression(expression.Body); + + return expression; + } + + protected override Expression VisitParameterExpression(ParameterExpression expression) + { + _stack.PushLeaf(_hqlTreeBuilder.Ident(expression.Name)); + + return expression; + } + + protected override Expression VisitConditionalExpression(ConditionalExpression expression) + { + using (_stack.PushNode(_hqlTreeBuilder.Case())) + { + using (_stack.PushNode(_hqlTreeBuilder.When())) + { + VisitExpression(expression.Test); + + VisitExpression(expression.IfTrue); + } + + if (expression.IfFalse != null) + { + using (_stack.PushNode(_hqlTreeBuilder.Else())) + { + VisitExpression(expression.IfFalse); + } + } + } + + return expression; + } + + protected override Expression VisitSubQueryExpression(SubQueryExpression expression) + { + CommandData query = QueryModelVisitor.GenerateHqlQuery(expression.QueryModel, _parameterAggregator); + + _stack.PushLeaf(query.Statement); + + return expression; + } + + + // Called when a LINQ expression type is not handled above. + protected override Exception CreateUnhandledItemException<T>(T unhandledItem, string visitMethod) + { + string itemText = FormatUnhandledItem(unhandledItem); + var message = string.Format("The expression '{0}' (type: {1}) is not supported by this LINQ provider.", itemText, typeof(T)); + return new NotSupportedException(message); + } + + private string FormatUnhandledItem<T>(T unhandledItem) + { + var itemAsExpression = unhandledItem as Expression; + return itemAsExpression != null ? FormattingExpressionTreeVisitor.Format(itemAsExpression) : unhandledItem.ToString(); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/HqlNodeStack.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/HqlNodeStack.cs 2009-09-10 18:24:03 UTC (rev 4711) +++ trunk/nhibernate/src/NHibernate/Linq/HqlNodeStack.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -27,12 +27,12 @@ return holder.Children; } - public void PushAndPop(HqlTreeNode query) + public void PushLeaf(HqlTreeNode query) { - Push(query).Dispose(); + PushNode(query).Dispose(); } - public IDisposable Push(HqlTreeNode query) + public IDisposable PushNode(HqlTreeNode query) { _stack.Peek().AddChild(query); Modified: trunk/nhibernate/src/NHibernate/Linq/NhExpressionTreeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/NhExpressionTreeVisitor.cs 2009-09-10 18:24:03 UTC (rev 4711) +++ trunk/nhibernate/src/NHibernate/Linq/NhExpressionTreeVisitor.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -1,286 +1,69 @@ -using System; -using System.Collections.Generic; -using System.Linq; using System.Linq.Expressions; -using NHibernate.Hql.Ast; -using Remotion.Data.Linq.Clauses.Expressions; -using Remotion.Data.Linq.Clauses.ExpressionTreeVisitors; using Remotion.Data.Linq.Parsing; namespace NHibernate.Linq { - public class NhExpressionTreeVisitor : ThrowingExpressionTreeVisitor + public class NhExpressionTreeVisitor : ExpressionTreeVisitor { - protected readonly HqlTreeBuilder _hqlTreeBuilder; - protected readonly HqlNodeStack _stack; - private readonly ParameterAggregator _parameterAggregator; - - public NhExpressionTreeVisitor(ParameterAggregator parameterAggregator) + protected override Expression VisitExpression(Expression expression) { - _parameterAggregator = parameterAggregator; - _hqlTreeBuilder = new HqlTreeBuilder(); - _stack = new HqlNodeStack(_hqlTreeBuilder); - } - - public IEnumerable<HqlTreeNode> GetAstBuilderNode() - { - return _stack.Finish(); - } - - public virtual void Visit(Expression expression) - { - VisitExpression(expression); - } - - protected override Expression VisitQuerySourceReferenceExpression(QuerySourceReferenceExpression expression) - { - _stack.PushAndPop(_hqlTreeBuilder.Ident(expression.ReferencedQuerySource.ItemName)); - - return expression; - } - - protected override Expression VisitBinaryExpression(BinaryExpression expression) - { - HqlTreeNode operatorNode = GetHqlOperatorNodeForBinaryOperator(expression); - - using (_stack.Push(operatorNode)) + switch ((NhExpressionType) expression.NodeType) { - VisitExpression(expression.Left); - - VisitExpression(expression.Right); + case NhExpressionType.Average: + return VisitNhAverage((AverageExpression) expression); + case NhExpressionType.Min: + return VisitNhMin((MinExpression)expression); + case NhExpressionType.Max: + return VisitNhMax((MaxExpression)expression); + case NhExpressionType.Sum: + return VisitNhSum((SumExpression)expression); + case NhExpressionType.Count: + return VisitNhCount((CountExpression)expression); + case NhExpressionType.Distinct: + return VisitNhDistinct((DistinctExpression) expression); } - return expression; + return base.VisitExpression(expression); } - private HqlTreeNode GetHqlOperatorNodeForBinaryOperator(BinaryExpression expression) + protected virtual Expression VisitNhDistinct(DistinctExpression expression) { - switch (expression.NodeType) - { - case ExpressionType.Equal: - return _hqlTreeBuilder.Equality(); + Expression nx = base.VisitExpression(expression.Expression); - case ExpressionType.NotEqual: - return _hqlTreeBuilder.Inequality(); - - case ExpressionType.And: - case ExpressionType.AndAlso: - return _hqlTreeBuilder.BooleanAnd(); - - case ExpressionType.Or: - case ExpressionType.OrElse: - return _hqlTreeBuilder.BooleanOr(); - - case ExpressionType.Add: - return _hqlTreeBuilder.Add(); - - case ExpressionType.Subtract: - return _hqlTreeBuilder.Subtract(); - - case ExpressionType.Multiply: - return _hqlTreeBuilder.Multiply(); - - case ExpressionType.Divide: - return _hqlTreeBuilder.Divide(); - - case ExpressionType.LessThan: - return _hqlTreeBuilder.LessThan(); - - case ExpressionType.LessThanOrEqual: - return _hqlTreeBuilder.LessThanOrEqual(); - - case ExpressionType.GreaterThan: - return _hqlTreeBuilder.GreaterThan(); - - case ExpressionType.GreaterThanOrEqual: - return _hqlTreeBuilder.GreaterThanOrEqual(); - } - - throw new InvalidOperationException(); + return nx != expression.Expression ? new DistinctExpression(nx) : expression; } - protected override Expression VisitUnaryExpression(UnaryExpression expression) + protected virtual Expression VisitNhCount(CountExpression expression) { - HqlTreeNode operatorNode = GetHqlOperatorNodeforUnaryOperator(expression); - - using (_stack.Push(operatorNode)) - { - VisitExpression(expression.Operand); - } - return expression; } - private HqlTreeNode GetHqlOperatorNodeforUnaryOperator(UnaryExpression expression) + protected virtual Expression VisitNhSum(SumExpression expression) { - switch (expression.NodeType) - { - case ExpressionType.Not: - return _hqlTreeBuilder.Not(); - } - - throw new InvalidOperationException(); - } + Expression nx = base.VisitExpression(expression.Expression); - protected override Expression VisitMemberExpression(MemberExpression expression) - { - using (_stack.Push(_hqlTreeBuilder.Dot())) - { - Expression newExpression = VisitExpression(expression.Expression); - - _stack.PushAndPop(_hqlTreeBuilder.Ident(expression.Member.Name)); - - if (newExpression != expression.Expression) - { - return Expression.MakeMemberAccess(newExpression, expression.Member); - } - } - - return expression; + return nx != expression.Expression ? new SumExpression(nx) : expression; } - protected override Expression VisitConstantExpression(ConstantExpression expression) + protected virtual Expression VisitNhMax(MaxExpression expression) { - if (expression.Value != null) - { - System.Type t = expression.Value.GetType(); + Expression nx = base.VisitExpression(expression.Expression); - if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof (NhQueryable<>)) - { - _stack.PushAndPop(_hqlTreeBuilder.Ident(t.GetGenericArguments()[0].Name)); - return expression; - } - } - - /* - var namedParameter = _parameterAggregator.AddParameter(expression.Value); - - _expression = _hqlTreeBuilder.Parameter(namedParameter.Name); - - return expression; - */ - // TODO - get parameter support in place in the HQLQueryPlan - _stack.PushAndPop(_hqlTreeBuilder.Constant(expression.Value)); - - return expression; + return nx != expression.Expression ? new MaxExpression(nx) : expression; } - protected override Expression VisitMethodCallExpression(MethodCallExpression expression) + protected virtual Expression VisitNhMin(MinExpression expression) { - if (expression.Method.DeclaringType == typeof(Enumerable)) - { - switch (expression.Method.Name) - { - case "Any": - // Any has one or two arguments. Arg 1 is the source and arg 2 is the optional predicate - using (_stack.Push(_hqlTreeBuilder.Exists())) - { - using (_stack.Push(_hqlTreeBuilder.Query())) - { - using (_stack.Push(_hqlTreeBuilder.SelectFrom())) - { - using (_stack.Push(_hqlTreeBuilder.From())) - { - using (_stack.Push(_hqlTreeBuilder.Range())) - { - VisitExpression(expression.Arguments[0]); + Expression nx = base.VisitExpression(expression.Expression); - if (expression.Arguments.Count > 1) - { - var expr = (LambdaExpression) expression.Arguments[1]; - _stack.PushAndPop(_hqlTreeBuilder.Alias(expr.Parameters[0].Name)); - } - } - } - } - if (expression.Arguments.Count > 1) - { - using (_stack.Push(_hqlTreeBuilder.Where())) - { - VisitExpression(expression.Arguments[1]); - } - } - } - } - break; - default: - throw new NotSupportedException(string.Format("The Enumerable method {0} is not supported", expression.Method.Name)); - } - - return expression; - } - else - { - return base.VisitMethodCallExpression(expression); // throws - } + return nx != expression.Expression ? new MinExpression(nx) : expression; } - protected override Expression VisitLambdaExpression(LambdaExpression expression) + protected virtual Expression VisitNhAverage(AverageExpression expression) { - VisitExpression(expression.Body); + Expression nx = base.VisitExpression(expression.Expression); - return expression; + return nx != expression.Expression ? new AverageExpression(nx) : expression; } - - protected override Expression VisitParameterExpression(ParameterExpression expression) - { - _stack.PushAndPop(_hqlTreeBuilder.Ident(expression.Name)); - - return expression; - } - - protected override Expression VisitConditionalExpression(ConditionalExpression expression) - { - using (_stack.Push(_hqlTreeBuilder.Case())) - { - using (_stack.Push(_hqlTreeBuilder.When())) - { - VisitExpression(expression.Test); - - VisitExpression(expression.IfTrue); - } - - if (expression.IfFalse != null) - { - using (_stack.Push(_hqlTreeBuilder.Else())) - { - VisitExpression(expression.IfFalse); - } - } - } - - return expression; - } - - protected override Expression VisitSubQueryExpression(SubQueryExpression expression) - { - CommandData query = QueryModelVisitor.GenerateHqlQuery(expression.QueryModel, _parameterAggregator); - - if (query.ProjectionExpression != null) - { - throw new InvalidOperationException(); - } - - // TODO - what if there was a projection expression? - - _stack.PushAndPop(query.Statement); - - return expression; - } - - - // Called when a LINQ expression type is not handled above. - protected override Exception CreateUnhandledItemException<T>(T unhandledItem, string visitMethod) - { - string itemText = FormatUnhandledItem(unhandledItem); - var message = string.Format("The expression '{0}' (type: {1}) is not supported by this LINQ provider.", itemText, typeof(T)); - return new NotSupportedException(message); - } - - private string FormatUnhandledItem<T>(T unhandledItem) - { - var itemAsExpression = unhandledItem as Expression; - return itemAsExpression != null ? FormattingExpressionTreeVisitor.Format(itemAsExpression) : unhandledItem.ToString(); - } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/NhThrowingExpressionTreeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/NhThrowingExpressionTreeVisitor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/NhThrowingExpressionTreeVisitor.cs 2009-09-15 14:26:02 UTC (rev 4712) @@ -0,0 +1,101 @@ +using System; +using System.Linq.Expressions; +using Remotion.Data.Linq.Parsing; + +namespace NHibernate.Linq +{ + public abstract class NhThrowingExpressionTreeVisitor : ThrowingExpressionTreeVisitor + { + protected override Expression VisitExpression(Expression expression) + { + switch ((NhExpressionType)expression.NodeType) + { + case NhExpressionType.Average: + return VisitNhAverage((AverageExpression)expression); + case NhExpressionType.Min: + return VisitNhMin((MinExpression)expression); + case NhExpressionType.Max: + return VisitNhMax((MaxExpression)expression); + case NhExpressionType.Sum: + return VisitNhSum((SumExpression)expression); + case NhExpressionType.Count: + return VisitNhCount((CountExpression)expression); + case NhExpressionType.Distinct: + return VisitNhDistinct((DistinctExpression) expression); + } + + return base.VisitExpression(expression); + } + + protected virtual Expression VisitNhDistinct(DistinctExpression expression) + { + return VisitUnhandledItem<DistinctExpression, Expression>(expression, "VisitNhDistinct", BaseVisitNhDistinct); + } + + protected virtual Expression VisitNhAverage(AverageExpression expression) + { + return VisitUnhandledItem<AverageExpression, Expression>(expression, "VisitNhAverage", BaseVisitNhAverage); + } + + protected virtual Expression VisitNhMin(MinExpression expression) + { + return VisitUnhandledItem<MinExpression, Expression>(expression, "VisitNhMin", BaseVisitNhMin); + } + + protected virtual Expression VisitNhMax(MaxExpression expression) + { + return VisitUnhandledItem<MaxExpression, Expression>(expression, "VisitNhMax", BaseVisitNhMax); + } + + protected virtual Expression VisitNhSum(SumExpression expression) + { + return VisitUnhandledItem<SumExpression, Expression>(expression, "VisitNhSum", BaseVisitNhSum); + } + + protected virtual Expression VisitNhCount(CountEx... [truncated message content] |
From: <ric...@us...> - 2009-09-15 21:41:10
|
Revision: 4714 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4714&view=rev Author: ricbrown Date: 2009-09-15 21:41:03 +0000 (Tue, 15 Sep 2009) Log Message: ----------- Merge r4713 (Simplify filter parameter reordering and possible fix for NH-1908 threading issue.) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Model.cs Modified: trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2009-09-15 21:39:54 UTC (rev 4713) +++ trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2009-09-15 21:41:03 UTC (rev 4714) @@ -39,6 +39,7 @@ private object _optionalId; private string _comment; private bool _readOnly; + private IDictionary<int, int> _adjustedParameterLocations; private SqlString processedSQL; @@ -286,15 +287,12 @@ /************** Filters ********************************/ - private void AdjustPostionalParameterLocations(int parameterIndex) + public int FindAdjustedParameterLocation(int parameterIndex) { - for (int i = 0; i < _positionalParameterLocations.Length; i++) - { - if (_positionalParameterLocations[i] >= parameterIndex) - { - _positionalParameterLocations[i]++; - } - } + if (_adjustedParameterLocations == null) + return parameterIndex; + + return _adjustedParameterLocations[parameterIndex]; } public void ProcessFilters(SqlString sql, ISessionImplementor session) @@ -314,7 +312,9 @@ var result = new SqlStringBuilder(); - int parameterIndex = 0; // keep track of the positional parameter + int originalParameterIndex = 0; // keep track of the positional parameter + int newParameterIndex = 0; + _adjustedParameterLocations = new Dictionary<int, int>(); foreach (var part in sql.Parts) { @@ -329,7 +329,9 @@ // types for the named parameters are added later to the end of the list. // see test fixture NH-1098 - parameterIndex++; + _adjustedParameterLocations[originalParameterIndex] = newParameterIndex; + originalParameterIndex++; + newParameterIndex++; continue; } @@ -358,9 +360,8 @@ result.AddParameter(); filteredParameterTypes.Add(type); filteredParameterValues.Add(elementValue); - filteredParameterLocations.Add(parameterIndex); - AdjustPostionalParameterLocations(parameterIndex); - parameterIndex++; + filteredParameterLocations.Add(newParameterIndex); + newParameterIndex++; if (i < coll.Count) { result.Add(", "); @@ -376,9 +377,8 @@ result.AddParameter(); filteredParameterTypes.Add(type); filteredParameterValues.Add(value); - filteredParameterLocations.Add(parameterIndex); - AdjustPostionalParameterLocations(parameterIndex); - parameterIndex++; + filteredParameterLocations.Add(newParameterIndex); + newParameterIndex++; } } } @@ -401,7 +401,7 @@ for (int i = 0; i < _positionalParameterLocations.Length; i++) { - int location = _positionalParameterLocations[i]; + int location = FindAdjustedParameterLocation(_positionalParameterLocations[i]); object value = _positionalParameterValues[i]; IType type = _positionalParameterTypes[i]; ArrayHelper.SafeSetValue(values, location, value); @@ -428,7 +428,7 @@ int[] locations = getNamedParameterLocations(name); for (int i = 0; i < locations.Length; i++) { - int location = locations[i]; + int location = FindAdjustedParameterLocation(locations[i]); // can still clash with positional parameters // could consider throwing an exception to locate problem (NH-1098) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-09-15 21:39:54 UTC (rev 4713) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Loader/QueryLoader.cs 2009-09-15 21:41:03 UTC (rev 4714) @@ -58,11 +58,6 @@ get { return HasSubselectLoadableCollections(); } } - protected override void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) - { - _queryTranslator.AdjustNamedParameterLocationsForQueryParameters(parameters); - } - protected override SqlString ApplyLocks(SqlString sql, IDictionary<string, LockMode> lockModes, Dialect.Dialect dialect) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-09-15 21:39:54 UTC (rev 4713) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs 2009-09-15 21:41:03 UTC (rev 4714) @@ -464,11 +464,6 @@ throw new QueryExecutionRequestException("Not supported for DML operations", _hql); } } - - public void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) - { - ((ParameterTranslationsImpl) GetParameterTranslations()).AdjustNamedParameterLocationsForQueryParameters(parameters); - } } internal class HqlParseEngine Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2009-09-15 21:39:54 UTC (rev 4713) +++ trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2009-09-15 21:41:03 UTC (rev 4714) @@ -705,21 +705,6 @@ return o.ToArray(); } - protected override void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) - { - foreach (int existingParameterLocation in parameters.FilteredParameterLocations) - { - foreach (IList<int> namedParameterLocations in namedParameters.Values) - { - for (int index = 0; index < namedParameterLocations.Count; index++) - { - if (namedParameterLocations[index] >= existingParameterLocation) - namedParameterLocations[index]++; - } - } - } - } - public static string ScalarName(int x, int y) { return new StringBuilder() Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs 2009-09-15 21:39:54 UTC (rev 4713) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectCollectionLoader.cs 2009-09-15 21:41:03 UTC (rev 4714) @@ -43,23 +43,5 @@ { return namedParameterLocMap[name]; } - - protected override void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) - { - if (namedParameterLocMap == null) - return; - - foreach (int existingParameterLocation in parameters.FilteredParameterLocations) - { - foreach (IList<int> namedParameterLocations in namedParameterLocMap.Values) - { - for (int index = 0; index < namedParameterLocations.Count; index++) - { - if (namedParameterLocations[index] >= existingParameterLocation) - namedParameterLocations[index]++; - } - } - } - } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2009-09-15 21:39:54 UTC (rev 4713) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2009-09-15 21:41:03 UTC (rev 4714) @@ -45,24 +45,5 @@ { return namedParameterLocMap[name]; } - - protected override void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) - { - if (namedParameterLocMap == null) - return; - - foreach (int existingParameterLocation in parameters.FilteredParameterLocations) - { - foreach (IList<int> namedParameterLocations in namedParameterLocMap.Values) - { - for (int index = 0; index < namedParameterLocations.Count; index++) - { - if (namedParameterLocations[index] >= existingParameterLocation) - namedParameterLocations[index]++; - } - } - } - } - } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2009-09-15 21:39:54 UTC (rev 4713) +++ trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2009-09-15 21:41:03 UTC (rev 4714) @@ -320,30 +320,6 @@ } } - protected override void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) - { - var existingParameterLocations = parameters.FilteredParameterLocations.GetEnumerator(); - while (existingParameterLocations.MoveNext()) - { - foreach (string name in parameters.NamedParameters.Keys) - { - object locations = namedParameterBindPoints[name]; - if (locations is int) - { - namedParameterBindPoints[name] = ((int)locations) + 1; - } - else - { - IList locationsList = (IList)locations; - for (int i = 0; i < locationsList.Count; i++) - { - locationsList[i] = ((int)locationsList[i]) + 1; - } - } - } - } - } - protected override void AutoDiscoverTypes(IDataReader rs) { MetaData metadata = new MetaData(rs); Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2009-09-15 21:39:54 UTC (rev 4713) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2009-09-15 21:41:03 UTC (rev 4714) @@ -1174,7 +1174,6 @@ protected virtual SqlString ProcessFilters(QueryParameters parameters, ISessionImplementor session) { parameters.ProcessFilters(SqlString, session); - AdjustNamedParameterLocationsForQueryParameters(parameters); return parameters.FilteredSQL; } @@ -1269,15 +1268,6 @@ throw new AssertionFailure("no named parameters"); } - protected virtual void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) - { - // if you support named parameter locations (by overriding GetNamedParameterLocs), then you might need to - // allow for the locations to be adjusted by introduced filtered parameters by overriding - // this method too. - if ((parameters.NamedParameters != null) && (parameters.NamedParameters.Keys.Count > 0)) - throw new AssertionFailure(GetType() + " must override to handle implementation of named parameter locations"); - } - /// <summary> /// Fetch a <c>IDbCommand</c>, call <c>SetMaxRows</c> and then execute it, /// advance to the first result and return an SQL <c>IDataReader</c> @@ -1734,6 +1724,7 @@ for (int index = 0; index < parameters.PositionalParameterTypes.Length; index++) { int location = parameters.PositionalParameterLocations[index]; + location = parameters.FindAdjustedParameterLocation(location); IType type = parameters.PositionalParameterTypes[index]; ArrayHelper.SafeSetValue(paramTypeList, location, type); span += type.GetColumnSpan(Factory); @@ -1760,6 +1751,7 @@ for (int i = 0; i < locs.Length; i++) { int location = locs[i]; + location = parameters.FindAdjustedParameterLocation(location); // can still clash with positional parameters // could consider throwing an exception to locate problem (NH-1098) Modified: trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-09-15 21:39:54 UTC (rev 4713) +++ trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-09-15 21:41:03 UTC (rev 4714) @@ -67,21 +67,6 @@ } } - public void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters) - { - // NH Different behaviour NH-1776 - // Analyze all named parameters declared after filters - // in general all named parameters but depend on the complexity of the query (see sub query) - RestoreOriginalParameterLocations(); - foreach (int filterParameterLocation in parameters.FilteredParameterLocations) - { - foreach (ParameterInfo entry in _namedParameters.Values) - { - entry.IncrementLocationAfterFilterLocation(filterParameterLocation); - } - } - } - public int GetOrdinalParameterSqlLocation(int ordinalPosition) { return GetOrdinalParameterInfo(ordinalPosition).SqlLocations[0]; @@ -117,14 +102,6 @@ get { return _ordinalParameters.Length; } } - private void RestoreOriginalParameterLocations() - { - foreach (ParameterInfo entry in _namedParameters.Values) - { - entry.RestoreOriginalParameterLocations(); - } - } - private ParameterInfo GetOrdinalParameterInfo(int ordinalPosition) { // remember that ordinal parameters numbers are 1-based!!! @@ -170,24 +147,5 @@ } public IType ExpectedType { get; private set; } - - public void RestoreOriginalParameterLocations() - { - for (int i = 0; i < sqlLocations.Length; i++) - { - sqlLocations[i] = originalLocation[i]; - } - } - - public void IncrementLocationAfterFilterLocation(int filterParameterLocation) - { - for (int i = 0; i < sqlLocations.Length; i++) - { - if (sqlLocations[i] >= filterParameterLocation) - { - sqlLocations[i]++; - } - } - } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Fixture.cs 2009-09-15 21:41:03 UTC (rev 4714) @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1908ThreadSafety +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void UsingFiltersIsThreadSafe() + { + var errors = new List<Exception>(); + var threads = new List<Thread>(); + for (int i = 0; i < 50; i++) + { + var thread = new Thread(() => + { + try + { + ScenarioRunningWithMultiThreading(); + } + catch (Exception ex) + { + lock (errors) + errors.Add(ex); + } + }); + thread.Start(); + threads.Add(thread); + } + + foreach (var thread in threads) + { + thread.Join(); + } + + Assert.AreEqual(0, errors.Count); + } + + private void ScenarioRunningWithMultiThreading() + { + using (var session = sessions.OpenSession()) + { + session + .EnableFilter("CurrentOnly") + .SetParameter("date", DateTime.Now); + + session.CreateQuery( + @" + select u + from Order u + left join fetch u.ActiveOrderLines + where + u.Email = :email + ") + .SetString("email", "st...@bu...") + .UniqueResult<Order>(); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Mappings.hbm.xml 2009-09-15 21:41:03 UTC (rev 4714) @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1908ThreadSafety"> + + <class name="Order" table="Orders"> + <id name="Id" type="Int64" unsaved-value="none"> + <generator class="assigned"/> + </id> + <property name="Email" type="String" not-null="true"/> + <bag name="ActiveOrderLines" inverse="true" cascade="none" lazy="true" + optimistic-lock="false"> + <key column="OrderId"/> + <one-to-many class="OrderLine"/> + <filter name="CurrentOnly"/> + </bag> + </class> + + <class name="OrderLine" discriminator-value="null"> + <id name="Id" type="Int64" unsaved-value="none"> + <generator class="assigned"/> + </id> + <property name="ValidUntil"/> + <filter name="CurrentOnly"/> + </class> + + <filter-def name="CurrentOnly" condition="ValidUntil > :date"> + <filter-param name="date" type="DateTime"/> + </filter-def> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Model.cs 2009-09-15 21:41:03 UTC (rev 4714) @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1908ThreadSafety +{ + public class Order + { + public virtual long Id { get; set; } + public virtual IList<OrderLine> ActiveOrderLines { get; set;} + public virtual string Email { get; set; } + } + + public class OrderLine + { + public virtual long Id { get; set; } + public virtual DateTime ValidUntil { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-15 21:39:54 UTC (rev 4713) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-15 21:41:03 UTC (rev 4714) @@ -580,6 +580,8 @@ <Compile Include="NHSpecificTest\NH1905\Model.cs" /> <Compile Include="NHSpecificTest\NH1907\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1907\MyType.cs" /> + <Compile Include="NHSpecificTest\NH1908ThreadSafety\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1908ThreadSafety\Model.cs" /> <Compile Include="NHSpecificTest\NH1908\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1908\Model.cs" /> <Compile Include="NHSpecificTest\NH1911\Fixture.cs" /> @@ -2006,6 +2008,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1908ThreadSafety\Mappings.hbm.xml" /> <EmbeddedResource Include="Tools\hbm2ddl\SchemaUpdate\1_Person.hbm.xml" /> <EmbeddedResource Include="Tools\hbm2ddl\SchemaUpdate\2_Person.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1938\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-09-23 10:10:11
|
Revision: 4722 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4722&view=rev Author: ricbrown Date: 2009-09-23 10:10:00 +0000 (Wed, 23 Sep 2009) Log Message: ----------- Merge r4721 (Fix NH-1941 Overriding GetValue in EnumStringType) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Type/EnumStringType.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/Model.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/SexEnumStringType.cs Modified: trunk/nhibernate/src/NHibernate/Type/EnumStringType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/EnumStringType.cs 2009-09-23 10:09:13 UTC (rev 4721) +++ trunk/nhibernate/src/NHibernate/Type/EnumStringType.cs 2009-09-23 10:10:00 UTC (rev 4722) @@ -126,7 +126,7 @@ public virtual object GetValue(object code) { //code is an enum instance. - return code == null ? string.Empty : code.ToString(); + return code == null ? string.Empty : Enum.Format(ReturnedClass, code, "G"); } /// <summary> @@ -144,7 +144,7 @@ } else { - par.Value = Enum.Format(ReturnedClass, value, "G"); + par.Value = GetValue(value); } } Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941 ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/Fixture.cs 2009-09-23 10:10:00 UTC (rev 4722) @@ -0,0 +1,50 @@ +using System; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1941 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession s = OpenSession()) + { + s.Delete("from Person"); + } + } + [Test] + public void CanOverrideStringEnumGetValue() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + using (SqlLogSpy ls = new SqlLogSpy()) + { + Person person = new Person() { Sex = Sex.Male }; + s.Save(person); + + string log = ls.GetWholeLog(); + Assert.IsTrue(log.Contains("@p0 = 'M'")); + } + + using (SqlLogSpy ls = new SqlLogSpy()) + { + Person person = + s.CreateQuery("from Person p where p.Sex = :personSex") + .SetParameter("personSex", Sex.Female) + .UniqueResult<Person>(); + + Assert.That(person, Is.Null); + + string log = ls.GetWholeLog(); + Assert.IsTrue(log.Contains("@p0 = 'F'")); + } + + tx.Rollback(); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/Mappings.hbm.xml 2009-09-23 10:10:00 UTC (rev 4722) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1941"> + + <class name="Person" > + <id name="Id"> + <generator class="native" /> + </id> + + <property name="Sex" type="SexEnumStringType" /> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/Model.cs 2009-09-23 10:10:00 UTC (rev 4722) @@ -0,0 +1,14 @@ +namespace NHibernate.Test.NHSpecificTest.NH1941 +{ + public enum Sex + { + Male, + Female, + } + + public class Person + { + public virtual int Id { get; set; } + public virtual Sex Sex { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/SexEnumStringType.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/SexEnumStringType.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1941/SexEnumStringType.cs 2009-09-23 10:10:00 UTC (rev 4722) @@ -0,0 +1,28 @@ +using System; +using NHibernate.Type; + +namespace NHibernate.Test.NHSpecificTest.NH1941 +{ + public class SexEnumStringType : EnumStringType<Sex> + { + public override object GetValue(object enumValue) + { + if (enumValue == null) + { + return string.Empty; + } + + return (Sex)enumValue == Sex.Male ? "M" : "F"; + } + + public override object GetInstance(object value) + { + if (value == null) + { + throw new ArgumentNullException("value"); + } + + return (value.ToString() == "M") ? Sex.Male : Sex.Female; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-23 10:09:13 UTC (rev 4721) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-23 10:10:00 UTC (rev 4722) @@ -603,6 +603,9 @@ <Compile Include="NHSpecificTest\NH1938\Model.cs" /> <Compile Include="NHSpecificTest\NH1939\AuxType.cs" /> <Compile Include="NHSpecificTest\NH1939\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1941\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1941\Model.cs" /> + <Compile Include="NHSpecificTest\NH1941\SexEnumStringType.cs" /> <Compile Include="NHSpecificTest\NH1963\CacheableQueryOnByteArray.cs" /> <Compile Include="NHSpecificTest\NH1963\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1969\DummyEntity.cs" /> @@ -2022,6 +2025,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1941\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1963\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1969\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1922\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-09-24 11:23:08
|
Revision: 4724 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4724&view=rev Author: ricbrown Date: 2009-09-24 11:22:59 +0000 (Thu, 24 Sep 2009) Log Message: ----------- Merge r4723 (Fix NH-1948 Allow scale of zero) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948/Model.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-09-24 11:20:25 UTC (rev 4723) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-09-24 11:22:59 UTC (rev 4724) @@ -152,7 +152,7 @@ public string precision; /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute(DataType="positiveInteger")] + [System.Xml.Serialization.XmlAttributeAttribute(DataType="nonNegativeInteger")] public string scale; /// <remarks/> @@ -937,7 +937,7 @@ public string precision; /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute(DataType="positiveInteger")] + [System.Xml.Serialization.XmlAttributeAttribute(DataType="nonNegativeInteger")] public string scale; /// <remarks/> @@ -1101,7 +1101,7 @@ public string precision; /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute(DataType="positiveInteger")] + [System.Xml.Serialization.XmlAttributeAttribute(DataType="nonNegativeInteger")] public string scale; /// <remarks/> Modified: trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd =================================================================== --- trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2009-09-24 11:20:25 UTC (rev 4723) +++ trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2009-09-24 11:22:59 UTC (rev 4724) @@ -233,7 +233,7 @@ </xs:attribute> <xs:attribute name="length" type="xs:positiveInteger" /> <xs:attribute name="precision" type="xs:positiveInteger" /> - <xs:attribute name="scale" type="xs:positiveInteger" /> + <xs:attribute name="scale" type="xs:nonNegativeInteger" /> <xs:attribute name="not-null" type="xs:boolean"> </xs:attribute> <xs:attribute name="unique" type="xs:boolean"> @@ -448,7 +448,7 @@ <xs:attribute name="type" type="xs:string" /> <xs:attribute name="length" type="xs:positiveInteger" /> <xs:attribute name="precision" type="xs:positiveInteger" /> - <xs:attribute name="scale" type="xs:positiveInteger" /> + <xs:attribute name="scale" type="xs:nonNegativeInteger" /> <xs:attribute name="not-null" default="false" type="xs:boolean"> </xs:attribute> <xs:attribute name="unique" default="false" type="xs:boolean"> @@ -1158,7 +1158,7 @@ <xs:attribute name="column" type="xs:string" /> <xs:attribute name="length" type="xs:positiveInteger" /> <xs:attribute name="precision" type="xs:positiveInteger" /> - <xs:attribute name="scale" type="xs:positiveInteger" /> + <xs:attribute name="scale" type="xs:nonNegativeInteger" /> <xs:attribute name="not-null" type="xs:boolean"> </xs:attribute> <xs:attribute name="unique" default="false" type="xs:boolean"> Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948 ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948/Fixture.cs 2009-09-24 11:22:59 UTC (rev 4724) @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1948 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + [Test] + public void CanUseDecimalScaleZero() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + Person person = + new Person() + { + Age = 50, + ShoeSize = 10, + FavouriteNumbers = + new List<decimal>() + { + 20, + 30, + 40, + }, + }; + + s.Save(person); + s.Flush(); + tx.Rollback(); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948/Mappings.hbm.xml 2009-09-24 11:22:59 UTC (rev 4724) @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1948"> + + <class name="Person"> + <id name="Id"> + <generator class="native" /> + </id> + + <property name="Age" type="decimal" precision="2" scale="0" /> + + <property name="ShoeSize"> + <column name="ShoeSizeColumn" precision="2" scale="0"/> + </property> + + <bag name="FavouriteNumbers" table="FavNum"> + <key column="Person" /> + <element type="decimal" precision="2" scale="0" /> + </bag> + + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1948/Model.cs 2009-09-24 11:22:59 UTC (rev 4724) @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1948 +{ + public class Person + { + public virtual int Id { get; set; } + public virtual decimal Age { get; set; } + public virtual decimal ShoeSize { get; set; } + public virtual IList<decimal> FavouriteNumbers { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-24 11:20:25 UTC (rev 4723) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-24 11:22:59 UTC (rev 4724) @@ -606,6 +606,8 @@ <Compile Include="NHSpecificTest\NH1941\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1941\Model.cs" /> <Compile Include="NHSpecificTest\NH1941\SexEnumStringType.cs" /> + <Compile Include="NHSpecificTest\NH1948\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1948\Model.cs" /> <Compile Include="NHSpecificTest\NH1963\CacheableQueryOnByteArray.cs" /> <Compile Include="NHSpecificTest\NH1963\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1969\DummyEntity.cs" /> @@ -2025,6 +2027,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1948\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1941\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1963\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1969\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-09-25 21:05:16
|
Revision: 4725 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4725&view=rev Author: steverstrong Date: 2009-09-25 21:04:56 +0000 (Fri, 25 Sep 2009) Log Message: ----------- Further updates to the Linq provider Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs trunk/nhibernate/src/NHibernate/Linq/AggregatingGroupByRewriter.cs trunk/nhibernate/src/NHibernate/Linq/HqlGeneratorExpressionTreeVisitor.cs trunk/nhibernate/src/NHibernate/Linq/NhExpressionTreeVisitor.cs trunk/nhibernate/src/NHibernate/Linq/NhThrowingExpressionTreeVisitor.cs trunk/nhibernate/src/NHibernate/Linq/NonAggregatingGroupByRewriter.cs trunk/nhibernate/src/NHibernate/Linq/QueryModelVisitor.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Linq/LinqQuerySamples.cs trunk/nhibernate/src/NHibernate.Test/Linq/ReadonlyTestCase.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Linq/AggregatingGroupJoinRewriter.cs trunk/nhibernate/src/NHibernate/Linq/GroupByAggregateDetectionVisitor.cs trunk/nhibernate/src/NHibernate/Linq/GroupByKeySelectorVisitor.cs trunk/nhibernate/src/NHibernate/Linq/GroupBySelectClauseRewriter.cs trunk/nhibernate/src/NHibernate/Linq/MergeAggregatingResultsRewriter.cs trunk/nhibernate/src/NHibernate/Linq/NhNewExpression.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate/Linq/AggregateDetectionVisitor.cs trunk/nhibernate/src/NHibernate/Linq/GroupBySelectClauseVisitor.cs trunk/nhibernate/src/NHibernate/Linq/GroupBySelectorVisitor.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs 2009-09-24 11:22:59 UTC (rev 4724) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -100,6 +100,11 @@ return new HqlEquality(_factory); } + public HqlEquality Equality(HqlTreeNode lhs, HqlTreeNode rhs) + { + return new HqlEquality(_factory, lhs, rhs); + } + public HqlBooleanAnd BooleanAnd() { return new HqlBooleanAnd(_factory); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs 2009-09-24 11:22:59 UTC (rev 4724) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -229,6 +229,11 @@ : base(HqlSqlWalker.EQ, "==", factory) { } + + public HqlEquality(IASTFactory factory, HqlTreeNode lhs, HqlTreeNode rhs) + : base(HqlSqlWalker.EQ, "==", factory, lhs, rhs) + { + } } public class HqlParameter : HqlTreeNode Deleted: trunk/nhibernate/src/NHibernate/Linq/AggregateDetectionVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/AggregateDetectionVisitor.cs 2009-09-24 11:22:59 UTC (rev 4724) +++ trunk/nhibernate/src/NHibernate/Linq/AggregateDetectionVisitor.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -1,54 +0,0 @@ -using System.Linq; -using System.Linq.Expressions; -using Remotion.Data.Linq.Clauses.Expressions; -using Remotion.Data.Linq.Clauses.ResultOperators; -using Remotion.Data.Linq.Parsing; - -namespace NHibernate.Linq -{ - // TODO: This needs strengthening. For example, it doesn't recurse into SubQueries at present - internal class AggregateDetectionVisitor : ExpressionTreeVisitor - { - public bool ContainsAggregateMethods { get; private set; } - - public bool Visit(Expression expression) - { - ContainsAggregateMethods = false; - - VisitExpression(expression); - - return ContainsAggregateMethods; - } - - protected override Expression VisitMethodCallExpression(MethodCallExpression m) - { - if (m.Method.DeclaringType == typeof (Queryable) || - m.Method.DeclaringType == typeof (Enumerable)) - { - switch (m.Method.Name) - { - case "Count": - case "Min": - case "Max": - case "Sum": - case "Average": - ContainsAggregateMethods = true; - break; - } - } - - return base.VisitMethodCallExpression(m); - } - - protected override Expression VisitSubQueryExpression(SubQueryExpression expression) - { - if (expression.QueryModel.ResultOperators.Count == 1 - && typeof(ValueFromSequenceResultOperatorBase).IsAssignableFrom(expression.QueryModel.ResultOperators[0].GetType())) - { - ContainsAggregateMethods = true; - } - - return base.VisitSubQueryExpression(expression); - } - } -} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/AggregatingGroupByRewriter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/AggregatingGroupByRewriter.cs 2009-09-24 11:22:59 UTC (rev 4724) +++ trunk/nhibernate/src/NHibernate/Linq/AggregatingGroupByRewriter.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -7,44 +7,55 @@ namespace NHibernate.Linq { - public class AggregatingGroupByRewriter : QueryModelVisitorBase + public class AggregatingGroupByRewriter { - public override void VisitMainFromClause(MainFromClause fromClause, QueryModel queryModel) + public void ReWrite(QueryModel queryModel) { - var subQueryExpression = fromClause.FromExpression as SubQueryExpression; + var subQueryExpression = queryModel.MainFromClause.FromExpression as SubQueryExpression; if ((subQueryExpression != null) && (subQueryExpression.QueryModel.ResultOperators.Count() == 1) && (subQueryExpression.QueryModel.ResultOperators[0] is GroupResultOperator) && (IsAggregatingGroupBy(queryModel))) { - FlattenSubQuery(subQueryExpression, fromClause, queryModel); + FlattenSubQuery(subQueryExpression, queryModel.MainFromClause, queryModel); } - - base.VisitMainFromClause(fromClause, queryModel); } private static bool IsAggregatingGroupBy(QueryModel queryModel) { - return new AggregateDetectionVisitor().Visit(queryModel.SelectClause.Selector); + return new GroupByAggregateDetectionVisitor().Visit(queryModel.SelectClause.Selector); } private void FlattenSubQuery(SubQueryExpression subQueryExpression, FromClauseBase fromClause, QueryModel queryModel) { + // Move the result operator up + if (queryModel.ResultOperators.Count != 0) + { + throw new NotImplementedException(); + } + + var groupBy = (GroupResultOperator) subQueryExpression.QueryModel.ResultOperators[0]; + // Replace the outer select clause... - queryModel.SelectClause.TransformExpressions(GroupBySelectClauseVisitor.Visit); + queryModel.SelectClause.TransformExpressions(s => GroupBySelectClauseRewriter.ReWrite(s, groupBy, subQueryExpression.QueryModel)); + queryModel.SelectClause.TransformExpressions( + s => + new SwapQuerySourceVisitor(queryModel.MainFromClause, subQueryExpression.QueryModel.MainFromClause).Swap + (s)); + + MainFromClause innerMainFromClause = subQueryExpression.QueryModel.MainFromClause; CopyFromClauseData(innerMainFromClause, fromClause); - // Move the result operator up - if (queryModel.ResultOperators.Count != 0) + foreach (var bodyClause in subQueryExpression.QueryModel.BodyClauses) { - throw new NotImplementedException(); + queryModel.BodyClauses.Add(bodyClause); } - queryModel.ResultOperators.Add(subQueryExpression.QueryModel.ResultOperators[0]); + queryModel.ResultOperators.Add(groupBy); } protected void CopyFromClauseData(FromClauseBase source, FromClauseBase destination) Added: trunk/nhibernate/src/NHibernate/Linq/AggregatingGroupJoinRewriter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/AggregatingGroupJoinRewriter.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/AggregatingGroupJoinRewriter.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -0,0 +1,321 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using Remotion.Data.Linq; +using Remotion.Data.Linq.Clauses; +using Remotion.Data.Linq.Clauses.Expressions; + +namespace NHibernate.Linq +{ + public class AggregatingGroupJoinRewriter + { + public void ReWrite(QueryModel model) + { + // We want to take queries like this: + + //var q = + // from c in db.Customers + // join o in db.Orders on c.CustomerId equals o.Customer.CustomerId into ords + // join e in db.Employees on c.Address.City equals e.Address.City into emps + // select new { c.ContactName, ords = ords.Count(), emps = emps.Count() }; + + // and turn them into this: + + //var q = + // from c in db.Customers + // select new + // { + // c.ContactName, + // ords = (from o2 in db.Orders where o2.Customer.CustomerId == c.CustomerId select o2).Count(), + // emps = (from e2 in db.Employees where e2.Address.City == c.Address.City select e2).Count() + // }; + + // so spot a group join where every use of the grouping in the selector is an aggregate + + // firstly, get the group join clauses + var groupJoin = model.BodyClauses.Where(bc => bc is GroupJoinClause).Cast<GroupJoinClause>(); + + if (groupJoin.Count() == 0) + { + // No group join here.. + return; + } + + // Now walk the tree to decide which groupings are fully aggregated (and can hence be done in hql) + var aggregateDetectorResults = IsAggregatingGroupJoin(model, groupJoin); + + if (aggregateDetectorResults.AggregatingClauses.Count > 0) + { + // Re-write the select expression + model.SelectClause.TransformExpressions(s => GroupJoinSelectClauseRewriter.ReWrite(s, aggregateDetectorResults)); + + // Remove the aggregating group joins + foreach (GroupJoinClause aggregatingGroupJoin in aggregateDetectorResults.AggregatingClauses) + { + model.BodyClauses.Remove(aggregatingGroupJoin); + } + } + } + + private static IsAggregatingResults IsAggregatingGroupJoin(QueryModel model, IEnumerable<GroupJoinClause> clause) + { + return new GroupJoinAggregateDetectionVisitor(clause).Visit(model.SelectClause.Selector); + } + } + + public class GroupJoinSelectClauseRewriter : NhExpressionTreeVisitor + { + private readonly IsAggregatingResults _results; + + public static Expression ReWrite(Expression expression, IsAggregatingResults results) + { + return new GroupJoinSelectClauseRewriter(results).VisitExpression(expression); + } + + private GroupJoinSelectClauseRewriter(IsAggregatingResults results) + { + _results = results; + } + + protected override Expression VisitSubQueryExpression(SubQueryExpression expression) + { + // If the sub queries main (and only) from clause is one of our aggregating group bys, then swap it + GroupJoinClause groupJoin = LocateGroupJoinQuerySource(expression.QueryModel); + + if (groupJoin != null) + { + Expression innerSelector = new SwapQuerySourceVisitor(groupJoin.JoinClause, expression.QueryModel.MainFromClause). + Swap(groupJoin.JoinClause.InnerKeySelector); + + expression.QueryModel.MainFromClause.FromExpression = groupJoin.JoinClause.InnerSequence; + + + // TODO - this only works if the key selectors are not composite. Needs improvement... + expression.QueryModel.BodyClauses.Add(new WhereClause(Expression.Equal(innerSelector, groupJoin.JoinClause.OuterKeySelector))); + } + + return expression; + } + + private GroupJoinClause LocateGroupJoinQuerySource(QueryModel model) + { + if (model.BodyClauses.Count > 0) + { + return null; + } + return new LocateGroupJoinQuerySource(_results).Detect(model.MainFromClause.FromExpression); + } + } + + public class SwapQuerySourceVisitor : NhExpressionTreeVisitor + { + private readonly IQuerySource _oldClause; + private readonly IQuerySource _newClause; + + public SwapQuerySourceVisitor(IQuerySource oldClause, IQuerySource newClause) + { + _oldClause = oldClause; + _newClause = newClause; + } + + public Expression Swap(Expression expression) + { + return VisitExpression(expression); + } + + protected override Expression VisitQuerySourceReferenceExpression(QuerySourceReferenceExpression expression) + { + if (expression.ReferencedQuerySource == _oldClause) + { + return new QuerySourceReferenceExpression(_newClause); + } + + // TODO - really don't like this drill down approach. Feels fragile + var mainFromClause = expression.ReferencedQuerySource as MainFromClause; + + if (mainFromClause != null) + { + mainFromClause.FromExpression = VisitExpression(mainFromClause.FromExpression); + } + + return expression; + } + + protected override Expression VisitSubQueryExpression(SubQueryExpression expression) + { + expression.QueryModel.TransformExpressions(VisitExpression); + return base.VisitSubQueryExpression(expression); + } + } + + public class LocateGroupJoinQuerySource : NhExpressionTreeVisitor + { + private readonly IsAggregatingResults _results; + private GroupJoinClause _groupJoin; + + public LocateGroupJoinQuerySource(IsAggregatingResults results) + { + _results = results; + } + + public GroupJoinClause Detect(Expression expression) + { + VisitExpression(expression); + return _groupJoin; + } + + protected override Expression VisitQuerySourceReferenceExpression(QuerySourceReferenceExpression expression) + { + if (_results.AggregatingClauses.Contains(expression.ReferencedQuerySource as GroupJoinClause)) + { + _groupJoin = expression.ReferencedQuerySource as GroupJoinClause; + } + + return base.VisitQuerySourceReferenceExpression(expression); + } + } + + public class IsAggregatingResults + { + public List<GroupJoinClause> NonAggregatingClauses { get; set; } + public List<GroupJoinClause> AggregatingClauses { get; set; } + public List<Expression> NonAggregatingExpressions { get; set; } + } + + internal class GroupJoinAggregateDetectionVisitor : NhExpressionTreeVisitor + { + private readonly HashSet<GroupJoinClause> _groupJoinClauses; + private readonly StackFlag _inAggregate = new StackFlag(); + private readonly StackFlag _parentExpressionProcessed = new StackFlag(); + + private readonly List<Expression> _nonAggregatingExpressions = new List<Expression>(); + private readonly List<GroupJoinClause> _nonAggregatingGroupJoins = new List<GroupJoinClause>(); + private readonly List<GroupJoinClause> _aggregatingGroupJoins = new List<GroupJoinClause>(); + + public GroupJoinAggregateDetectionVisitor(IEnumerable<GroupJoinClause> groupJoinClause) + { + _groupJoinClauses = new HashSet<GroupJoinClause>(groupJoinClause); + } + + public IsAggregatingResults Visit(Expression expression) + { + VisitExpression(expression); + + return new IsAggregatingResults { NonAggregatingClauses = _nonAggregatingGroupJoins, AggregatingClauses = _aggregatingGroupJoins, NonAggregatingExpressions = _nonAggregatingExpressions }; + } + + protected override Expression VisitSubQueryExpression(SubQueryExpression expression) + { + VisitExpression(expression.QueryModel.SelectClause.Selector); + return expression; + } + + protected override Expression VisitNhAverage(NhAverageExpression expression) + { + using (_inAggregate.SetFlag()) + { + return base.VisitNhAverage(expression); + } + } + + protected override Expression VisitNhCount(NhCountExpression expression) + { + using (_inAggregate.SetFlag()) + { + return base.VisitNhCount(expression); + } + } + + protected override Expression VisitNhMax(NhMaxExpression expression) + { + using (_inAggregate.SetFlag()) + { + return base.VisitNhMax(expression); + } + } + + protected override Expression VisitNhMin(NhMinExpression expression) + { + using (_inAggregate.SetFlag()) + { + return base.VisitNhMin(expression); + } + } + + protected override Expression VisitNhSum(NhSumExpression expression) + { + using (_inAggregate.SetFlag()) + { + return base.VisitNhSum(expression); + } + } + + protected override Expression VisitMemberExpression(MemberExpression expression) + { + if (_inAggregate.FlagIsFalse && _parentExpressionProcessed.FlagIsFalse) + { + _nonAggregatingExpressions.Add(expression); + } + + using (_parentExpressionProcessed.SetFlag()) + { + return base.VisitMemberExpression(expression); + } + } + + protected override Expression VisitQuerySourceReferenceExpression(QuerySourceReferenceExpression expression) + { + var fromClause = (FromClauseBase) expression.ReferencedQuerySource; + + if (fromClause.FromExpression is QuerySourceReferenceExpression) + { + var querySourceReference = (QuerySourceReferenceExpression) fromClause.FromExpression; + + if (_groupJoinClauses.Contains(querySourceReference.ReferencedQuerySource as GroupJoinClause)) + { + if (_inAggregate.FlagIsFalse) + { + _nonAggregatingGroupJoins.Add((GroupJoinClause) querySourceReference.ReferencedQuerySource); + } + else + { + _aggregatingGroupJoins.Add((GroupJoinClause) querySourceReference.ReferencedQuerySource); + } + } + } + + return base.VisitQuerySourceReferenceExpression(expression); + } + + internal class StackFlag + { + public bool FlagIsTrue { get; private set; } + + public bool FlagIsFalse { get { return !FlagIsTrue; } } + + public IDisposable SetFlag() + { + return new StackFlagDisposable(this); + } + + internal class StackFlagDisposable : IDisposable + { + private readonly StackFlag _parent; + private readonly bool _old; + + public StackFlagDisposable(StackFlag parent) + { + _parent = parent; + _old = parent.FlagIsTrue; + parent.FlagIsTrue = true; + } + + public void Dispose() + { + _parent.FlagIsTrue = _old; + } + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/GroupByAggregateDetectionVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/GroupByAggregateDetectionVisitor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/GroupByAggregateDetectionVisitor.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -0,0 +1,83 @@ +using System.Linq; +using System.Linq.Expressions; +using Remotion.Data.Linq.Clauses.Expressions; +using Remotion.Data.Linq.Clauses.ResultOperators; +using Remotion.Data.Linq.Parsing; + +namespace NHibernate.Linq +{ + // TODO: This needs strengthening. Possibly a lot in common with the GroupJoinAggregateDetectionVisitor class, which does many more checks + internal class GroupByAggregateDetectionVisitor : NhExpressionTreeVisitor + { + public bool ContainsAggregateMethods { get; private set; } + + public bool Visit(Expression expression) + { + ContainsAggregateMethods = false; + + VisitExpression(expression); + + return ContainsAggregateMethods; + } + + // TODO - this should not exist, since it should be handled either by re-linq or by the MergeAggregatingResultsRewriter + protected override Expression VisitMethodCallExpression(MethodCallExpression m) + { + if (m.Method.DeclaringType == typeof (Queryable) || + m.Method.DeclaringType == typeof (Enumerable)) + { + switch (m.Method.Name) + { + case "Count": + case "Min": + case "Max": + case "Sum": + case "Average": + ContainsAggregateMethods = true; + break; + } + } + + return m; + } + + // TODO - having a VisitNhAggregation method or something in the base class would remove this duplication... + protected override Expression VisitNhAverage(NhAverageExpression expression) + { + ContainsAggregateMethods = true; + return expression; + } + + protected override Expression VisitNhCount(NhCountExpression expression) + { + ContainsAggregateMethods = true; + return expression; + } + + protected override Expression VisitNhMax(NhMaxExpression expression) + { + ContainsAggregateMethods = true; + return expression; + } + + protected override Expression VisitNhMin(NhMinExpression expression) + { + ContainsAggregateMethods = true; + return expression; + } + + protected override Expression VisitNhSum(NhSumExpression expression) + { + ContainsAggregateMethods = true; + return expression; + } + + protected override Expression VisitSubQueryExpression(SubQueryExpression expression) + { + ContainsAggregateMethods = + new GroupByAggregateDetectionVisitor().Visit(expression.QueryModel.SelectClause.Selector); + + return expression; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/GroupByKeySelectorVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/GroupByKeySelectorVisitor.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/GroupByKeySelectorVisitor.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -0,0 +1,26 @@ +using System.Linq.Expressions; +using Remotion.Data.Linq.Clauses.Expressions; +using Remotion.Data.Linq.Parsing; + +namespace NHibernate.Linq +{ + internal class GroupByKeySelectorVisitor : ExpressionTreeVisitor + { + private readonly ParameterExpression _parameter; + + public GroupByKeySelectorVisitor(ParameterExpression parameter) + { + _parameter = parameter; + } + + public Expression Visit(Expression expression) + { + return VisitExpression(expression); + } + + protected override Expression VisitQuerySourceReferenceExpression(QuerySourceReferenceExpression expression) + { + return _parameter; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/GroupBySelectClauseRewriter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/GroupBySelectClauseRewriter.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/GroupBySelectClauseRewriter.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -0,0 +1,202 @@ +using System; +using System.Linq.Expressions; +using Remotion.Data.Linq; +using Remotion.Data.Linq.Clauses; +using Remotion.Data.Linq.Clauses.Expressions; +using Remotion.Data.Linq.Clauses.ResultOperators; + +namespace NHibernate.Linq +{ + internal class GroupBySelectClauseRewriter : NhExpressionTreeVisitor + { + public static Expression ReWrite(Expression expression, GroupResultOperator groupBy, QueryModel model) + { + var visitor = new GroupBySelectClauseRewriter(groupBy, model); + return visitor.VisitExpression(expression); + } + + private readonly GroupResultOperator _groupBy; + private readonly QueryModel _model; + + public GroupBySelectClauseRewriter(GroupResultOperator groupBy, QueryModel model) + { + _groupBy = groupBy; + _model = model; + } + + protected override Expression VisitQuerySourceReferenceExpression(QuerySourceReferenceExpression expression) + { + if (expression.ReferencedQuerySource == _groupBy) + { + return _groupBy.ElementSelector; + } + + return base.VisitQuerySourceReferenceExpression(expression); + } + + protected override Expression VisitMemberExpression(MemberExpression expression) + { + if (IsMemberOfModel(expression)) + { + if (expression.Member.Name == "Key") + { + return _groupBy.KeySelector; + } + else + { + Expression elementSelector = _groupBy.ElementSelector; + + if ((elementSelector is MemberExpression) || (elementSelector is QuerySourceReferenceExpression)) + { + // If ElementSelector is MemberExpression, just return + return base.VisitMemberExpression(expression); + } + else if (elementSelector is NewExpression) + { + // If ElementSelector is NewExpression, then search for member of name "get_" + originalMemberExpression.Member.Name + // TODO - this wouldn't handle nested initialisers. Should do a tree walk to find the correct member + var nex = elementSelector as NewExpression; + + int i = 0; + foreach (var member in nex.Members) + { + if (member.Name == "get_" + expression.Member.Name) + { + return nex.Arguments[i]; + } + i++; + } + + throw new NotImplementedException(); + } + else + { + throw new NotImplementedException(); + } + } + } + else + { + return base.VisitMemberExpression(expression); + } + } + + // TODO - dislike this code intensly. Should probably be a tree-walk in its own right + private bool IsMemberOfModel(MemberExpression expression) + { + var querySourceRef = expression.Expression as QuerySourceReferenceExpression; + + if (querySourceRef == null) + { + return false; + } + + var fromClause = querySourceRef.ReferencedQuerySource as FromClauseBase; + + if (fromClause == null) + { + return false; + } + + var subQuery = fromClause.FromExpression as SubQueryExpression; + + if (subQuery != null) + { + return subQuery.QueryModel == _model; + } + + var referencedQuery = fromClause.FromExpression as QuerySourceReferenceExpression; + + if (referencedQuery == null) + { + return false; + } + + var querySource = referencedQuery.ReferencedQuerySource as FromClauseBase; + + var subQuery2 = querySource.FromExpression as SubQueryExpression; + + return (subQuery2.QueryModel == _model); + } + + protected override Expression VisitSubQueryExpression(SubQueryExpression expression) + { + // TODO - is this safe? All we are extracting is the select clause from the sub-query. Assumes that everything + // else in the subquery has been removed. If there were two subqueries, one aggregating & one not, this may not be a + // valid assumption. Should probably be passed a list of aggregating subqueries that we are flattening so that we can check... + return GroupBySelectClauseRewriter.ReWrite(expression.QueryModel.SelectClause.Selector, _groupBy, _model); + } + } + + public enum NhExpressionType + { + Average = 10000, + Min, + Max, + Sum, + Count, + Distinct, + New + } + + public class NhAggregatedExpression : Expression + { + public Expression Expression { get; set; } + + public NhAggregatedExpression(Expression expression, NhExpressionType type) + : base((ExpressionType)type, expression.Type) + { + Expression = expression; + } + } + + public class NhAverageExpression : NhAggregatedExpression + { + public NhAverageExpression(Expression expression) : base(expression, NhExpressionType.Average) + { + } + } + + public class NhMinExpression : NhAggregatedExpression + { + public NhMinExpression(Expression expression) + : base(expression, NhExpressionType.Min) + { + } + } + + public class NhMaxExpression : NhAggregatedExpression + { + public NhMaxExpression(Expression expression) + : base(expression, NhExpressionType.Max) + { + } + } + + public class NhSumExpression : NhAggregatedExpression + { + public NhSumExpression(Expression expression) + : base(expression, NhExpressionType.Sum) + { + } + } + + public class NhDistinctExpression : NhAggregatedExpression + { + public NhDistinctExpression(Expression expression) + : base(expression, NhExpressionType.Distinct) + { + } + } + + public class NhCountExpression : Expression + { + public NhCountExpression(Expression expression) + : base((ExpressionType)NhExpressionType.Count, typeof(int)) + { + Expression = expression; + } + + public Expression Expression { get; private set; } + } +} Deleted: trunk/nhibernate/src/NHibernate/Linq/GroupBySelectClauseVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/GroupBySelectClauseVisitor.cs 2009-09-24 11:22:59 UTC (rev 4724) +++ trunk/nhibernate/src/NHibernate/Linq/GroupBySelectClauseVisitor.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -1,148 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using Remotion.Data.Linq.Clauses; -using Remotion.Data.Linq.Clauses.Expressions; -using Remotion.Data.Linq.Clauses.ResultOperators; -using Remotion.Data.Linq.Parsing; - -namespace NHibernate.Linq -{ - internal class GroupBySelectClauseVisitor : ExpressionTreeVisitor - { - public static Expression Visit(Expression expression) - { - var visitor = new GroupBySelectClauseVisitor(); - return visitor.VisitExpression(expression); - } - - protected override Expression VisitMemberExpression(MemberExpression expression) - { - if (expression.Member.Name == "Key" && - expression.Member.DeclaringType.GetGenericTypeDefinition() == typeof (IGrouping<,>)) - { - var querySourceRef = expression.Expression as QuerySourceReferenceExpression; - - var fromClause = querySourceRef.ReferencedQuerySource as FromClauseBase; - - var subQuery = fromClause.FromExpression as SubQueryExpression; - - var groupBy = - subQuery.QueryModel.ResultOperators.Where(r => r is GroupResultOperator).Single() as - GroupResultOperator; - - return groupBy.KeySelector; - } - else - { - return base.VisitMemberExpression(expression); - } - } - - protected override Expression VisitSubQueryExpression(SubQueryExpression expression) - { - if (expression.QueryModel.ResultOperators.Count == 1) - { - ResultOperatorBase resultOperator = expression.QueryModel.ResultOperators[0]; - - if (resultOperator is AverageResultOperator) - { - return new AverageExpression(expression.QueryModel.SelectClause.Selector); - } - else if (resultOperator is MinResultOperator) - { - return new MinExpression(expression.QueryModel.SelectClause.Selector); - } - else if (resultOperator is MaxResultOperator) - { - return new MaxExpression(expression.QueryModel.SelectClause.Selector); - } - else if (resultOperator is CountResultOperator) - { - return new CountExpression(); - } - else if (resultOperator is SumResultOperator) - { - return new SumExpression(expression.QueryModel.SelectClause.Selector); - } - else - { - throw new NotImplementedException(); - } - } - else - { - return base.VisitSubQueryExpression(expression); - } - } - } - - public enum NhExpressionType - { - Average = 10000, - Min, - Max, - Sum, - Count, - Distinct - } - - public class NhAggregatedExpression : Expression - { - public Expression Expression { get; set; } - - public NhAggregatedExpression(Expression expression, NhExpressionType type) - : base((ExpressionType)type, expression.Type) - { - Expression = expression; - } - } - - public class AverageExpression : NhAggregatedExpression - { - public AverageExpression(Expression expression) : base(expression, NhExpressionType.Average) - { - } - } - - public class MinExpression : NhAggregatedExpression - { - public MinExpression(Expression expression) - : base(expression, NhExpressionType.Min) - { - } - } - - public class MaxExpression : NhAggregatedExpression - { - public MaxExpression(Expression expression) - : base(expression, NhExpressionType.Max) - { - } - } - - public class SumExpression : NhAggregatedExpression - { - public SumExpression(Expression expression) - : base(expression, NhExpressionType.Sum) - { - } - } - - public class DistinctExpression : NhAggregatedExpression - { - public DistinctExpression(Expression expression) - : base(expression, NhExpressionType.Distinct) - { - } - } - - public class CountExpression : Expression - { - public CountExpression() - : base((ExpressionType)NhExpressionType.Count, typeof(int)) - { - } - } -} Deleted: trunk/nhibernate/src/NHibernate/Linq/GroupBySelectorVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/GroupBySelectorVisitor.cs 2009-09-24 11:22:59 UTC (rev 4724) +++ trunk/nhibernate/src/NHibernate/Linq/GroupBySelectorVisitor.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -1,26 +0,0 @@ -using System.Linq.Expressions; -using Remotion.Data.Linq.Clauses.Expressions; -using Remotion.Data.Linq.Parsing; - -namespace NHibernate.Linq -{ - internal class GroupBySelectorVisitor : ExpressionTreeVisitor - { - private readonly ParameterExpression _parameter; - - public GroupBySelectorVisitor(ParameterExpression parameter) - { - _parameter = parameter; - } - - public Expression Visit(Expression expression) - { - return VisitExpression(expression); - } - - protected override Expression VisitQuerySourceReferenceExpression(QuerySourceReferenceExpression expression) - { - return _parameter; - } - } -} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/HqlGeneratorExpressionTreeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/HqlGeneratorExpressionTreeVisitor.cs 2009-09-24 11:22:59 UTC (rev 4724) +++ trunk/nhibernate/src/NHibernate/Linq/HqlGeneratorExpressionTreeVisitor.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -31,7 +31,7 @@ VisitExpression(expression); } - protected override Expression VisitNhAverage(AverageExpression expression) + protected override Expression VisitNhAverage(NhAverageExpression expression) { var visitor = new HqlGeneratorExpressionTreeVisitor(_parameterAggregator); visitor.Visit(expression.Expression); @@ -41,14 +41,17 @@ return expression; } - protected override Expression VisitNhCount(CountExpression expression) + protected override Expression VisitNhCount(NhCountExpression expression) { - _stack.PushLeaf(_hqlTreeBuilder.Cast(_hqlTreeBuilder.Count(_hqlTreeBuilder.RowStar()), expression.Type)); + var visitor = new HqlGeneratorExpressionTreeVisitor(_parameterAggregator); + visitor.Visit(expression.Expression); + _stack.PushLeaf(_hqlTreeBuilder.Cast(_hqlTreeBuilder.Count(visitor.GetHqlTreeNodes().Single()), expression.Type)); + return expression; } - protected override Expression VisitNhMin(MinExpression expression) + protected override Expression VisitNhMin(NhMinExpression expression) { var visitor = new HqlGeneratorExpressionTreeVisitor(_parameterAggregator); visitor.Visit(expression.Expression); @@ -58,7 +61,7 @@ return expression; } - protected override Expression VisitNhMax(MaxExpression expression) + protected override Expression VisitNhMax(NhMaxExpression expression) { var visitor = new HqlGeneratorExpressionTreeVisitor(_parameterAggregator); visitor.Visit(expression.Expression); @@ -68,7 +71,7 @@ return expression; } - protected override Expression VisitNhSum(SumExpression expression) + protected override Expression VisitNhSum(NhSumExpression expression) { var visitor = new HqlGeneratorExpressionTreeVisitor(_parameterAggregator); visitor.Visit(expression.Expression); @@ -78,7 +81,7 @@ return expression; } - protected override Expression VisitNhDistinct(DistinctExpression expression) + protected override Expression VisitNhDistinct(NhDistinctExpression expression) { var visitor = new HqlGeneratorExpressionTreeVisitor(_parameterAggregator); visitor.Visit(expression.Expression); Added: trunk/nhibernate/src/NHibernate/Linq/MergeAggregatingResultsRewriter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/MergeAggregatingResultsRewriter.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/MergeAggregatingResultsRewriter.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -0,0 +1,123 @@ +using System; +using System.Linq; +using System.Linq.Expressions; +using Remotion.Data.Linq; +using Remotion.Data.Linq.Clauses; +using Remotion.Data.Linq.Clauses.Expressions; +using Remotion.Data.Linq.Clauses.ResultOperators; +using Remotion.Data.Linq.Parsing; +using Remotion.Data.Linq.Parsing.ExpressionTreeVisitors; + +namespace NHibernate.Linq +{ + public class MergeAggregatingResultsRewriter : QueryModelVisitorBase + { + public void ReWrite(QueryModel model) + { + this.VisitQueryModel(model); + } + + public override void VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, int index) + { + if (resultOperator is SumResultOperator) + { + queryModel.SelectClause.Selector = new NhSumExpression(queryModel.SelectClause.Selector); + queryModel.ResultOperators.Remove(resultOperator); + } + else if (resultOperator is AverageResultOperator) + { + queryModel.SelectClause.Selector = new NhAverageExpression(queryModel.SelectClause.Selector); + queryModel.ResultOperators.Remove(resultOperator); + } + else if (resultOperator is MinResultOperator) + { + queryModel.SelectClause.Selector = new NhMinExpression(queryModel.SelectClause.Selector); + queryModel.ResultOperators.Remove(resultOperator); + } + else if (resultOperator is MaxResultOperator) + { + queryModel.SelectClause.Selector = new NhMaxExpression(queryModel.SelectClause.Selector); + queryModel.ResultOperators.Remove(resultOperator); + } + else if (resultOperator is DistinctResultOperator) + { + queryModel.SelectClause.Selector = new NhDistinctExpression(queryModel.SelectClause.Selector); + queryModel.ResultOperators.Remove(resultOperator); + } + else if (resultOperator is CountResultOperator) + { + queryModel.SelectClause.Selector = new NhCountExpression(queryModel.SelectClause.Selector); + queryModel.ResultOperators.Remove(resultOperator); + } + + base.VisitResultOperator(resultOperator, queryModel, index); + } + + public override void VisitSelectClause(SelectClause selectClause, QueryModel queryModel) + { + selectClause.TransformExpressions(s => new MergeAggregatingResultsInExpressionRewriter().Visit(s)); + } + } + + internal class MergeAggregatingResultsInExpressionRewriter : NhExpressionTreeVisitor + { + public Expression Visit(Expression expression) + { + return VisitExpression(expression); + } + + protected override Expression VisitSubQueryExpression(SubQueryExpression expression) + { + new MergeAggregatingResultsRewriter().ReWrite(expression.QueryModel); + return expression; + } + + protected override Expression VisitMethodCallExpression(MethodCallExpression m) + { + if (m.Method.DeclaringType == typeof(Queryable) || + m.Method.DeclaringType == typeof(Enumerable)) + { + // TODO - dynamic name generation needed here + switch (m.Method.Name) + { + case "Count": + return CreateAggregate(m.Arguments[0], (LambdaExpression)m.Arguments[1], + e => new NhCountExpression(e)); + case "Min": + return CreateAggregate(m.Arguments[0], (LambdaExpression) m.Arguments[1], + e => new NhMinExpression(e)); + case "Max": + return CreateAggregate(m.Arguments[0], (LambdaExpression)m.Arguments[1], + e => new NhMaxExpression(e)); + case "Sum": + return CreateAggregate(m.Arguments[0], (LambdaExpression)m.Arguments[1], + e => new NhSumExpression(e)); + case "Average": + return CreateAggregate(m.Arguments[0], (LambdaExpression)m.Arguments[1], + e => new NhAverageExpression(e)); + } + } + + return base.VisitMethodCallExpression(m); + } + + private Expression CreateAggregate(Expression fromClauseExpression, LambdaExpression body, Func<Expression,Expression> factory) + { + var fromClause = new MainFromClause("x2", body.Parameters[0].Type, fromClauseExpression); + var selectClause = body.Body; + selectClause = ReplacingExpressionTreeVisitor.Replace(body.Parameters[0], + new QuerySourceReferenceExpression( + fromClause), selectClause); + var queryModel = new QueryModel(fromClause, + new SelectClause(factory(selectClause))); + + queryModel.ResultOperators.Add(new AverageResultOperator()); + + var subQuery = new SubQueryExpression(queryModel); + + queryModel.ResultOperators.Clear(); + + return subQuery; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/NhExpressionTreeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/NhExpressionTreeVisitor.cs 2009-09-24 11:22:59 UTC (rev 4724) +++ trunk/nhibernate/src/NHibernate/Linq/NhExpressionTreeVisitor.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -1,3 +1,4 @@ +using System; using System.Linq.Expressions; using Remotion.Data.Linq.Parsing; @@ -7,63 +8,79 @@ { protected override Expression VisitExpression(Expression expression) { + if (expression == null) + { + return null; + } + switch ((NhExpressionType) expression.NodeType) { case NhExpressionType.Average: - return VisitNhAverage((AverageExpression) expression); + return VisitNhAverage((NhAverageExpression) expression); case NhExpressionType.Min: - return VisitNhMin((MinExpression)expression); + return VisitNhMin((NhMinExpression)expression); case NhExpressionType.Max: - return VisitNhMax((MaxExpression)expression); + return VisitNhMax((NhMaxExpression)expression); case NhExpressionType.Sum: - return VisitNhSum((SumExpression)expression); + return VisitNhSum((NhSumExpression)expression); case NhExpressionType.Count: - return VisitNhCount((CountExpression)expression); + return VisitNhCount((NhCountExpression)expression); case NhExpressionType.Distinct: - return VisitNhDistinct((DistinctExpression) expression); + return VisitNhDistinct((NhDistinctExpression) expression); + case NhExpressionType.New: + return VisitNhNew((NhNewExpression) expression); } return base.VisitExpression(expression); } - protected virtual Expression VisitNhDistinct(DistinctExpression expression) + private Expression VisitNhNew(NhNewExpression expression) { + var arguments = VisitExpressionList(expression.Arguments); + + return arguments != expression.Arguments ? new NhNewExpression(expression.Members, arguments) : expression; + } + + protected virtual Expression VisitNhDistinct(NhDistinctExpression expression) + { Expression nx = base.VisitExpression(expression.Expression); - return nx != expression.Expression ? new DistinctExpression(nx) : expression; + return nx != expression.Expression ? new NhDistinctExpression(nx) : expression; } - protected virtual Expression VisitNhCount(CountExpression expression) + protected virtual Expression VisitNhCount(NhCountExpression expression) { - return expression; + Expression nx = base.VisitExpression(expression.Expression); + + return nx != expression.Expression ? new NhCountExpression(nx) : expression; } - protected virtual Expression VisitNhSum(SumExpression expression) + protected virtual Expression VisitNhSum(NhSumExpression expression) { Expression nx = base.VisitExpression(expression.Expression); - return nx != expression.Expression ? new SumExpression(nx) : expression; + return nx != expression.Expression ? new NhSumExpression(nx) : expression; } - protected virtual Expression VisitNhMax(MaxExpression expression) + protected virtual Expression VisitNhMax(NhMaxExpression expression) { Expression nx = base.VisitExpression(expression.Expression); - return nx != expression.Expression ? new MaxExpression(nx) : expression; + return nx != expression.Expression ? new NhMaxExpression(nx) : expression; } - protected virtual Expression VisitNhMin(MinExpression expression) + protected virtual Expression VisitNhMin(NhMinExpression expression) { Expression nx = base.VisitExpression(expression.Expression); - return nx != expression.Expression ? new MinExpression(nx) : expression; + return nx != expression.Expression ? new NhMinExpression(nx) : expression; } - protected virtual Expression VisitNhAverage(AverageExpression expression) + protected virtual Expression VisitNhAverage(NhAverageExpression expression) { Expression nx = base.VisitExpression(expression.Expression); - return nx != expression.Expression ? new AverageExpression(nx) : expression; + return nx != expression.Expression ? new NhAverageExpression(nx) : expression; } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Linq/NhNewExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/NhNewExpression.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Linq/NhNewExpression.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Linq.Expressions; + +namespace NHibernate.Linq +{ + public class NhNewExpression : Expression + { + private readonly ReadOnlyCollection<string> _members; + private readonly ReadOnlyCollection<Expression> _arguments; + + public NhNewExpression(IList<string> members, IList<Expression> arguments) + : base((ExpressionType)NhExpressionType.New, typeof(object)) + { + _members = new ReadOnlyCollection<string>(members); + _arguments = new ReadOnlyCollection<Expression>(arguments); + } + + public ReadOnlyCollection<Expression> Arguments + { + get { return _arguments; } + } + + public ReadOnlyCollection<string> Members + { + get { return _members; } + } + } +} Modified: trunk/nhibernate/src/NHibernate/Linq/NhThrowingExpressionTreeVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/NhThrowingExpressionTreeVisitor.cs 2009-09-24 11:22:59 UTC (rev 4724) +++ trunk/nhibernate/src/NHibernate/Linq/NhThrowingExpressionTreeVisitor.cs 2009-09-25 21:04:56 UTC (rev 4725) @@ -1,4 +1,3 @@ -using System; using System.Linq.Expressions; using Remotion.Data.Linq.Parsing; @@ -11,91 +10,106 @@ switch ((NhExpressionType)expression.NodeType) { case NhExpressionType.Average: - return VisitNhAverage((AverageExpression)expression); + return VisitNhAverage((NhAverageExpression)expression); case NhExpressionType.Min: - return VisitNhMin((MinExpression)expression); + return VisitNhMin((NhMinExpression)expression); case NhExpressionType.Max: - return VisitNhMax((MaxExpression)expression); + return VisitNhMax((NhMaxExpression)expression); case NhExpressionType.Sum: - return VisitNhSum((SumExpression)expression); + return VisitNhSum((NhSumExpression)expression); case NhExpressionType.Count: - return VisitNhCount((CountExpression)expression); + return VisitNhCount((NhCountExpression)expression); case NhExpressionType.Distinct: - return VisitNhDistinct((DistinctExpression) expression); + return VisitNhDistinct((NhDistinctExpression) expression); + case NhExpressionType.New: + return VisitNhNew((NhNewExpression) expression); } return base.VisitExpression(expression); } - protected virtual Expression VisitNhDistinct(DistinctExpression expression) + protected virtual Expression VisitNhNew(NhNewExpression expression) { - return VisitUnhandledItem<DistinctExpression, Expression>(expression, "VisitNhDistinct", BaseVisitNhDistinct); + return VisitUnhandledItem<NhNewExpression, Expression>(expression, "VisitNhNew", BaseVisitNhNew); } - protected virtual Expression VisitNhAverage(AverageExpression expression) + protected virtual Expression VisitNhDistinct(NhDistinctExpression expression) { - return VisitUnhandledItem<AverageExpression, Expression>(expression, "VisitNhAverage", BaseVisitNhAverage); + return VisitUnhandledItem<NhDistinctExpression, Expression>(expression, "VisitNhDistinct", BaseVisitNhDistinct); } - protected virtual Expression VisitNhMin(MinExpression expression) + protected virtual Expression VisitNhAverage(NhAverageExpression expression) { - return VisitUnhandledItem<MinExpression, Expression>(expression, "VisitNhMin", BaseVisitNhMin); + return VisitUnhandledItem<NhAverageExpression, Expression>(expression, "VisitNhAverage", BaseVisitNhAverage); } - protected virtual Expression VisitNhMax(MaxExpression expression) + protected virtual Expression VisitNhMin(NhMinExpression expression) { - return VisitUnhandledItem<MaxExpression, Expression>(expression, "VisitNhMax", BaseVisitNhMax); + return VisitUnhandledItem<NhMinExpression, Expression>(expression, "VisitNhMin", BaseVisitNhMin); } - protected virtual Expression VisitNhSum(SumExpression expression) + protected virtual Expression VisitNhMax(NhMaxExpression expression) { - return VisitUnhandledItem<SumExpression, Expression>(expression, "VisitNhSum", BaseVisitNhSum); + return VisitUnhandledItem<NhMaxExpression, Expression>(expression, "VisitNhMax", BaseVisitNhMax); } - protected virtual Expression VisitNhCount(CountExpression expression) + protected virtual Expression VisitNhSum(NhSumExpression expression) { - return VisitUnhandledItem<CountExpression, Expression>(expression, "VisitNhCount", BaseVisitNhCount); + return VisitUnhandledItem<NhSumExpression, Expression>(expression, "VisitNhSum", BaseVisitNhSum); } - protected virtual Expression BaseVisitNhCount(CountExpression expression) + protected virtual Expression VisitNhCount(NhCountExpression expression) { - return expression; + return VisitUnhandledItem<NhCountExpression, Expression>(expression, "VisitNhCount", BaseVisitNhCount); } - protected virtual Expression BaseVisitNhSum(SumExpression expression) + protected virtual Expression BaseVisitNhCount(NhCountExpression expression) { Expression nx = base.VisitExpression(expression.Expression); - return nx != expression.Expression ? new SumExpression(nx) : expression; + return nx != expression.Expression ? new NhCountExpression(nx) : expression; } - protected virtual Expression BaseVisitNhMax(MaxExpression expression) + protected virtual Expression BaseVisitNhSum(NhSumExpression expression) { Expression nx = base.VisitExpression(expression.Expression); - return nx != expression.Expression ? new MaxExpression(nx) : expression; + return nx != expression.Expression ? new NhSumExpression(nx) : expression; } - protected virtual Expression BaseVisitNhMin(MinExpression expression) + protected virtual Expression BaseVisitNhMax(NhMaxExpression expression) { Expression nx = base.VisitExpression(expression.Expression); - return nx != expression.Expression ? new MinExpression(nx) : expression; + return nx != expression.Expression ? new NhMaxExpression(nx) : expression; } - protected virtual Expression BaseVisitNhAverage(AverageExpression expression) + protected virtual Expression BaseVisitNhMin(NhMinExpression expression) { Expression nx = base.VisitExpression(expression.Expression); - return nx != expression.Expression ? new AverageExpression(nx) : expression; + return nx != expression.Expression ? new NhMinExpression(nx) : expression; } - private Expression BaseVisitNhDistinct(DistinctExpression expression) + protected virtual Expression BaseVisitNhAverage(NhAverageExpression expression) { Expression nx = base.VisitExpression(expression.Expression); - return nx != expression.Expression ? new DistinctExpression(nx) : expression; + ... [truncated message content] |
From: <ric...@us...> - 2009-09-26 12:07:51
|
Revision: 4728 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4728&view=rev Author: ricbrown Date: 2009-09-26 12:07:41 +0000 (Sat, 26 Sep 2009) Log Message: ----------- Fix NH-1975, using primitive with QueryOver. Patch supplied by Ken Tong. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs 2009-09-25 21:59:02 UTC (rev 4727) +++ trunk/nhibernate/src/NHibernate/Impl/ExpressionProcessor.cs 2009-09-26 12:07:41 UTC (rev 4728) @@ -261,6 +261,9 @@ if (type.IsEnum) return Enum.ToObject(type, value); + if (type.IsPrimitive) + return Convert.ChangeType(value, type); + throw new Exception("Cannot convert '" + value.ToString() + "' to " + type.ToString()); } Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml 2009-09-25 21:59:02 UTC (rev 4727) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml 2009-09-26 12:07:41 UTC (rev 4728) @@ -9,6 +9,7 @@ </id> <property name="Name" /> <property name="Age" /> + <property name="Blood" /> </class> <class name="Child"> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-09-25 21:59:02 UTC (rev 4727) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-09-26 12:07:41 UTC (rev 4728) @@ -23,6 +23,7 @@ public virtual bool HasCar { get; set; } public virtual Person Father { get; set; } public virtual bool IsParent { get; set; } + public virtual char Blood { get; set; } public virtual IEnumerable<Child> Children { get; set; } public virtual IList<Person> PersonList { get; set; } Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-09-25 21:59:02 UTC (rev 4727) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-09-26 12:07:41 UTC (rev 4728) @@ -67,6 +67,22 @@ } [Test] + public void SimpleCriterion_Char() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .Add(Restrictions.Eq("Blood", 'A')) + .Add(Restrictions.Not(Restrictions.Eq("Blood", 'B'))); + + IQueryOver<Person> actual = + CreateTestQueryOver<Person>() + .And(p => p.Blood == 'A') + .And(p => p.Blood != 'B'); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] public void MultipleCriterionExpression() { ICriteria expected = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-09-27 10:07:02
|
Revision: 4730 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4730&view=rev Author: ricbrown Date: 2009-09-27 10:06:52 +0000 (Sun, 27 Sep 2009) Log Message: ----------- Merge r4729 (Fix NH-1959, add/remove from IdBag causing KeyNotFoundException) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959/Model.cs Modified: trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs 2009-09-27 10:06:11 UTC (rev 4729) +++ trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs 2009-09-27 10:06:52 UTC (rev 4730) @@ -290,6 +290,9 @@ protected void BeforeRemove(int index) { + if (!identifiers.ContainsKey(index)) + return; // index not previously persisted, nothing to do + // Move the identifier being removed to the end of the list (i.e. it isn't actually removed). object removedId = identifiers[index]; int last = values.Count - 1; Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959 ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959/Fixture.cs 2009-09-27 10:06:52 UTC (rev 4730) @@ -0,0 +1,74 @@ +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1959 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + protected override void OnTearDown() + { + using (ISession s = OpenSession()) + using(ITransaction tx = s.BeginTransaction()) + { + s.Delete("from ClassB"); + s.Delete("from ClassA"); + tx.Commit(); + } + } + + [Test] + public void StartWithEmptyDoAddAndRemove() + { + ClassB b = new ClassB(); + ClassA a = new ClassA(); + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Save(a); + s.Save(b); + tx.Commit(); + } + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + ClassA loadedA = s.Get<ClassA>(a.Id); + ClassB loadedB = s.Get<ClassB>(b.Id); + loadedA.TheBag.Add(loadedB); + loadedA.TheBag.Remove(loadedB); + tx.Commit(); + } + + using (ISession s = OpenSession()) + Assert.AreEqual(0, s.Get<ClassA>(a.Id).TheBag.Count); + } + + [Test] + public void StartWithEmptyDoAddAndRemoveAt() + { + ClassB b = new ClassB(); + ClassA a = new ClassA(); + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Save(a); + s.Save(b); + tx.Commit(); + } + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + ClassA loadedA = s.Get<ClassA>(a.Id); + ClassB loadedB = s.Get<ClassB>(b.Id); + loadedA.TheBag.Add(loadedB); + loadedA.TheBag.RemoveAt(0); + tx.Commit(); + } + + using (ISession s = OpenSession()) + Assert.AreEqual(0, s.Get<ClassA>(a.Id).TheBag.Count); + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959/Mappings.hbm.xml 2009-09-27 10:06:52 UTC (rev 4730) @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1959" + assembly="NHibernate.Test"> + + <class name="ClassA"> + <id name="Id"> + <generator class="guid.comb"/> + </id> + <idbag name="TheBag"> + <collection-id column="collection_id" type="guid"> + <generator class="guid.comb"/> + </collection-id> + <key> + <column name="classA" not-null="true" /> + </key> + <many-to-many class="ClassB"> + <column name="classB" not-null="true" /> + </many-to-many> + </idbag> + </class> + + <class name="ClassB"> + <id name="Id"> + <generator class="guid.comb"/> + </id> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1959/Model.cs 2009-09-27 10:06:52 UTC (rev 4730) @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1959 +{ + public class ClassA + { + public virtual Guid Id { get; set; } + public virtual IList<ClassB> TheBag { get; set; } + + public ClassA() + { + TheBag = new List<ClassB>(); + } + } + + public class ClassB + { + public virtual Guid Id { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-27 10:06:11 UTC (rev 4729) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-27 10:06:52 UTC (rev 4730) @@ -608,6 +608,8 @@ <Compile Include="NHSpecificTest\NH1941\SexEnumStringType.cs" /> <Compile Include="NHSpecificTest\NH1948\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1948\Model.cs" /> + <Compile Include="NHSpecificTest\NH1959\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1959\Model.cs" /> <Compile Include="NHSpecificTest\NH1963\CacheableQueryOnByteArray.cs" /> <Compile Include="NHSpecificTest\NH1963\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1969\DummyEntity.cs" /> @@ -2027,6 +2029,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1959\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1948\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1941\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1963\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-09-28 17:04:24
|
Revision: 4731 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4731&view=rev Author: steverstrong Date: 2009-09-28 17:04:14 +0000 (Mon, 28 Sep 2009) Log Message: ----------- Changes to Linq execution to tie in with HQLQueryPlan caching Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs trunk/nhibernate/src/NHibernate/IQueryExpression.cs trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/QueryImpl.cs trunk/nhibernate/src/NHibernate/Linq/CommandData.cs trunk/nhibernate/src/NHibernate/Linq/NhQueryable.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs trunk/nhibernate/src/NHibernate.Test/Linq/ReadonlyTestCase.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlExpression.cs trunk/nhibernate/src/NHibernate/Linq/NhQueryExecutor.cs Modified: trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs 2009-09-27 10:06:52 UTC (rev 4730) +++ trunk/nhibernate/src/NHibernate/Engine/Query/HQLQueryPlan.cs 2009-09-28 17:04:14 UTC (rev 4731) @@ -28,8 +28,9 @@ private readonly HashedSet<string> enabledFilterNames; private readonly bool shallow; + private IQueryExpression sourceQueryExpression; - public HQLQueryPlan(string hql, bool shallow, + public HQLQueryPlan(string hql, bool shallow, IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory) : this(hql, (string) null, shallow, enabledFilters, factory) { @@ -110,6 +111,7 @@ protected internal HQLQueryPlan(string expressionStr, IQueryExpression queryExpression, string collectionRole, bool shallow, IDictionary<string, IFilter> enabledFilters, ISessionFactoryImplementor factory) { + sourceQueryExpression = queryExpression; sourceQuery = expressionStr; this.shallow = shallow; @@ -192,7 +194,12 @@ } } - private static ParameterMetadata BuildParameterMetadata(IParameterTranslations parameterTranslations, string hql) + public IQueryExpression QueryExpression + { + get { return sourceQueryExpression; } + } + + private static ParameterMetadata BuildParameterMetadata(IParameterTranslations parameterTranslations, string hql) { long start = DateTime.Now.Ticks; ParamLocationRecognizer recognizer = ParamLocationRecognizer.ParseLocations(hql); Modified: trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-09-27 10:06:52 UTC (rev 4730) +++ trunk/nhibernate/src/NHibernate/Engine/Query/QueryPlanCache.cs 2009-09-28 17:04:14 UTC (rev 4731) @@ -86,6 +86,7 @@ log.Debug("unable to locate HQL query plan in cache; generating (" + expressionStr + ")"); } plan = new HQLQueryPlan(expressionStr, queryExpression, shallow, enabledFilters, factory); + planCache.Put(key, plan); } else { @@ -95,8 +96,6 @@ } } - planCache.Put(key, plan); - return plan; } Deleted: trunk/nhibernate/src/NHibernate/Hql/Ast/HqlExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlExpression.cs 2009-09-27 10:06:52 UTC (rev 4730) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/HqlExpression.cs 2009-09-28 17:04:14 UTC (rev 4731) @@ -1,36 +0,0 @@ -using System.Collections.Generic; -using System.Reflection; -using NHibernate.Hql.Ast.ANTLR; -using NHibernate.Hql.Ast.ANTLR.Tree; - -namespace NHibernate.Hql.Ast -{ - public class HqlExpression : IQueryExpression - { - private readonly IASTNode _node; - private readonly System.Type _type; - private readonly string _key; - - public HqlExpression(HqlQuery node, System.Type type) - { - _node = node.AstNode; - _type = type; - _key = _node.ToStringTree(); - } - - public IASTNode Translate(ISessionFactory sessionFactory) - { - return _node; - } - - public string Key - { - get { return _key; } - } - - public System.Type Type - { - get { return _type; } - } - } -} Modified: trunk/nhibernate/src/NHibernate/IQueryExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryExpression.cs 2009-09-27 10:06:52 UTC (rev 4730) +++ trunk/nhibernate/src/NHibernate/IQueryExpression.cs 2009-09-28 17:04:14 UTC (rev 4731) @@ -1,4 +1,6 @@ +using NHibernate.Engine; using NHibernate.Hql.Ast.ANTLR.Tree; +using NHibernate.Impl; namespace NHibernate { @@ -7,5 +9,6 @@ IASTNode Translate(ISessionFactory sessionFactory); string Key { get; } System.Type Type { get; } + void SetQueryParametersPriorToExecute(QueryImpl impl); } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-09-27 10:06:52 UTC (rev 4730) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-09-28 17:04:14 UTC (rev 4731) @@ -252,8 +252,9 @@ using (new SessionIdLoggingContext(SessionId)) { CheckAndUpdateSessionStatus(); - QueryImpl query = new QueryImpl(queryExpression, this, - GetHQLQueryPlan(queryExpression, false).ParameterMetadata); + HQLQueryPlan queryPlan = GetHQLQueryPlan(queryExpression, false); + QueryImpl query = new QueryImpl(queryPlan.QueryExpression, this, + queryPlan.ParameterMetadata); query.SetComment("[expression]"); return query; } Modified: trunk/nhibernate/src/NHibernate/Impl/QueryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/QueryImpl.cs 2009-09-27 10:06:52 UTC (rev 4730) +++ trunk/nhibernate/src/NHibernate/Impl/QueryImpl.cs 2009-09-28 17:04:14 UTC (rev 4731) @@ -74,6 +74,7 @@ } else { + _queryExpression.SetQueryParametersPriorToExecute(this); return Session.List(_queryExpression, GetQueryParameters(namedParams)); } } Modified: trunk/nhibernate/src/NHibernate/Linq/CommandData.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/CommandData.cs 2009-09-27 10:06:52 UTC (rev 4730) +++ trunk/nhibernate/src/NHibernate/Linq/CommandData.cs 2009-09-28 17:04:14 UTC (rev 4731) @@ -8,8 +8,10 @@ { public class CommandData { + private readonly NamedParameter[] _namedParameters; private readonly List<LambdaExpression> _itemTransformers; private readonly List<LambdaExpression> _listTransformers; + private readonly List<Action<IQuery>> _additionalCriteria; public CommandData(HqlQuery statement, NamedParameter[] namedParameters, List<LambdaExpression> itemTransformers, List<LambdaExpression> listTransformers, List<Action<IQuery>> additionalCriteria) { @@ -17,47 +19,29 @@ _listTransformers = listTransformers; Statement = statement; - NamedParameters = namedParameters; - AdditionalCriteria = additionalCriteria; + _namedParameters = namedParameters; + _additionalCriteria = additionalCriteria; } public HqlQuery Statement { get; private set; } - public NamedParameter[] NamedParameters { get; private set; } - public List<Action<IQuery>> AdditionalCriteria { get; set; } - - public System.Type QueryResultType { get; set; } - - public IQuery CreateQuery(ISession session, System.Type type) + public void SetParameters(IQuery query) { - var query = session.CreateQuery(new HqlExpression(Statement, type)); - - SetParameters(query); - - SetResultTransformer(query); - - AddAdditionalCriteria(query); - - return query; - } - - private void SetParameters(IQuery query) - { - foreach (var parameter in NamedParameters) + foreach (var parameter in _namedParameters) { query.SetParameter(parameter.Name, parameter.Value); } } - private void AddAdditionalCriteria(IQuery query) + public void AddAdditionalCriteria(IQuery query) { - foreach (var criteria in AdditionalCriteria) + foreach (var criteria in _additionalCriteria) { criteria(query); } } - private void SetResultTransformer(IQuery query) + public void SetResultTransformer(IQuery query) { var itemTransformer = MergeLambdas(_itemTransformers); var listTransformer = MergeLambdas(_listTransformers); Deleted: trunk/nhibernate/src/NHibernate/Linq/NhQueryExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/NhQueryExecutor.cs 2009-09-27 10:06:52 UTC (rev 4730) +++ trunk/nhibernate/src/NHibernate/Linq/NhQueryExecutor.cs 2009-09-28 17:04:14 UTC (rev 4731) @@ -1,39 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Remotion.Data.Linq; - -namespace NHibernate.Linq -{ - public class NhQueryExecutor : IQueryExecutor - { - private readonly ISession _session; - - public NhQueryExecutor(ISession session) - { - _session = session; - } - - // Executes a query with a scalar result, i.e. a query that ends with a result operator such as Count, Sum, or Average. - public T ExecuteScalar<T>(QueryModel queryModel) - { - return ExecuteCollection<T>(queryModel).Single(); - } - - // Executes a query with a single result object, i.e. a query that ends with a result operator such as First, Last, Single, Min, or Max. - public T ExecuteSingle<T>(QueryModel queryModel, bool returnDefaultWhenEmpty) - { - return returnDefaultWhenEmpty ? ExecuteCollection<T>(queryModel).SingleOrDefault() : ExecuteCollection<T>(queryModel).Single(); - } - - // Executes a query with a collection result. - public IEnumerable<T> ExecuteCollection<T>(QueryModel queryModel) - { - var commandData = QueryModelVisitor.GenerateHqlQuery(queryModel); - - var query = commandData.CreateQuery(_session, typeof(T)); - - // TODO - check which call on Query makes most sense... - return (IEnumerable<T>) query.List(); - } - } -} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Linq/NhQueryable.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Linq/NhQueryable.cs 2009-09-27 10:06:52 UTC (rev 4730) +++ trunk/nhibernate/src/NHibernate/Linq/NhQueryable.cs 2009-09-28 17:04:14 UTC (rev 4731) @@ -1,6 +1,10 @@ +using System; using System.Linq; using System.Linq.Expressions; +using NHibernate.Hql.Ast.ANTLR.Tree; +using NHibernate.Impl; using Remotion.Data.Linq; +using Remotion.Data.Linq.Parsing.Structure; namespace NHibernate.Linq { @@ -9,14 +13,9 @@ /// </summary> public class NhQueryable<T> : QueryableBase<T> { - private static IQueryExecutor CreateExecutor(ISession session) - { - return new NhQueryExecutor(session); - } - // This constructor is called by our users, create a new IQueryExecutor. public NhQueryable(ISession session) - : base(CreateExecutor(session)) + : base(new NhQueryProvider(session)) { } @@ -26,4 +25,95 @@ { } } + + public class NhQueryProvider : IQueryProvider + { + private readonly ISession _session; + + public NhQueryProvider(ISession session) + { + _session = session; + } + + public object Execute(Expression expression) + { + var nhLinqExpression = new NhLinqExpression(expression); + + var query = _session.CreateQuery(nhLinqExpression).List(); + + if (nhLinqExpression.ReturnType == NhLinqExpressionReturnType.Sequence) + { + return query.AsQueryable(); + } + + return query[0]; + } + + public TResult Execute<TResult>(Expression expression) + { + return (TResult) Execute(expression); + } + + public IQueryable CreateQuery(Expression expression) + { + throw new NotImplementedException(); + } + + public IQueryable<T> CreateQuery<T>(Expression expression) + { + return new NhQueryable<T>(this, expression); + } + } + + public enum NhLinqExpressionReturnType + { + Sequence, + Scalar + } + + public class NhLinqExpression : IQueryExpression + { + private readonly Expression _expression; + private CommandData _commandData; + + public NhLinqExpression(Expression expression) + { + _expression = expression; + + Key = expression.ToString(); + + Type = expression.Type; + + // Note - re-linq handles return types via the GetOutputDataInfo method, and allows for SingleOrDefault here for the ChoiceResultOperator... + ReturnType = NhLinqExpressionReturnType.Scalar; + + if (typeof(IQueryable).IsAssignableFrom(Type)) + { + Type = Type.GetGenericArguments()[0]; + ReturnType = NhLinqExpressionReturnType.Sequence; + } + } + + public IASTNode Translate(ISessionFactory sessionFactory) + { + var queryModel = new QueryParser(new ExpressionTreeParser(MethodCallExpressionNodeTypeRegistry.CreateDefault())).GetParsedQuery(_expression); + + _commandData = QueryModelVisitor.GenerateHqlQuery(queryModel); + + return _commandData.Statement.AstNode; + } + + public string Key { get; private set; } + + public NhLinqExpressionReturnType ReturnType { get; private set; } + + public System.Type Type { get; private set; } + + public void SetQueryParametersPriorToExecute(QueryImpl impl) + { + _commandData.SetParameters(impl); + _commandData.SetResultTransformer(impl); + _commandData.AddAdditionalCriteria(impl); + } + } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-09-27 10:06:52 UTC (rev 4730) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-09-28 17:04:14 UTC (rev 4731) @@ -557,7 +557,6 @@ <Compile Include="Hql\Ast\ANTLR\Tree\ASTErrorNode.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\InsertStatement.cs" /> <Compile Include="Hql\Ast\ANTLR\Tree\UpdateStatement.cs" /> - <Compile Include="Hql\Ast\HqlExpression.cs" /> <Compile Include="Hql\Ast\HqlTreeBuilder.cs" /> <Compile Include="Hql\Ast\HqlTreeNode.cs" /> <Compile Include="IQueryExpression.cs" /> @@ -581,7 +580,6 @@ <Compile Include="Linq\NhExpressionTreeVisitor.cs" /> <Compile Include="Linq\NhNewExpression.cs" /> <Compile Include="Linq\NhQueryable.cs" /> - <Compile Include="Linq\NhQueryExecutor.cs" /> <Compile Include="Linq\NhThrowingExpressionTreeVisitor.cs" /> <Compile Include="Linq\Nominator.cs" /> <Compile Include="Linq\NonAggregatingGroupBy.cs" /> Modified: trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs 2009-09-27 10:06:52 UTC (rev 4730) +++ trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs 2009-09-28 17:04:14 UTC (rev 4731) @@ -13,6 +13,16 @@ private Northwind _northwind; private ISession _session; + protected override bool PerformDbDataSetup + { + get { return true; } + } + + protected override bool PerformDbDataTeardown + { + get { return true; } + } + protected override string MappingsAssembly { get { return "NHibernate.Test"; } Modified: trunk/nhibernate/src/NHibernate.Test/Linq/ReadonlyTestCase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/ReadonlyTestCase.cs 2009-09-27 10:06:52 UTC (rev 4730) +++ trunk/nhibernate/src/NHibernate.Test/Linq/ReadonlyTestCase.cs 2009-09-28 17:04:14 UTC (rev 4731) @@ -63,6 +63,9 @@ get { return "NHibernate.DomainModel"; } } + protected abstract bool PerformDbDataSetup { get; } + protected abstract bool PerformDbDataTeardown { get; } + static ReadonlyTestCase() { // Configure log4net here since configuration through an attribute doesn't always work. @@ -84,7 +87,12 @@ } BuildSessionFactory(); - CreateSchema(); + + if (PerformDbDataSetup) + { + CreateSchema(); + } + if (!AppliesTo(_sessions)) { DropSchema(); @@ -92,7 +100,10 @@ Assert.Ignore(GetType() + " does not apply with the current session-factory configuration"); } - OnFixtureSetup(); + if (PerformDbDataSetup) + { + OnFixtureSetup(); + } } catch (Exception e) { @@ -114,8 +125,12 @@ public void TestFixtureTearDown() { OnFixtureTeardown(); - - DropSchema(); + + if (PerformDbDataTeardown) + { + DropSchema(); + } + Cleanup(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-09-30 09:40:15
|
Revision: 4732 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4732&view=rev Author: ricbrown Date: 2009-09-30 09:40:08 +0000 (Wed, 30 Sep 2009) Log Message: ----------- Added IQueryOver.Lock(...) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Criterion/QueryOverLockBuilder.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-09-28 17:04:14 UTC (rev 4731) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-09-30 09:40:08 UTC (rev 4732) @@ -128,6 +128,16 @@ return new QueryOverFetchBuilder<T>(this, path); } + public QueryOverLockBuilder<T> Lock() + { + return new QueryOverLockBuilder<T>(this, null); + } + + public QueryOverLockBuilder<T> Lock(Expression<Func<object>> alias) + { + return new QueryOverLockBuilder<T>(this, alias); + } + public QueryOver<U> JoinQueryOver<U>(Expression<Func<T, U>> path) { return new QueryOver<U>(_impl, @@ -314,6 +324,12 @@ IQueryOverFetchBuilder<T> IQueryOver<T>.Fetch(Expression<Func<T, object>> path) { return new IQueryOverFetchBuilder<T>(this, path); } + IQueryOverLockBuilder<T> IQueryOver<T>.Lock() + { return new IQueryOverLockBuilder<T>(this, null); } + + IQueryOverLockBuilder<T> IQueryOver<T>.Lock(Expression<Func<object>> alias) + { return new IQueryOverLockBuilder<T>(this, alias); } + IQueryOver<U> IQueryOver<T>.JoinQueryOver<U>(Expression<Func<T, U>> path) { return JoinQueryOver(path); } Added: trunk/nhibernate/src/NHibernate/Criterion/QueryOverLockBuilder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOverLockBuilder.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOverLockBuilder.cs 2009-09-30 09:40:08 UTC (rev 4732) @@ -0,0 +1,106 @@ + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; + +using NHibernate.Impl; +using NHibernate.SqlCommand; + +namespace NHibernate.Criterion +{ + + public class QueryOverLockBuilder<T> : QueryOverLockBuilderBase<QueryOver<T>, T> + { + + public QueryOverLockBuilder(QueryOver<T> root, Expression<Func<object>> alias) + : base(root, alias) { } + + } + + public class IQueryOverLockBuilder<T> : QueryOverLockBuilderBase<IQueryOver<T>, T> + { + + public IQueryOverLockBuilder(IQueryOver<T> root, Expression<Func<object>> alias) + : base(root, alias) { } + + } + + public class QueryOverLockBuilderBase<R, T> where R : IQueryOver<T> + { + + protected R root; + protected string alias; + + protected QueryOverLockBuilderBase(R root, Expression<Func<object>> alias) + { + this.root = root; + + if (alias != null) + this.alias = ExpressionProcessor.FindMemberExpression(alias.Body); + } + + private void SetLockMode(LockMode lockMode) + { + if (alias != null) + root.UnderlyingCriteria.SetLockMode(alias, lockMode); + else + root.UnderlyingCriteria.SetLockMode(lockMode); + } + + public R Force + { + get + { + SetLockMode(LockMode.Force); + return this.root; + } + } + + public R None + { + get + { + SetLockMode(LockMode.None); + return this.root; + } + } + + public R Read + { + get + { + SetLockMode(LockMode.Read); + return this.root; + } + } + + public R Upgrade + { + get + { + SetLockMode(LockMode.Upgrade); + return this.root; + } + } + + public R UpgradeNoWait + { + get + { + SetLockMode(LockMode.UpgradeNoWait); + return this.root; + } + } + + public R Write + { + get + { + SetLockMode(LockMode.Write); + return this.root; + } + } + + } + +} Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-09-28 17:04:14 UTC (rev 4731) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-09-30 09:40:08 UTC (rev 4732) @@ -130,6 +130,16 @@ IQueryOverFetchBuilder<T> Fetch(Expression<Func<T, object>> path); /// <summary> + /// Set the lock mode of the current entity + /// </summary> + IQueryOverLockBuilder<T> Lock(); + + /// <summary> + /// Set the lock mode of the aliased entity + /// </summary> + IQueryOverLockBuilder<T> Lock(Expression<Func<object>> alias); + + /// <summary> /// Creates a new NHibernate.ICriteria<T>, "rooted" at the associated entity /// </summary> /// <typeparam name="U">Type of sub-criteria</typeparam> Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-09-28 17:04:14 UTC (rev 4731) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-09-30 09:40:08 UTC (rev 4732) @@ -507,6 +507,7 @@ <Compile Include="Criterion\IPropertyProjection.cs" /> <Compile Include="Criterion\QueryOverFetchBuilder.cs" /> <Compile Include="Criterion\QueryOverJoinBuilder.cs" /> + <Compile Include="Criterion\QueryOverLockBuilder.cs" /> <Compile Include="Criterion\QueryOverOrderBuilder.cs" /> <Compile Include="Dialect\MsSql2008Dialect.cs" /> <Compile Include="Dialect\InformixDialect0940.cs" /> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-09-28 17:04:14 UTC (rev 4731) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-09-30 09:40:08 UTC (rev 4732) @@ -347,6 +347,35 @@ AssertCriteriaAreEqual(expected, actual); } + [Test] + public void LockAll() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .SetLockMode(LockMode.UpgradeNoWait); + + IQueryOver<Person> actual = + CreateTestQueryOver<Person>() + .Lock().UpgradeNoWait; + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] + public void LockAlias() + { + ICriteria expected = + CreateTestCriteria(typeof(Person), "personAlias") + .SetLockMode("personAlias", LockMode.UpgradeNoWait); + + Person personAlias = null; + IQueryOver<Person> actual = + CreateTestQueryOver<Person>(() => personAlias) + .Lock(() => personAlias).UpgradeNoWait; + + AssertCriteriaAreEqual(expected, actual); + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-09-30 10:29:49
|
Revision: 4733 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4733&view=rev Author: ricbrown Date: 2009-09-30 10:29:35 +0000 (Wed, 30 Sep 2009) Log Message: ----------- Added arbitrary ICriterion to IQueryOver (allows protected properties, and eventual lambda-expression overloads for criterion). Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-09-30 09:40:08 UTC (rev 4732) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-09-30 10:29:35 UTC (rev 4733) @@ -52,6 +52,11 @@ return Add(expression); } + public QueryOver<T> And(ICriterion expression) + { + return Add(expression); + } + public QueryOver<T> Where(Expression<Func<T, bool>> expression) { return Add(expression); @@ -62,6 +67,11 @@ return Add(expression); } + public QueryOver<T> Where(ICriterion expression) + { + return Add(expression); + } + public QueryOver<T> Select(params Expression<Func<T, object>>[] projections) { List<IProjection> projectionList = new List<IProjection>(); @@ -275,7 +285,13 @@ return this; } + private QueryOver<T> Add(ICriterion expression) + { + _criteria.Add(expression); + return this; + } + ICriteria IQueryOver<T>.UnderlyingCriteria { get { return UnderlyingCriteria; } } @@ -285,12 +301,18 @@ IQueryOver<T> IQueryOver<T>.And(Expression<Func<bool>> expression) { return And(expression); } + IQueryOver<T> IQueryOver<T>.And(ICriterion expression) + { return And(expression); } + IQueryOver<T> IQueryOver<T>.Where(Expression<Func<T, bool>> expression) { return Where(expression); } IQueryOver<T> IQueryOver<T>.Where(Expression<Func<bool>> expression) { return Where(expression); } + IQueryOver<T> IQueryOver<T>.Where(ICriterion expression) + { return Where(expression); } + IQueryOver<T> IQueryOver<T>.Select(params Expression<Func<T, object>>[] projections) { return Select(projections); } Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-09-30 09:40:08 UTC (rev 4732) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-09-30 10:29:35 UTC (rev 4733) @@ -44,6 +44,11 @@ IQueryOver<T> And(Expression<Func<bool>> expression); /// <summary> + /// Add arbitrary ICriterion (e.g., to allow protected member access) + /// </summary> + IQueryOver<T> And(ICriterion expression); + + /// <summary> /// Identical semantics to Add() to allow more readable queries /// </summary> /// <param name="expression">Lambda expression</param> @@ -58,6 +63,11 @@ IQueryOver<T> Where(Expression<Func<bool>> expression); /// <summary> + /// Add arbitrary ICriterion (e.g., to allow protected member access) + /// </summary> + IQueryOver<T> Where(ICriterion expression); + + /// <summary> /// Add projection expressed as a lambda expression /// </summary> /// <param name="projections">Lambda expressions</param> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-09-30 09:40:08 UTC (rev 4732) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-09-30 10:29:35 UTC (rev 4733) @@ -118,6 +118,22 @@ } [Test] + public void PrivateProperties() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .Add(Restrictions.Eq("Name", "test name")) + .Add(Restrictions.Not(Restrictions.Eq("Name", "not test name"))); + + IQueryOver<Person> actual = + CreateTestQueryOver<Person>() + .Where(Restrictions.Eq("Name", "test name")) + .And(Restrictions.Not(Restrictions.Eq("Name", "not test name"))); + + AssertCriteriaAreEqual(expected, actual); + } + + [Test] public void SimpleCriterion_AliasReferenceSyntax() { ICriteria expected = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-09-30 13:56:20
|
Revision: 4734 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4734&view=rev Author: ricbrown Date: 2009-09-30 13:56:12 +0000 (Wed, 30 Sep 2009) Log Message: ----------- Added UniqueResult and Futures to IQueryOver. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryOverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-09-30 10:29:35 UTC (rev 4733) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-09-30 13:56:12 UTC (rev 4734) @@ -258,6 +258,36 @@ return _criteria.List<U>(); } + public T UniqueResult() + { + return _criteria.UniqueResult<T>(); + } + + public U UniqueResult<U>() + { + return _criteria.UniqueResult<U>(); + } + + IEnumerable<T> Future() + { + return _criteria.Future<T>(); + } + + IEnumerable<U> Future<U>() + { + return _criteria.Future<U>(); + } + + IFutureValue<T> FutureValue() + { + return _criteria.FutureValue<T>(); + } + + IFutureValue<U> FutureValue<U>() + { + return _criteria.FutureValue<U>(); + } + /// <summary> /// Get an executable instance of <c>IQueryOver<T></c>, /// to actually run the query.</summary> @@ -400,6 +430,24 @@ IList<U> IQueryOver<T>.List<U>() { return List<U>(); } + T IQueryOver<T>.UniqueResult() + { return UniqueResult(); } + + U IQueryOver<T>.UniqueResult<U>() + { return UniqueResult<U>(); } + + IEnumerable<T> IQueryOver<T>.Future() + { return Future(); } + + IEnumerable<U> IQueryOver<T>.Future<U>() + { return Future<U>(); } + + IFutureValue<T> IQueryOver<T>.FutureValue() + { return FutureValue(); } + + IFutureValue<U> IQueryOver<T>.FutureValue<U>() + { return FutureValue<U>(); } + } } Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-09-30 10:29:35 UTC (rev 4733) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-09-30 13:56:12 UTC (rev 4734) @@ -259,6 +259,49 @@ /// <returns>The list filled with the results.</returns> IList<U> List<U>(); + /// <summary> + /// Convenience method to return a single instance that matches + /// the query, or null if the query returns no results. + /// </summary> + /// <returns>the single result or <see langword="null" /></returns> + /// <exception cref="HibernateException"> + /// If there is more than one matching result + /// </exception> + T UniqueResult(); + + /// <summary> + /// Override type of <see cref="UniqueResult()" />. + /// </summary> + U UniqueResult<U>(); + + /// <summary> + /// Get a enumerable that when enumerated will execute + /// a batch of queries in a single database roundtrip + /// </summary> + IEnumerable<T> Future(); + + /// <summary> + /// Get a enumerable that when enumerated will execute + /// a batch of queries in a single database roundtrip + /// </summary> + IEnumerable<U> Future<U>(); + + /// <summary> + /// Get an IFutureValue instance, whose value can be retrieved through + /// its Value property. The query is not executed until the Value property + /// is retrieved, which will execute other Future queries as well in a + /// single roundtrip + /// </summary> + IFutureValue<T> FutureValue(); + + /// <summary> + /// Get an IFutureValue instance, whose value can be retrieved through + /// its Value property. The query is not executed until the Value property + /// is retrieved, which will execute other Future queries as well in a + /// single roundtrip + /// </summary> + IFutureValue<U> FutureValue<U>(); + } } Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-09-30 10:29:35 UTC (rev 4733) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-09-30 13:56:12 UTC (rev 4734) @@ -145,6 +145,36 @@ } } + [Test] + public void UniqueResult() + { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new Person() { Name = "test person 1", Age = 20 }); + t.Commit(); + } + + using (ISession s = OpenSession()) + { + Person actual = + s.QueryOver<Person>() + .UniqueResult(); + + Assert.That(actual.Name, Is.EqualTo("test person 1")); + } + + using (ISession s = OpenSession()) + { + string actual = + s.QueryOver<Person>() + .Select(p => p.Name) + .UniqueResult<string>(); + + Assert.That(actual, Is.EqualTo("test person 1")); + } + } + } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryOverFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryOverFixture.cs 2009-09-30 13:56:12 UTC (rev 4734) @@ -0,0 +1,132 @@ +using NHibernate.Criterion; +using NHibernate.Impl; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.Futures +{ + [TestFixture] + public class FutureQueryOverFixture : FutureFixture + { + + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Save(new Person()); + tx.Commit(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from Person"); + tx.Commit(); + } + } + + [Test] + public void CanUseFutureCriteria() + { + using (var s = sessions.OpenSession()) + { + IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); + + var persons10 = s.QueryOver<Person>() + .Take(10) + .Future(); + var persons5 = s.QueryOver<Person>() + .Select(p => p.Id) + .Take(5) + .Future<int>(); + + using (var logSpy = new SqlLogSpy()) + { + int actualPersons5Count = 0; + foreach (var person in persons5) + actualPersons5Count++; + + int actualPersons10Count = 0; + foreach (var person in persons10) + actualPersons10Count++; + + var events = logSpy.Appender.GetEvents(); + Assert.AreEqual(1, events.Length); + + Assert.That(actualPersons5Count, Is.EqualTo(1)); + Assert.That(actualPersons10Count, Is.EqualTo(1)); + } + } + } + + [Test] + public void TwoFuturesRunInTwoRoundTrips() + { + using (var s = sessions.OpenSession()) + { + IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); + + using (var logSpy = new SqlLogSpy()) + { + var persons10 = s.QueryOver<Person>() + .Take(10) + .Future(); + + foreach (var person in persons10) { } // fire first future round-trip + + var persons5 = s.QueryOver<Person>() + .Select(p => p.Id) + .Take(5) + .Future<int>(); + + foreach (var person in persons5) { } // fire second future round-trip + + var events = logSpy.Appender.GetEvents(); + Assert.AreEqual(2, events.Length); + } + } + } + + [Test] + public void CanCombineSingleFutureValueWithEnumerableFutures() + { + using (var s = sessions.OpenSession()) + { + IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); + + var persons = s.QueryOver<Person>() + .Take(10) + .Future(); + + var personIds = s.QueryOver<Person>() + .Select(p => p.Id) + .FutureValue<int>(); + + var singlePerson = s.QueryOver<Person>() + .FutureValue(); + + using (var logSpy = new SqlLogSpy()) + { + Person singlePersonValue = singlePerson.Value; + int personId = personIds.Value; + + foreach (var person in persons) + { + + } + + var events = logSpy.Appender.GetEvents(); + Assert.AreEqual(1, events.Length); + + Assert.That(singlePersonValue, Is.Not.Null); + Assert.That(personId, Is.Not.EqualTo(0)); + } + } + } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-30 10:29:35 UTC (rev 4733) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-30 13:56:12 UTC (rev 4734) @@ -390,6 +390,7 @@ <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagPartialNameFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" /> + <Compile Include="NHSpecificTest\Futures\FutureQueryOverFixture.cs" /> <Compile Include="NHSpecificTest\NH1922\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1922\Model.cs" /> <Compile Include="NHSpecificTest\NH1927\Fixture.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-10-01 10:02:47
|
Revision: 4735 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4735&view=rev Author: ricbrown Date: 2009-10-01 10:02:34 +0000 (Thu, 01 Oct 2009) Log Message: ----------- Added arbitrary IProjection to IQueryOver (allows protected properties, and eventual lambda-expression overloads for projections). Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs trunk/nhibernate/src/NHibernate/IQueryOver.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-09-30 13:56:12 UTC (rev 4734) +++ trunk/nhibernate/src/NHibernate/Criterion/QueryOver.cs 2009-10-01 10:02:34 UTC (rev 4735) @@ -83,6 +83,12 @@ return this; } + public QueryOver<T> Select(params IProjection[] projections) + { + _criteria.SetProjection(projections); + return this; + } + public QueryOverOrderBuilder<T> OrderBy(Expression<Func<T, object>> path) { return new QueryOverOrderBuilder<T>(this, path); @@ -346,6 +352,9 @@ IQueryOver<T> IQueryOver<T>.Select(params Expression<Func<T, object>>[] projections) { return Select(projections); } + IQueryOver<T> IQueryOver<T>.Select(params IProjection[] projections) + { return Select(projections); } + IQueryOverOrderBuilder<T> IQueryOver<T>.OrderBy(Expression<Func<T, object>> path) { return new IQueryOverOrderBuilder<T>(this, path); } Modified: trunk/nhibernate/src/NHibernate/IQueryOver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-09-30 13:56:12 UTC (rev 4734) +++ trunk/nhibernate/src/NHibernate/IQueryOver.cs 2009-10-01 10:02:34 UTC (rev 4735) @@ -75,6 +75,11 @@ IQueryOver<T> Select(params Expression<Func<T, object>>[] projections); /// <summary> + /// Add arbitrary IProjections to query + /// </summary> + IQueryOver<T> Select(params IProjection[] projections); + + /// <summary> /// Add order expressed as a lambda expression /// </summary> /// <param name="path">Lambda expression</param> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-09-30 13:56:12 UTC (rev 4734) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/QueryOverFixture.cs 2009-10-01 10:02:34 UTC (rev 4735) @@ -122,11 +122,13 @@ { ICriteria expected = CreateTestCriteria(typeof(Person)) + .SetProjection(Projections.Property("Name")) .Add(Restrictions.Eq("Name", "test name")) .Add(Restrictions.Not(Restrictions.Eq("Name", "not test name"))); IQueryOver<Person> actual = CreateTestQueryOver<Person>() + .Select(Projections.Property("Name")) .Where(Restrictions.Eq("Name", "test name")) .And(Restrictions.Not(Restrictions.Eq("Name", "not test name"))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-10-01 13:40:43
|
Revision: 4737 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4737&view=rev Author: ricbrown Date: 2009-10-01 12:29:45 +0000 (Thu, 01 Oct 2009) Log Message: ----------- Merge r4736 (Fix NH-1915, throw correct exception when joining on invalid path) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-10-01 12:29:05 UTC (rev 4736) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-10-01 12:29:45 UTC (rev 4737) @@ -679,6 +679,12 @@ dot.Resolve( true, false, alias == null ? null : alias.Text ); FromElement fromElement = dot.GetImpliedJoin(); + + if (fromElement == null) + { + throw new InvalidPathException("Invalid join: " + dot.Path); + } + fromElement.SetAllPropertyFetch(propertyFetch!=null); if ( with != null ) Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs 2009-10-01 12:29:05 UTC (rev 4736) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs 2009-10-01 12:29:45 UTC (rev 4737) @@ -1,6 +1,7 @@ using System; using System.Collections; using NHibernate.Engine.Query; +using NHibernate.Hql.Ast.ANTLR; using NHibernate.Util; using NUnit.Framework; @@ -131,5 +132,20 @@ s.CreateQuery(string.Format("from SimpleClass sc where sc.LongValue = {0}", int.MaxValue + 1L)).List(); } } + + [Test] + public void InvalidJoinOnProperty() + { + // NH-1915 + using (ISession s = OpenSession()) + { + Assert.Throws<InvalidPathException>( + () => + { + s.CreateQuery("from Zoo z inner join fetch z.classification").List(); + }, + "Incorrect path not caught during parsing"); + } + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-10-08 17:51:06
|
Revision: 4741 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4741&view=rev Author: ricbrown Date: 2009-10-08 17:50:58 +0000 (Thu, 08 Oct 2009) Log Message: ----------- Merge r4740 (Fix NH-1964, NH-1983, Blobs and Clobs with Sql Server CE) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Driver/SqlServerCeDriver.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlServerCeDriverFixture.cs trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlServerCeEntity.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Driver/SqlServerCeDriver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Driver/SqlServerCeDriver.cs 2009-10-08 17:50:20 UTC (rev 4740) +++ trunk/nhibernate/src/NHibernate/Driver/SqlServerCeDriver.cs 2009-10-08 17:50:58 UTC (rev 4741) @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Data; +using System.Reflection; using NHibernate.Cfg; using NHibernate.SqlCommand; using NHibernate.SqlTypes; @@ -24,11 +25,18 @@ } private bool prepareSql; + private PropertyInfo dbParamSqlDbTypeProperty; public override void Configure(IDictionary<string, string> settings) { base.Configure(settings); prepareSql = PropertiesHelper.GetBoolean(Environment.PrepareSql, settings, false); + + using (IDbCommand cmd = CreateCommand()) + { + IDbDataParameter dbParam = cmd.CreateParameter(); + dbParamSqlDbTypeProperty = dbParam.GetType().GetProperty("SqlDbType"); + } } /// <summary> @@ -94,5 +102,24 @@ { get { return true; } } + + protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) + { + base.InitializeParameter(dbParam, name, sqlType); + + AdjustDbParamTypeForLargeObjects(dbParam, sqlType); + } + + private void AdjustDbParamTypeForLargeObjects(IDbDataParameter dbParam, SqlType sqlType) + { + if (sqlType is BinaryBlobSqlType) + { + dbParamSqlDbTypeProperty.SetValue(dbParam, SqlDbType.Image, null); + } + else if (sqlType is StringClobSqlType) + { + dbParamSqlDbTypeProperty.SetValue(dbParam, SqlDbType.NText, null); + } + } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlServerCeDriverFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlServerCeDriverFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlServerCeDriverFixture.cs 2009-10-08 17:50:58 UTC (rev 4741) @@ -0,0 +1,112 @@ +using System; +using System.Collections; +using NHibernate.Cfg; +using NHibernate.Dialect; +using NUnit.Framework; +using NHibernate.Criterion; +using System.Collections.Generic; + +namespace NHibernate.Test.DriverTest +{ + public class SqlServerCeEntity + { + public virtual int Id { get; set; } + + public virtual string StringProp { get; set; } + public virtual byte[] BinaryProp { get; set; } + + public virtual string StringClob { get; set; } + public virtual byte[] BinaryBlob { get; set; } + } + + [TestFixture] + public class SqlServerCeDriverFixture : TestCase + { + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override IList Mappings + { + get { return new[] { "DriverTest.SqlServerCeEntity.hbm.xml" }; } + } + + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect is MsSqlCeDialect; + } + + protected override void OnTearDown() + { + base.OnTearDown(); + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from SqlServerCeEntity"); + tx.Commit(); + } + } + + [Test] + public void SaveLoad() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + SqlServerCeEntity entity = new SqlServerCeEntity(); + entity.StringProp = "a small string"; + entity.BinaryProp = new byte[100]; + + entity.StringClob = new String('a', 8193); + entity.BinaryBlob = new byte[8193]; + + s.Save(entity); + tx.Commit(); + } + + using (ISession s = OpenSession()) + { + SqlServerCeEntity entity = + s.CreateCriteria(typeof(SqlServerCeEntity)) + .UniqueResult<SqlServerCeEntity>(); + + Assert.That(entity.StringProp, Is.EqualTo("a small string")); + Assert.That(entity.BinaryProp.Length, Is.EqualTo(100)); + + Assert.That(entity.StringClob, Is.EqualTo(new String('a', 8193))); + Assert.That(entity.BinaryBlob.Length, Is.EqualTo(8193)); + } + } + + [Test] + public void Query() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + SqlServerCeEntity entity = new SqlServerCeEntity(); + entity.StringProp = "a small string"; + entity.BinaryProp = System.Text.ASCIIEncoding.ASCII.GetBytes("binary string"); + + entity.StringClob = new String('a', 8193); + entity.BinaryBlob = new byte[8193]; + + s.Save(entity); + tx.Commit(); + } + + using (ISession s = OpenSession()) + { + IList<SqlServerCeEntity> entities = + s.CreateCriteria(typeof(SqlServerCeEntity)) + .Add(Restrictions.Eq("StringProp", "a small string")) + .Add(Restrictions.Eq("BinaryProp", System.Text.ASCIIEncoding.ASCII.GetBytes("binary string"))) + .List<SqlServerCeEntity>(); + + Assert.That(entities.Count, Is.EqualTo(1)); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlServerCeEntity.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlServerCeEntity.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlServerCeEntity.hbm.xml 2009-10-08 17:50:58 UTC (rev 4741) @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.DriverTest" + assembly="NHibernate.Test"> + + <class name="SqlServerCeEntity"> + <id name="Id"> + <generator class="native" /> + </id> + + <property name="StringProp"/> <!-- maps to NVARCHAR(255) --> + <property name="BinaryProp"/> <!-- maps to VARBINARY(8000) --> + + <property name="StringClob" type="StringClob"> + <column name="StringClob" sql-type="ntext"/> + </property> + + <property name="BinaryBlob" type="BinaryBlob"> + <column name="BinaryBlob" sql-type="image"/> + </property> + + </class> +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-08 17:50:20 UTC (rev 4740) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-08 17:50:58 UTC (rev 4741) @@ -160,6 +160,7 @@ <Compile Include="Criteria\ProjectionsTest.cs" /> <Compile Include="Criteria\Reptile.cs" /> <Compile Include="DriverTest\SqlClientDriverFixture.cs" /> + <Compile Include="DriverTest\SqlServerCeDriverFixture.cs" /> <Compile Include="ExpressionTest\RestrictionsFixture.cs" /> <Compile Include="Criteria\Student.cs" /> <Compile Include="Criteria\StudentDTO.cs" /> @@ -2029,6 +2030,7 @@ <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> + <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> <EmbeddedResource Include="NHSpecificTest\NH1959\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1948\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-10-14 19:09:27
|
Revision: 4744 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4744&view=rev Author: fabiomaulo Date: 2009-10-14 19:09:18 +0000 (Wed, 14 Oct 2009) Log Message: ----------- Merge r4742, r4743 (fix NH-1990, NH-1992) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/Util/BasicFormatter.cs trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1990/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1990/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1990/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1990/Model.cs trunk/nhibernate/src/NHibernate.Test/UtilityTest/BasicFormatterFixture.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/Util/BasicFormatter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/Util/BasicFormatter.cs 2009-10-14 17:26:57 UTC (rev 4743) +++ trunk/nhibernate/src/NHibernate/AdoNet/Util/BasicFormatter.cs 2009-10-14 19:09:18 UTC (rev 4744) @@ -79,6 +79,7 @@ private bool afterInsert; private bool afterOn; private bool beginLine = true; + private bool endCommandFound; private int indent = 1; private int inFunction; @@ -186,6 +187,7 @@ { Out(); indent = 1; + endCommandFound = true; Newline(); } @@ -285,6 +287,7 @@ { afterInsert = true; } + endCommandFound = false; } private void Select() @@ -296,6 +299,7 @@ afterByOrFromOrSelects.Insert(afterByOrFromOrSelects.Count, afterByOrSetOrFromOrSelect); parensSinceSelect = 0; afterByOrSetOrFromOrSelect = true; + endCommandFound = false; } private void Out() @@ -353,6 +357,11 @@ private void CloseParen() { + if (endCommandFound) + { + Out(); + return; + } parensSinceSelect--; if (parensSinceSelect < 0) { @@ -384,6 +393,11 @@ private void OpenParen() { + if(endCommandFound) + { + Out(); + return; + } if (IsFunctionName(lastToken) || inFunction > 0) { inFunction++; Modified: trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2009-10-14 17:26:57 UTC (rev 4743) +++ trunk/nhibernate/src/NHibernate/Loader/Collection/SubselectOneToManyLoader.cs 2009-10-14 19:09:18 UTC (rev 4744) @@ -3,6 +3,7 @@ using NHibernate.Persister.Collection; using NHibernate.SqlCommand; using NHibernate.Type; +using NHibernate.Util; namespace NHibernate.Loader.Collection { @@ -31,8 +32,8 @@ namedParameters = queryParameters.NamedParameters; // NH Different behavior: to deal with positionslParameter+NamedParameter+ParameterOfFilters - types = queryParameters.PositionalParameterTypes; - values = queryParameters.PositionalParameterValues; + types = new List<IType>(new JoinedEnumerable<IType>(queryParameters.FilteredParameterTypes, queryParameters.PositionalParameterTypes)).ToArray(); + values = new List<object>(new JoinedEnumerable<object>(queryParameters.FilteredParameterValues, queryParameters.PositionalParameterValues)).ToArray(); this.namedParameterLocMap = namedParameterLocMap; } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1990/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1990/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1990/Fixture.cs 2009-10-14 19:09:18 UTC (rev 4744) @@ -0,0 +1,134 @@ +using System.Collections.Generic; +using System.Text; +using NHibernate.Criterion; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1990 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override void OnSetUp() + { + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + for (int i = 0; i < 10; i++) + { + var feed = new NewsFeed + { + Url = string.Format("Feed{0}Uri", i), + Title = string.Format("Feed{0}", i), + Status = (i % 2 == 0 ? 1 : 2) + }; + s.Save(feed); + + for (int j = 0; j < 8; j++) + { + var item = new NewsItem + {Title = string.Format("Feed{0}Item{1}", i, j), Status = (j % 2 == 0 ? 1 : 2), Feed = feed}; + s.Save(item); + } + } + tx.Commit(); + } + } + } + + protected override void OnTearDown() + { + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete(string.Format("from {0}", typeof (NewsItem).Name)); + s.Delete(string.Format("from {0}", typeof (NewsFeed).Name)); + tx.Commit(); + } + } + } + + [Test] + public void FetchingBySubqueryFilterParameters() + { + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + IFilter filter = s.EnableFilter("StatusFilter"); + filter.SetParameter("Status", 1); + + ICriteria criteria = s.CreateCriteria(typeof (NewsFeed), "NewsFeed"); + IList<NewsFeed> feeds = criteria.List<NewsFeed>(); + + Assert.That(feeds.Count, Is.EqualTo(5)); + foreach (NewsFeed feed in feeds) + { + Assert.That(feed.Items.Count, Is.EqualTo(4)); + } + + tx.Commit(); + } + } + } + + [Test] + public void FetchingBySubqueryFilterParametersAndPositionalParameters() + { + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + IFilter filter = s.EnableFilter("StatusFilter"); + filter.SetParameter("Status", 1); + + ICriteria criteria = s.CreateCriteria(typeof (NewsFeed), "NewsFeed"); + criteria.Add(Restrictions.In("Url", new[] {"Feed2Uri", "Feed4Uri", "Feed8Uri"})); + + IList<NewsFeed> feeds = criteria.List<NewsFeed>(); + + Assert.That(feeds.Count, Is.EqualTo(3)); + foreach (NewsFeed feed in feeds) + { + Assert.That(feed.Items.Count, Is.EqualTo(4)); + } + + tx.Commit(); + } + } + } + + [Test] + public void FetchingBySubqueryFilterParametersAndPositionalParametersAndNamedParameters() + { + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + IFilter filter = s.EnableFilter("StatusFilter"); + filter.SetParameter("Status", 1); + + var hql = new StringBuilder(); + hql.AppendLine("from NewsFeed"); + hql.AppendLine("where (Url = ? or Url = ?) and Title in (:TitleList)) "); + + IQuery query = s.CreateQuery(hql.ToString()); + query.SetString(0, "Feed4Uri"); + query.SetString(1, "Feed8Uri"); + query.SetParameterList("TitleList", new[] {"Feed2", "Feed4", "Feed8"}); + + IList<NewsFeed> feeds = query.List<NewsFeed>(); + + Assert.That(feeds.Count, Is.EqualTo(2)); + foreach (NewsFeed feed in feeds) + { + Assert.That(feed.Items.Count, Is.EqualTo(4)); + } + + tx.Commit(); + } + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1990/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1990/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1990/Mappings.hbm.xml 2009-10-14 19:09:18 UTC (rev 4744) @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1990" + assembly="NHibernate.Test"> + + <class name="NewsFeed" table="NWS_Feed" batch-size="100"> + <id name="Id" type="Guid" column="OID"> + <generator class="guid"></generator> + </id> + <property name="Title" type="String" not-null="true"/> + <property name="Url" type="String" not-null="true"/> + <property name="Status" type="Int32" not-null="true"/> + <bag name="Items" cascade="all" fetch="subselect" inverse="true" > + <key column="FK_Feed_OID"/> + <one-to-many class="NewsItem"></one-to-many> + <filter name="StatusFilter" condition=":Status=Status" /> + </bag> + <filter name="StatusFilter" condition=":Status=Status" /> + </class> + + <class name="NewsItem" table="NWS_Item" batch-size="100"> + <id name="Id" type="Guid" column="OID"> + <generator class="guid"></generator> + </id> + <property name="Title" type="String" not-null="true"/> + <property name="Status" type="Int32" not-null="true"/> + <many-to-one name="Feed" class="NewsFeed" column="FK_Feed_OID" not-null="true"/> + + <filter name="StatusFilter" condition=":Status=Status" /> + </class> + + <filter-def name="StatusFilter"> + <filter-param name="Status" type="Int32"/> + </filter-def> +</hibernate-mapping> + + Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1990/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1990/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1990/Model.cs 2009-10-14 19:09:18 UTC (rev 4744) @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1990 +{ + public class NewsFeed + { + public NewsFeed() + { + Items = new List<NewsItem>(); + } + + public virtual Guid Id { get; set; } + public virtual string Title { get; set; } + public virtual string Url { get; set; } + public virtual int Status { get; set; } + public virtual IList<NewsItem> Items { get; set; } + } + + public class NewsItem + { + public virtual Guid Id { get; set; } + public virtual string Title { get; set; } + public virtual int Status { get; set; } + public virtual NewsFeed Feed { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-14 17:26:57 UTC (rev 4743) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-14 19:09:18 UTC (rev 4744) @@ -617,6 +617,8 @@ <Compile Include="NHSpecificTest\NH1969\DummyEntity.cs" /> <Compile Include="NHSpecificTest\NH1969\EntityWithTypeProperty.cs" /> <Compile Include="NHSpecificTest\NH1969\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1990\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1990\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1439,6 +1441,7 @@ <Compile Include="UserCollection\User.cs" /> <Compile Include="UserCollection\UserCollectionTypeTest.cs" /> <Compile Include="UtilityTest\AssemblyQualifiedTypeNameFixture.cs" /> + <Compile Include="UtilityTest\BasicFormatterFixture.cs" /> <Compile Include="UtilityTest\ExpressionsHelperFixture.cs" /> <Compile Include="UtilityTest\IdentityMapFixture.cs" /> <Compile Include="UtilityTest\IdentityMapSequencedFixture.cs" /> @@ -2032,6 +2035,7 @@ <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1990\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1959\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1948\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1941\Mappings.hbm.xml" /> Added: trunk/nhibernate/src/NHibernate.Test/UtilityTest/BasicFormatterFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/UtilityTest/BasicFormatterFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/BasicFormatterFixture.cs 2009-10-14 19:09:18 UTC (rev 4744) @@ -0,0 +1,23 @@ +using NHibernate.AdoNet.Util; +using NUnit.Framework; + +namespace NHibernate.Test.UtilityTest +{ + [TestFixture] + public class BasicFormatterFixture + { + [Test] + public void StringWithNestedDelimiters() + { + string formattedSql = null; + IFormatter formatter = new BasicFormatter(); + string sql = @"INSERT INTO Table (Name, id) VALUES (@p0, @p1); @p0 = 'a'(b', @p1 = 1"; + Assert.DoesNotThrow(() => formattedSql = formatter.Format(sql)); + Assert.That(formattedSql, Text.Contains("'a'(b'")); + + sql = @"UPDATE Table SET Column = @p0;@p0 = '(')'"; + Assert.DoesNotThrow(() => formattedSql = formatter.Format(sql)); + Assert.That(formattedSql, Text.Contains("'(')'")); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-10-14 20:23:07
|
Revision: 4746 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4746&view=rev Author: fabiomaulo Date: 2009-10-14 20:22:58 +0000 (Wed, 14 Oct 2009) Log Message: ----------- Merge r4745 (fix NH-1985) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Event/Default/DefaultDeleteEventListener.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1985/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1985/DomainClass.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1985/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1985/SampleTest.cs Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultDeleteEventListener.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/Default/DefaultDeleteEventListener.cs 2009-10-14 19:45:17 UTC (rev 4745) +++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultDeleteEventListener.cs 2009-10-14 20:22:58 UTC (rev 4746) @@ -90,12 +90,11 @@ version = entityEntry.Version; } - /*if ( !persister.isMutable() ) { - throw new HibernateException( - "attempted to delete an object of immutable class: " + - MessageHelper.infoString(persister) - ); - }*/ + if (!persister.IsMutable) + { + throw new HibernateException("Attempted to delete an object of immutable class: " + + MessageHelper.InfoString(persister)); + } if (InvokeDeleteLifecycle(source, entity, persister)) { Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1985/DomainClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1985/DomainClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1985/DomainClass.cs 2009-10-14 20:22:58 UTC (rev 4746) @@ -0,0 +1,9 @@ +namespace NHibernate.Test.NHSpecificTest.NH1985 +{ + public class DomainClass + { + public int Id { get; set; } + + public string Label { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1985/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1985/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1985/Mappings.hbm.xml 2009-10-14 20:22:58 UTC (rev 4746) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1985" + default-lazy="false"> + <class name="DomainClass" mutable="false"> + <id name="Id"> + <generator class="assigned" /> + </id> + <property name="Label" /> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1985/SampleTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1985/SampleTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1985/SampleTest.cs 2009-10-14 20:22:58 UTC (rev 4746) @@ -0,0 +1,66 @@ +using System; +using System.Data; +using NHibernate.Connection; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1985 +{ + [TestFixture] + public class SampleTest : BugTestCase + { + protected override void OnSetUp() + { + base.OnSetUp(); + + if (0 == ExecuteStatement("INSERT INTO DomainClass (Id, Label) VALUES (1, 'TEST record');")) + { + throw new ApplicationException("Insertion of test record failed."); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + + ExecuteStatement("DELETE FROM DomainClass WHERE Id=1;"); + } + + [Test] + public void AttemptToDeleteImmutableObjectShouldThrow() + { + using (ISession session = OpenSession()) + { + Assert.Throws<HibernateException>(() => + { + using (ITransaction trans = session.BeginTransaction()) + { + var entity = session.Get<DomainClass>(1); + session.Delete(entity); + + trans.Commit(); // This used to throw... + } + }); + } + + using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties)) + { + IDbConnection conn = prov.GetConnection(); + + try + { + using (IDbCommand comm = conn.CreateCommand()) + { + comm.CommandText = "SELECT Id FROM DomainClass WHERE Id=1 AND Label='TEST record'"; + object result = comm.ExecuteScalar(); + + Assert.That(result != null, "Immutable object has been deleted!"); + } + } + finally + { + prov.CloseConnection(conn); + } + } + } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-14 19:45:17 UTC (rev 4745) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-14 20:22:58 UTC (rev 4746) @@ -617,6 +617,8 @@ <Compile Include="NHSpecificTest\NH1969\DummyEntity.cs" /> <Compile Include="NHSpecificTest\NH1969\EntityWithTypeProperty.cs" /> <Compile Include="NHSpecificTest\NH1969\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1985\DomainClass.cs" /> + <Compile Include="NHSpecificTest\NH1985\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1990\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1990\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> @@ -2035,6 +2037,7 @@ <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1985\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1990\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1959\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1948\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |