|
From: <fab...@us...> - 2010-12-15 22:21:10
|
Revision: 5319
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5319&view=rev
Author: fabiomaulo
Date: 2010-12-15 22:21:00 +0000 (Wed, 15 Dec 2010)
Log Message:
-----------
- added FirstOrNull enumerable extension
- refactoring
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs
trunk/nhibernate/src/NHibernate/Util/EnumerableExtensions.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/FirstOrNullExtensionTests.cs
Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2010-12-15 22:09:18 UTC (rev 5318)
+++ trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2010-12-15 22:21:00 UTC (rev 5319)
@@ -682,7 +682,8 @@
return this;
}
- SetParameterList(name, vals, !vals.Any() ? GuessType(vals.GetCollectionElementType()) : DetermineType(name, vals.First()));
+ object firstValue = vals.FirstOrNull();
+ SetParameterList(name, vals, firstValue == null ? GuessType(vals.GetCollectionElementType()) : DetermineType(name, firstValue));
return this;
}
Modified: trunk/nhibernate/src/NHibernate/Util/EnumerableExtensions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/EnumerableExtensions.cs 2010-12-15 22:09:18 UTC (rev 5318)
+++ trunk/nhibernate/src/NHibernate/Util/EnumerableExtensions.cs 2010-12-15 22:21:00 UTC (rev 5319)
@@ -48,6 +48,33 @@
throw new InvalidOperationException("Sequence contains no elements");
}
+ public static object FirstOrNull(this IEnumerable source)
+ {
+ if (source == null)
+ {
+ throw new ArgumentNullException("source");
+ }
+ IList collection = source as IList;
+ if (collection != null)
+ {
+ if (collection.Count > 0)
+ {
+ return collection[0];
+ }
+ }
+ else
+ {
+ using (DisposableEnumerator enumerator = source.GetDisposableEnumerator())
+ {
+ if (enumerator.MoveNext())
+ {
+ return enumerator.Current;
+ }
+ }
+ }
+ return null;
+ }
+
private static DisposableEnumerator GetDisposableEnumerator(this IEnumerable source)
{
return new DisposableEnumerator(source);
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-12-15 22:09:18 UTC (rev 5318)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-12-15 22:21:00 UTC (rev 5319)
@@ -582,6 +582,7 @@
<Compile Include="TypesTest\XmlDocTypeFixture.cs" />
<Compile Include="UtilityTest\EnumerableExtensionsTests\AnyExtensionTests.cs" />
<Compile Include="UtilityTest\EnumerableExtensionsTests\FirstExtensionTests.cs" />
+ <Compile Include="UtilityTest\EnumerableExtensionsTests\FirstOrNullExtensionTests.cs" />
<Compile Include="UtilityTest\ReflectionHelperIsMethodOfTests.cs" />
<Compile Include="UtilityTest\ReflectionHelperTest.cs" />
<Compile Include="Linq\RegresstionTests.cs" />
Added: trunk/nhibernate/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/FirstOrNullExtensionTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/FirstOrNullExtensionTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/FirstOrNullExtensionTests.cs 2010-12-15 22:21:00 UTC (rev 5319)
@@ -0,0 +1,29 @@
+using System;
+using System.Collections;
+using NHibernate.Util;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.UtilityTest.EnumerableExtensionsTests
+{
+ public class FirstOrNullExtensionTests
+ {
+ [Test]
+ public void WhenNullThenThenThrows()
+ {
+ Executing.This(() => ((IEnumerable)null).FirstOrNull()).Should().Throw<ArgumentNullException>();
+ }
+
+ [Test]
+ public void WhenHasElementsThenReturnFirst()
+ {
+ (new[] { 2, 1 }).FirstOrNull().Should().Be(2);
+ }
+
+ [Test]
+ public void WhenEmptyThenReturnNull()
+ {
+ (new object[0]).FirstOrNull().Should().Be.Null();
+ }
+ }
+}
\ 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: <fab...@us...> - 2010-12-17 04:09:06
|
Revision: 5322
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5322&view=rev
Author: fabiomaulo
Date: 2010-12-17 04:09:00 +0000 (Fri, 17 Dec 2010)
Log Message:
-----------
Fix NH-2460
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs
trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/Decima2lTypeFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs 2010-12-17 03:06:33 UTC (rev 5321)
+++ trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs 2010-12-17 04:09:00 UTC (rev 5322)
@@ -51,5 +51,15 @@
return x.Equals(y);
}
+
+ public override object Next(object current, Engine.ISessionImplementor session)
+ {
+ return Seed(session);
+ }
+
+ public override object Seed(Engine.ISessionImplementor session)
+ {
+ return DateTime.Now;
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs 2010-12-17 03:06:33 UTC (rev 5321)
+++ trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs 2010-12-17 04:09:00 UTC (rev 5322)
@@ -68,12 +68,12 @@
#region IVersionType Members
- public object Next(object current, ISessionImplementor session)
+ public virtual object Next(object current, ISessionImplementor session)
{
return Seed(session);
}
- public object Seed(ISessionImplementor session)
+ public virtual object Seed(ISessionImplementor session)
{
return TimestampType.Round(DateTime.Now, TimeSpan.TicksPerSecond);
}
Modified: trunk/nhibernate/src/NHibernate.Test/TypesTest/Decima2lTypeFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/Decima2lTypeFixture.cs 2010-12-17 03:06:33 UTC (rev 5321)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/Decima2lTypeFixture.cs 2010-12-17 04:09:00 UTC (rev 5322)
@@ -1,6 +1,7 @@
using System;
using NHibernate.Type;
using NUnit.Framework;
+using SharpTestsEx;
namespace NHibernate.Test.TypesTest
{
@@ -14,12 +15,10 @@
public void Next()
{
DateTimeType type = (DateTimeType)NHibernateUtil.DateTime2;
- object current = DateTime.Parse("2004-01-01");
+ object current = DateTime.Now.AddMilliseconds(-1);
object next = type.Next(current, null);
- Assert.IsTrue(next is DateTime, "Next should be DateTime");
- Assert.IsTrue((DateTime)next > (DateTime)current,
- "next should be greater than current (could be equal depending on how quickly this occurs)");
+ next.Should().Be.OfType<DateTime>().And.Value.Should().Be.GreaterThan((DateTime)current);
}
[Test]
@@ -43,5 +42,15 @@
value2 = ((DateTime)value2).AddHours(2);
Assert.IsFalse(value1 == value2, "value2 was changed, value1 should not have changed also.");
}
+
+ [Test]
+ public void EqualityShouldIgnoreKindAndNotIgnoreMillisecond()
+ {
+ var type = (DateTimeType)NHibernateUtil.DateTime;
+ var localTime = DateTime.Now;
+ var unspecifiedKid = new DateTime(localTime.Ticks, DateTimeKind.Unspecified);
+ type.Satisfy(t => t.IsEqual(localTime, unspecifiedKid));
+ type.Satisfy(t => t.IsEqual(localTime, unspecifiedKid, EntityMode.Poco));
+ }
}
}
\ 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: <fab...@us...> - 2010-12-18 15:59:08
|
Revision: 5325
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5325&view=rev
Author: fabiomaulo
Date: 2010-12-18 15:59:02 +0000 (Sat, 18 Dec 2010)
Log Message:
-----------
Fix of NH-2375 and NH-2381 (thanks to Dean Ward)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessOfType.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/Linq/EagerLoadTests.cs
trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Linq/ReWriters/ResultOperatorRewriter.cs
trunk/nhibernate/src/NHibernate/Linq/ReWriters/ResultOperatorRewriterResult.cs
Added: trunk/nhibernate/src/NHibernate/Linq/ReWriters/ResultOperatorRewriter.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/ReWriters/ResultOperatorRewriter.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Linq/ReWriters/ResultOperatorRewriter.cs 2010-12-18 15:59:02 UTC (rev 5325)
@@ -0,0 +1,112 @@
+namespace NHibernate.Linq.ReWriters
+{
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Linq.Expressions;
+
+ using NHibernate.Linq.Visitors;
+
+ 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.Clauses.StreamedData;
+ using Remotion.Data.Linq.EagerFetching;
+
+ /// <summary>
+ /// Removes various result operators from a query so that they can be processed at the same
+ /// tree level as the query itself.
+ /// </summary>
+ public class ResultOperatorRewriter : QueryModelVisitorBase
+ {
+ private readonly List<ResultOperatorBase> resultOperators = new List<ResultOperatorBase>();
+ private IStreamedDataInfo evaluationType;
+
+ private ResultOperatorRewriter()
+ {
+ }
+
+ public static ResultOperatorRewriterResult Rewrite(QueryModel queryModel)
+ {
+ ResultOperatorRewriter rewriter = new ResultOperatorRewriter();
+
+ rewriter.VisitQueryModel(queryModel);
+
+ return new ResultOperatorRewriterResult(rewriter.resultOperators, rewriter.evaluationType);
+ }
+
+ public override void VisitMainFromClause(MainFromClause fromClause, QueryModel queryModel)
+ {
+ base.VisitMainFromClause(fromClause, queryModel);
+
+ ResultOperatorExpressionRewriter rewriter = new ResultOperatorExpressionRewriter();
+ fromClause.TransformExpressions(rewriter.Rewrite);
+ if (fromClause.FromExpression.NodeType == ExpressionType.Constant)
+ {
+ System.Type expressionType = queryModel.MainFromClause.FromExpression.Type;
+ if (expressionType.IsGenericType && expressionType.GetGenericTypeDefinition() == typeof(NhQueryable<>))
+ {
+ queryModel.MainFromClause.ItemType = expressionType.GetGenericArguments()[0];
+ }
+ }
+
+ this.resultOperators.AddRange(rewriter.ResultOperators);
+ this.evaluationType = rewriter.EvaluationType;
+ }
+
+ /// <summary>
+ /// Rewrites expressions so that they sit in the outermost portion of the query.
+ /// </summary>
+ private class ResultOperatorExpressionRewriter : NhExpressionTreeVisitor
+ {
+ private static readonly System.Type[] rewrittenTypes = new[]
+ {
+ typeof(FetchRequestBase),
+ typeof(OfTypeResultOperator),
+ };
+
+ private readonly List<ResultOperatorBase> resultOperators = new List<ResultOperatorBase>();
+ private IStreamedDataInfo evaluationType;
+
+ /// <summary>
+ /// Gets an <see cref="IEnumerable{T}" /> of <see cref="ResultOperatorBase" /> that were rewritten.
+ /// </summary>
+ public IEnumerable<ResultOperatorBase> ResultOperators
+ {
+ get { return this.resultOperators; }
+ }
+
+ /// <summary>
+ /// Gets the <see cref="IStreamedDataInfo" /> representing the type of data that the operator works upon.
+ /// </summary>
+ public IStreamedDataInfo EvaluationType
+ {
+ get { return this.evaluationType; }
+ }
+
+ public Expression Rewrite(Expression expression)
+ {
+ Expression rewrittenExpression = this.VisitExpression(expression);
+
+ return rewrittenExpression;
+ }
+
+ protected override Expression VisitSubQueryExpression(SubQueryExpression expression)
+ {
+ this.resultOperators.AddRange(
+ expression.QueryModel.ResultOperators
+ .Where(r => rewrittenTypes.Any(t => t.IsAssignableFrom(r.GetType()))));
+
+ this.resultOperators.ForEach(f => expression.QueryModel.ResultOperators.Remove(f));
+ this.evaluationType = expression.QueryModel.SelectClause.GetOutputDataInfo();
+
+ if (expression.QueryModel.ResultOperators.Count == 0)
+ {
+ return expression.QueryModel.MainFromClause.FromExpression;
+ }
+
+ return base.VisitSubQueryExpression(expression);
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate/Linq/ReWriters/ResultOperatorRewriterResult.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/ReWriters/ResultOperatorRewriterResult.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Linq/ReWriters/ResultOperatorRewriterResult.cs 2010-12-18 15:59:02 UTC (rev 5325)
@@ -0,0 +1,30 @@
+namespace NHibernate.Linq.ReWriters
+{
+ using System.Collections.Generic;
+
+ using Remotion.Data.Linq.Clauses;
+ using Remotion.Data.Linq.Clauses.StreamedData;
+
+ /// <summary>
+ /// Result of <see cref="ResultOperatorRewriter.Rewrite" />.
+ /// </summary>
+ public class ResultOperatorRewriterResult
+ {
+ public ResultOperatorRewriterResult(IEnumerable<ResultOperatorBase> rewrittenOperators, IStreamedDataInfo evaluationType)
+ {
+ this.RewrittenOperators = rewrittenOperators;
+ this.EvaluationType = evaluationType;
+ }
+
+ /// <summary>
+ /// Gets an <see cref="IEnumerable{T}" /> of <see cref="ResultOperatorBase" /> implementations that were
+ /// rewritten.
+ /// </summary>
+ public IEnumerable<ResultOperatorBase> RewrittenOperators { get; private set; }
+
+ /// <summary>
+ /// Gets the <see cref="IStreamedDataInfo" /> representing the type of data that the operator works upon.
+ /// </summary>
+ public IStreamedDataInfo EvaluationType { get; private set; }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs 2010-12-18 15:40:50 UTC (rev 5324)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs 2010-12-18 15:59:02 UTC (rev 5325)
@@ -45,10 +45,18 @@
// Add left joins for references
AddLeftJoinsReWriter.ReWrite(queryModel, parameters.SessionFactory);
- var visitor = new QueryModelVisitor(parameters, root, queryModel);
- visitor.Visit();
+ // rewrite any operators that should be applied on the outer query
+ // by flattening out the sub-queries that they are located in
+ ResultOperatorRewriterResult result = ResultOperatorRewriter.Rewrite(queryModel);
- return visitor._hqlTree.GetTranslation();
+ QueryModelVisitor visitor = new QueryModelVisitor(parameters, root, queryModel)
+ {
+ RewrittenOperatorResult = result
+ };
+
+ visitor.Visit();
+
+ return visitor._hqlTree.GetTranslation();
}
private readonly IntermediateHqlTree _hqlTree;
@@ -59,6 +67,7 @@
public IStreamedDataInfo CurrentEvaluationType { get; private set; }
public IStreamedDataInfo PreviousEvaluationType { get; private set; }
public QueryModel Model { get; private set; }
+ public ResultOperatorRewriterResult RewrittenOperatorResult { get; private set; }
static QueryModelVisitor()
{
@@ -102,6 +111,16 @@
HqlGeneratorExpressionTreeVisitor.Visit(fromClause.FromExpression, VisitorParameters),
_hqlTree.TreeBuilder.Alias(fromClause.ItemName)));
+ // apply any result operators that were rewritten
+ if (RewrittenOperatorResult != null)
+ {
+ CurrentEvaluationType = RewrittenOperatorResult.EvaluationType;
+ foreach (ResultOperatorBase rewrittenOperator in RewrittenOperatorResult.RewrittenOperators)
+ {
+ this.VisitResultOperator(rewrittenOperator, queryModel, -1);
+ }
+ }
+
base.VisitMainFromClause(fromClause, queryModel);
}
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessOfType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessOfType.cs 2010-12-18 15:40:50 UTC (rev 5324)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessOfType.cs 2010-12-18 15:59:02 UTC (rev 5325)
@@ -1,7 +1,6 @@
using System.Linq.Expressions;
using NHibernate.Hql.Ast;
using Remotion.Data.Linq.Clauses.ResultOperators;
-using Remotion.Data.Linq.Clauses.StreamedData;
namespace NHibernate.Linq.Visitors.ResultOperatorProcessors
{
@@ -11,8 +10,7 @@
public void Process(OfTypeResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree)
{
- Expression source =
- queryModelVisitor.CurrentEvaluationType.As<StreamedSequenceInfo>().ItemExpression;
+ Expression source = queryModelVisitor.Model.SelectClause.GetOutputDataInfo().ItemExpression;
tree.AddWhereClause(tree.TreeBuilder.Equality(
tree.TreeBuilder.Dot(
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-12-18 15:40:50 UTC (rev 5324)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-12-18 15:59:02 UTC (rev 5325)
@@ -257,6 +257,8 @@
<Compile Include="ITransaction.cs" />
<Compile Include="LazyInitializationException.cs" />
<Compile Include="Linq\Functions\DictionaryGenerator.cs" />
+ <Compile Include="Linq\ReWriters\ResultOperatorRewriter.cs" />
+ <Compile Include="Linq\ReWriters\ResultOperatorRewriterResult.cs" />
<Compile Include="Loader\Loader.cs" />
<Compile Include="Loader\OuterJoinLoader.cs" />
<Compile Include="LockMode.cs" />
Modified: trunk/nhibernate/src/NHibernate.Test/Linq/EagerLoadTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Linq/EagerLoadTests.cs 2010-12-18 15:40:50 UTC (rev 5324)
+++ trunk/nhibernate/src/NHibernate.Test/Linq/EagerLoadTests.cs 2010-12-18 15:59:02 UTC (rev 5325)
@@ -56,12 +56,32 @@
Assert.IsTrue(NHibernateUtil.IsInitialized(x[0].Orders.First().OrderLines));
}
- [Test]
- public void WhenFetchSuperclassCollectionThenNotThrows()
- {
- // NH-2277
- session.Executing(s => s.Query<Lizard>().Fetch(x => x.Children).ToList()).NotThrows();
- session.Close();
- }
+ [Test]
+ public void WhenFetchSuperclassCollectionThenNotThrows()
+ {
+ // NH-2277
+ session.Executing(s => s.Query<Lizard>().Fetch(x => x.Children).ToList()).NotThrows();
+ session.Close();
+ }
+
+ [Test]
+ public void FetchWithWhere()
+ {
+ // NH-2381
+ (from p
+ in session.Query<Product>().Fetch(a => a.Supplier)
+ where p.ProductId == 1
+ select p).ToList();
+ }
+
+ [Test]
+ public void FetchManyWithWhere()
+ {
+ // NH-2381
+ (from s
+ in session.Query<Supplier>().FetchMany(a => a.Products)
+ where s.SupplierId == 1
+ select s).ToList();
+ }
}
}
Modified: trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs 2010-12-18 15:40:50 UTC (rev 5324)
+++ trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs 2010-12-18 15:59:02 UTC (rev 5325)
@@ -491,5 +491,25 @@
Assert.AreEqual(3, query.Count);
}
+ [Test]
+ public void OfTypeWithWhereAndProjection()
+ {
+ // NH-2375
+ (from a
+ in session.Query<Animal>().OfType<Cat>()
+ where a.Pregnant
+ select a.Id).FirstOrDefault();
+ }
+
+ [Test]
+ public void OfTypeWithWhere()
+ {
+ // NH-2375
+ (from a
+ in session.Query<Animal>().OfType<Cat>()
+ where a.Pregnant
+ select a).FirstOrDefault();
+ }
+
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-12-18 22:29:13
|
Revision: 5329
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5329&view=rev
Author: fabiomaulo
Date: 2010-12-18 22:29:06 +0000 (Sat, 18 Dec 2010)
Log Message:
-----------
Fix NH-2037 (by Jose F. Romaniello)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2037/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2037/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2037/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2037/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2010-12-18 16:26:47 UTC (rev 5328)
+++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2010-12-18 22:29:06 UTC (rev 5329)
@@ -4066,6 +4066,10 @@
{
snapshot[i] =
extractionTypes[i].Hydrate(rs, GetPropertyAliases(string.Empty, naturalIdPropertyIndexes[i]), session, null);
+ if (extractionTypes[i].IsEntityType)
+ {
+ snapshot[i] = extractionTypes[i].ResolveIdentifier(snapshot[i], session, null);
+ }
}
return snapshot;
}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2037/Domain.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2037/Domain.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2037/Domain.cs 2010-12-18 22:29:06 UTC (rev 5329)
@@ -0,0 +1,36 @@
+namespace NHibernate.Test.NHSpecificTest.NH2037
+{
+ public class Country
+ {
+ public virtual int Id { get; set; }
+ public virtual string Name { get; set; }
+
+ public virtual bool Equals(Country other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return other.Id == Id;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (!(obj is Country)) return false;
+ return Equals((Country) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return Id;
+ }
+ }
+
+ public class City
+ {
+ public virtual int Id { get; set; }
+ public virtual Country Country { get; set; }
+ public virtual int CityCode { get; set; }
+ public virtual string Name { get; set; }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2037/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2037/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2037/Fixture.cs 2010-12-18 22:29:06 UTC (rev 5329)
@@ -0,0 +1,56 @@
+ using NUnit.Framework;
+namespace NHibernate.Test.NHSpecificTest.NH2037
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ [Test]
+ public void Test()
+ {
+ var country = new Country {Name = "Argentina"};
+
+ var city = new City
+ {
+ CityCode = 5,
+ Country = country,
+ Name = "Cordoba"
+ };
+
+
+ using (ISession session = OpenSession())
+ using(var tx = session.BeginTransaction())
+ {
+ session.Save(city.Country);
+ session.Save(city);
+ tx.Commit();
+ }
+
+ using(ISession session = OpenSession())
+ using (var tx = session.BeginTransaction())
+ {
+ //THROW
+ session.SaveOrUpdate(city);
+ tx.Commit();
+ }
+
+ using (var session = OpenSession())
+ using (var tx = session.BeginTransaction())
+ {
+ Assert.IsNotNull(session.Get<City>(city.Id));
+ tx.Commit();
+ }
+ }
+
+ protected override void OnTearDown()
+ {
+ using(var session = OpenSession())
+ using(var tx = session.BeginTransaction())
+ {
+ session.Delete("from City");
+ session.Delete("from Country");
+ tx.Commit();
+ }
+ }
+
+ }
+ }
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2037/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2037/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2037/Mappings.hbm.xml 2010-12-18 22:29:06 UTC (rev 5329)
@@ -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.NH2037">
+
+ <class name="Country" table="Countries">
+ <id name="Id">
+ <generator class="identity"/>
+ </id>
+ <property name="Name" />
+ </class>
+
+ <class name="City" table="Cities">
+ <id name="Id">
+ <generator class="identity"/>
+ </id>
+ <natural-id>
+ <many-to-one name="Country" class="Country" />
+ <property name="CityCode" />
+
+ </natural-id>
+ <property name="Name" />
+ </class>
+
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-12-18 16:26:47 UTC (rev 5328)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-12-18 22:29:06 UTC (rev 5329)
@@ -476,6 +476,8 @@
<Compile Include="NHSpecificTest\NH1836\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1869\Entities.cs" />
<Compile Include="NHSpecificTest\NH1869\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH2037\Domain.cs" />
+ <Compile Include="NHSpecificTest\NH2037\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2111\A.cs" />
<Compile Include="NHSpecificTest\NH2111\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2112\Fixture.cs" />
@@ -2358,6 +2360,7 @@
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="NHSpecificTest\NH2037\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2118\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2362\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2244\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-12-19 18:40:15
|
Revision: 5333
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5333&view=rev
Author: fabiomaulo
Date: 2010-12-19 18:40:07 +0000 (Sun, 19 Dec 2010)
Log Message:
-----------
Fix NH-2023
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/IStatelessSession.cs
trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs
Modified: trunk/nhibernate/src/NHibernate/IStatelessSession.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/IStatelessSession.cs 2010-12-19 17:46:48 UTC (rev 5332)
+++ trunk/nhibernate/src/NHibernate/IStatelessSession.cs 2010-12-19 18:40:07 UTC (rev 5333)
@@ -210,5 +210,12 @@
/// application should not close the connection.
/// </remarks>
IDbConnection Connection { get; }
+
+ /// <summary>
+ /// Sets the batch size of the session
+ /// </summary>
+ /// <param name="batchSize">The batch size.</param>
+ /// <returns>The same instance of the session for mthods chain.</returns>
+ IStatelessSession SetBatchSize(int batchSize);
}
}
Modified: trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2010-12-19 17:46:48 UTC (rev 5332)
+++ trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2010-12-19 18:40:07 UTC (rev 5333)
@@ -490,6 +490,12 @@
get { return connectionManager.GetConnection(); }
}
+ public IStatelessSession SetBatchSize(int batchSize)
+ {
+ Batcher.BatchSize = batchSize;
+ return this;
+ }
+
public override void Flush()
{
using (new SessionIdLoggingContext(SessionId))
Modified: trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs 2010-12-19 17:46:48 UTC (rev 5332)
+++ trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs 2010-12-19 18:40:07 UTC (rev 5333)
@@ -1,7 +1,9 @@
using System;
using System.Collections;
using System.Threading;
+using NHibernate.Engine;
using NUnit.Framework;
+using SharpTestsEx;
namespace NHibernate.Test.Stateless
{
@@ -176,5 +178,16 @@
}
}
}
+
+ [Test]
+ public void WhenSetTheBatchSizeThenSetTheBatchSizeOfTheBatcher()
+ {
+ using (IStatelessSession ss = sessions.OpenStatelessSession())
+ {
+ ss.SetBatchSize(37);
+ var impl = (ISessionImplementor)ss;
+ impl.Batcher.BatchSize.Should().Be(37);
+ }
+ }
}
}
\ 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: <fab...@us...> - 2010-12-22 17:30:54
|
Revision: 5334
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5334&view=rev
Author: fabiomaulo
Date: 2010-12-22 17:30:48 +0000 (Wed, 22 Dec 2010)
Log Message:
-----------
Fix NH-2457 (thanks to Maximilian Haru Raditya for the implementation without tests)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs
trunk/nhibernate/src/NHibernate/IStatelessSession.cs
trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs 2010-12-19 18:40:07 UTC (rev 5333)
+++ trunk/nhibernate/src/NHibernate/Criterion/DetachedCriteria.cs 2010-12-22 17:30:48 UTC (rev 5334)
@@ -71,7 +71,7 @@
/// to actually run the query.</summary>
public ICriteria GetExecutableCriteria(IStatelessSession session)
{
- impl.Session = (ISessionImplementor)session;
+ impl.Session = session.GetSessionImplementation();
return impl;
}
Modified: trunk/nhibernate/src/NHibernate/IStatelessSession.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/IStatelessSession.cs 2010-12-19 18:40:07 UTC (rev 5333)
+++ trunk/nhibernate/src/NHibernate/IStatelessSession.cs 2010-12-22 17:30:48 UTC (rev 5334)
@@ -1,6 +1,8 @@
using System;
using System.Data;
+using NHibernate.Engine;
+
namespace NHibernate
{
/// <summary>
@@ -24,6 +26,18 @@
/// <summary> Get the current Hibernate transaction.</summary>
ITransaction Transaction { get;}
+ /// <summary>
+ /// Gets the stateless session implementation.
+ /// </summary>
+ /// <remarks>
+ /// This method is provided in order to get the <b>NHibernate</b> implementation of the session from wrapper implementations.
+ /// Implementors of the <seealso cref="IStatelessSession"/> interface should return the NHibernate implementation of this method.
+ /// </remarks>
+ /// <returns>
+ /// An NHibernate implementation of the <seealso cref="ISessionImplementor"/> interface
+ /// </returns>
+ ISessionImplementor GetSessionImplementation();
+
/// <summary> Close the stateless session and release the ADO.NET connection.</summary>
void Close();
Modified: trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2010-12-19 18:40:07 UTC (rev 5333)
+++ trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2010-12-22 17:30:48 UTC (rev 5334)
@@ -543,6 +543,21 @@
set { }
}
+ /// <summary>
+ /// Gets the stateless session implementation.
+ /// </summary>
+ /// <remarks>
+ /// This method is provided in order to get the <b>NHibernate</b> implementation of the session from wrapper implementations.
+ /// Implementors of the <seealso cref="IStatelessSession"/> interface should return the NHibernate implementation of this method.
+ /// </remarks>
+ /// <returns>
+ /// An NHibernate implementation of the <seealso cref="ISessionImplementor"/> interface
+ /// </returns>
+ public ISessionImplementor GetSessionImplementation()
+ {
+ return this;
+ }
+
/// <summary> Close the stateless session and release the ADO.NET connection.</summary>
public void Close()
{
Modified: trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs 2010-12-19 18:40:07 UTC (rev 5333)
+++ trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs 2010-12-22 17:30:48 UTC (rev 5334)
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Threading;
+using NHibernate.Criterion;
using NHibernate.Engine;
using NUnit.Framework;
using SharpTestsEx;
@@ -189,5 +190,26 @@
impl.Batcher.BatchSize.Should().Be(37);
}
}
+
+ [Test]
+ public void CanGetImplementor()
+ {
+ using (IStatelessSession ss = sessions.OpenStatelessSession())
+ {
+ ss.GetSessionImplementation().Should().Be.SameInstanceAs(ss);
+ }
+ }
+
+ [Test]
+ public void HavingDetachedCriteriaThenCanGetExecutableCriteriaFromStatelessSession()
+ {
+ var dc = DetachedCriteria.For<Paper>();
+ using (IStatelessSession ss = sessions.OpenStatelessSession())
+ {
+ ICriteria criteria = null;
+ Executing.This(()=> criteria = dc.GetExecutableCriteria(ss)).Should().NotThrow();
+ criteria.Executing(c => c.List()).NotThrows();
+ }
+ }
}
}
\ 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: <pa...@us...> - 2010-12-25 00:40:56
|
Revision: 5337
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5337&view=rev
Author: patearl
Date: 2010-12-25 00:40:50 +0000 (Sat, 25 Dec 2010)
Log Message:
-----------
Added a workaround for a .NET bug (pre 4.0) to support adding null to a List<Nullable<T>>. This was required to fix a bug in nullable linq sums.
Added more tests for linq sums.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/Linq/SumTests.cs
Modified: trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs 2010-12-25 00:35:58 UTC (rev 5336)
+++ trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs 2010-12-25 00:40:50 UTC (rev 5337)
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Data;
+using System.Reflection;
using System.Text;
using NHibernate.SqlTypes;
using NHibernate.Type;
@@ -196,9 +197,41 @@
// NH-specific
public static void AddAll(IList to, IList from)
{
+ System.Action addNull = null;
foreach (object obj in from)
{
- to.Add(obj);
+ // There is bug in .NET, before version 4, where adding null to a List<Nullable<T>> through the non-generic IList interface throws an exception.
+ // TODO: Everything but the to.Add(obj) should should be conditionally compiled only for versions of .NET earlier than 4.
+ if (obj == null)
+ {
+ if (addNull == null)
+ {
+ if (to.GetType().IsGenericType &&
+ to.GetType().GetGenericTypeDefinition() == typeof(List<>) &&
+ to.GetType().GetGenericArguments()[0].IsGenericType &&
+ to.GetType().GetGenericArguments()[0].GetGenericTypeDefinition() == typeof(Nullable<>))
+ {
+ MethodInfo addMethod = to.GetType().GetMethod("Add");
+ System.Linq.Expressions.MethodCallExpression addMethodCall =
+ System.Linq.Expressions.Expression.Call(System.Linq.Expressions.Expression.Constant(to),
+ addMethod,
+ System.Linq.Expressions.Expression.Constant(null, to.GetType().GetGenericArguments()[0]));
+ System.Linq.Expressions.LambdaExpression addLambda =
+ System.Linq.Expressions.Expression.Lambda(addMethodCall);
+
+ addNull = (System.Action) addLambda.Compile();
+ }
+ else
+ {
+ addNull = () => to.Add(null);
+ }
+ }
+ addNull();
+ }
+ else
+ {
+ to.Add(obj);
+ }
}
}
Added: trunk/nhibernate/src/NHibernate.Test/Linq/SumTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Linq/SumTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Linq/SumTests.cs 2010-12-25 00:40:50 UTC (rev 5337)
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NUnit.Framework;
+
+namespace NHibernate.Test.Linq
+{
+ [TestFixture]
+ public class SumTests : LinqTestCase
+ {
+ [Test]
+ [ExpectedException]
+ public void EmptySumDecimal()
+ {
+ db.OrderLines.Where(ol => false).Sum(ol => ol.Discount);
+ }
+
+ [Test]
+ public void EmptySumCastNullableDecimal()
+ {
+ decimal total = db.OrderLines.Where(ol => false).Sum(ol => (decimal?)ol.Discount) ?? 0;
+ Assert.AreEqual(0, total);
+ }
+
+ [Test]
+ public void SumDecimal()
+ {
+ decimal total = db.OrderLines.Sum(ol => ol.Discount);
+ Assert.Greater(total, 0);
+ }
+
+ [Test]
+ public void EmptySumNullableDecimal()
+ {
+ decimal total = db.Orders.Where(ol => false).Sum(ol => ol.Freight) ?? 0;
+ Assert.AreEqual(0, total);
+ }
+
+ [Test]
+ public void SumNullableDecimal()
+ {
+ decimal? total = db.Orders.Sum(ol => ol.Freight);
+ Assert.Greater(total, 0);
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-12-25 00:35:58 UTC (rev 5336)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-12-25 00:40:50 UTC (rev 5337)
@@ -454,6 +454,7 @@
<Compile Include="Linq\QueryReuseTests.cs" />
<Compile Include="Linq\ReadonlyTestCase.cs" />
<Compile Include="Linq\StatelessSessionQueringTest.cs" />
+ <Compile Include="Linq\SumTests.cs" />
<Compile Include="Logging\Log4NetLoggerTest.cs" />
<Compile Include="Logging\LoggerProviderTest.cs" />
<Compile Include="NHSpecificTest\EntityNameAndCompositeId\Fixture.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2010-12-26 15:53:20
|
Revision: 5340
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5340&view=rev
Author: fabiomaulo
Date: 2010-12-26 15:53:13 +0000 (Sun, 26 Dec 2010)
Log Message:
-----------
Fix NH-2470
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2470/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs 2010-12-25 20:55:56 UTC (rev 5339)
+++ trunk/nhibernate/src/NHibernate/Collection/PersistentIdentifierBag.cs 2010-12-26 15:53:13 UTC (rev 5340)
@@ -3,6 +3,8 @@
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
+using System.Linq;
+using Iesi.Collections.Generic;
using NHibernate.DebugHelpers;
using NHibernate.Engine;
using NHibernate.Id;
@@ -31,6 +33,48 @@
[DebuggerTypeProxy(typeof (CollectionProxy))]
public class PersistentIdentifierBag : AbstractPersistentCollection, IList
{
+ [Serializable]
+ private class SnapshotElement : IEquatable<SnapshotElement>
+ {
+ public object Id { get; set; }
+ public object Value { get; set; }
+
+ public bool Equals(SnapshotElement other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+ return Equals(other.Id, Id);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ {
+ return false;
+ }
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+ if (obj.GetType() != typeof (SnapshotElement))
+ {
+ return false;
+ }
+ return Equals((SnapshotElement) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return (Id != null ? Id.GetHashCode() : 0);
+ }
+ }
+
protected IList values; //element
protected Dictionary<int, object> identifiers; //index -> id
@@ -77,7 +121,7 @@
private object GetIdentifier(int index)
{
// NH specific : To emulate IDictionary behavior but using Dictionary<int, object> (without boxing/unboxing for index)
- object result = null;
+ object result;
identifiers.TryGetValue(index, out result);
return result;
}
@@ -131,7 +175,7 @@
public override bool EqualsSnapshot(ICollectionPersister persister)
{
IType elementType = persister.ElementType;
- IDictionary snap = (IDictionary) GetSnapshot();
+ var snap = (ISet<SnapshotElement>) GetSnapshot();
if (snap.Count != values.Count)
{
return false;
@@ -140,12 +184,7 @@
{
object val = values[i];
object id = GetIdentifier(i);
- if (id == null)
- {
- return false;
- }
-
- object old = snap[id];
+ object old = snap.Where(x=> Equals(x.Id, id)).Select(x=> x.Value).FirstOrDefault();
if (elementType.IsDirty(old, val, Session))
{
return false;
@@ -157,13 +196,13 @@
public override bool IsSnapshotEmpty(object snapshot)
{
- return ((IDictionary) snapshot).Count == 0;
+ return ((ICollection) snapshot).Count == 0;
}
public override IEnumerable GetDeletes(ICollectionPersister persister, bool indexIsFormula)
{
- IDictionary snap = (IDictionary) GetSnapshot();
- ArrayList deletes = new ArrayList(snap.Keys);
+ var snap = (ISet<SnapshotElement>)GetSnapshot();
+ ArrayList deletes = new ArrayList(snap.Select(x=> x.Id).ToArray());
for (int i = 0; i < values.Count; i++)
{
if (values[i] != null)
@@ -186,17 +225,18 @@
public override object GetSnapshotElement(object entry, int i)
{
- IDictionary snap = (IDictionary) GetSnapshot();
+ var snap = (ISet<SnapshotElement>)GetSnapshot();
object id = GetIdentifier(i);
- return snap[id];
+ return snap.Where(x => Equals(x.Id, id)).Select(x => x.Value).FirstOrDefault();
}
public override bool NeedsInserting(object entry, int i, IType elemType)
{
- IDictionary snap = (IDictionary) GetSnapshot();
+ var snap = (ISet<SnapshotElement>)GetSnapshot();
object id = GetIdentifier(i);
+ object valueFound = snap.Where(x => Equals(x.Id, id)).Select(x => x.Value).FirstOrDefault();
- return entry != null && (id == null || snap[id] == null);
+ return entry != null && (id == null || valueFound == null);
}
public override bool NeedsUpdating(object entry, int i, IType elemType)
@@ -205,7 +245,7 @@
{
return false;
}
- IDictionary snap = (IDictionary) GetSnapshot();
+ var snap = (ISet<SnapshotElement>)GetSnapshot();
object id = GetIdentifier(i);
if (id == null)
@@ -213,7 +253,7 @@
return false;
}
- object old = snap[id];
+ object old = snap.Where(x => Equals(x.Id, id)).Select(x => x.Value).FirstOrDefault();
return old != null && elemType.IsDirty(old, entry, Session);
}
@@ -235,26 +275,22 @@
{
EntityMode entityMode = Session.EntityMode;
- Hashtable map = new Hashtable(values.Count);
+ var map = new HashedSet<SnapshotElement>();
int i = 0;
foreach (object value in values)
{
- // NH Different behavior : in Hb they use directly identifiers[i++]
- // probably we have some different behavior in some other place because a Snapshot before save the collection
- // when the identifiers dictionary is empty (in this case the Snapshot is unneeded before save)
object id;
- if (identifiers.TryGetValue(i++, out id))
- {
- map[id] = persister.ElementType.DeepCopy(value, entityMode, persister.Factory);
- }
+ identifiers.TryGetValue(i++, out id);
+ var valueCopy = persister.ElementType.DeepCopy(value, entityMode, persister.Factory);
+ map.Add(new SnapshotElement { Id = id, Value = valueCopy });
}
return map;
}
public override ICollection GetOrphans(object snapshot, string entityName)
{
- IDictionary sn = (IDictionary) snapshot;
- return GetOrphans(sn.Values, values, entityName, Session);
+ var sn = (ISet<SnapshotElement>)GetSnapshot();
+ return GetOrphans(sn.Select(x=> x.Value).ToArray(), values, entityName, Session);
}
public override void PreInsert(ICollectionPersister persister)
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2470/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2470/Mappings.hbm.xml 2010-12-25 20:55:56 UTC (rev 5339)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2470/Mappings.hbm.xml 2010-12-26 15:53:13 UTC (rev 5340)
@@ -12,7 +12,7 @@
<version name="EntityVersion"/>
<!-- NH2470 - I used to have inverse="true" here -->
- <idbag name="Class2List" table="Class1_Class2" access="field.camelcase-underscore">
+ <idbag name="Class2List" table="Class1_Class2" inverse="true" access="field.camelcase-underscore">
<collection-id column="ID" type="Guid">
<generator class="guid.comb" />
</collection-id>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aye...@us...> - 2010-12-27 14:12:30
|
Revision: 5341
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5341&view=rev
Author: ayenderahien
Date: 2010-12-27 14:12:24 +0000 (Mon, 27 Dec 2010)
Log Message:
-----------
Fixing an issue where filters would not be considered for extra lazy collection queries
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/BagWithLazyExtraAndFilter/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/BagWithLazyExtraAndFilter/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/BagWithLazyExtraAndFilter/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/BagWithLazyExtraAndFilter/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2010-12-26 15:53:13 UTC (rev 5340)
+++ trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2010-12-27 14:12:24 UTC (rev 5341)
@@ -42,7 +42,6 @@
private readonly SqlCommandInfo sqlInsertRowString;
private readonly SqlCommandInfo sqlUpdateRowString;
private readonly SqlCommandInfo sqlDeleteRowString;
- private readonly SqlString sqlSelectSizeString;
private readonly SqlString sqlSelectRowByIndexString;
private readonly SqlString sqlDetectRowByIndexString;
private readonly SqlString sqlDetectRowByElementString;
@@ -478,7 +477,7 @@
deleteAllCheckStyle = ExecuteUpdateResultCheckStyle.None;
}
- sqlSelectSizeString = GenerateSelectSizeString(collection.IsIndexed && !collection.IsMap);
+ isCollectionIntegerIndex = collection.IsIndexed && !collection.IsMap;
sqlDetectRowByIndexString = GenerateDetectRowByIndexString();
sqlDetectRowByElementString = GenerateDetectRowByElementString();
sqlSelectRowByIndexString = GenerateSelectRowByIndexString();
@@ -840,21 +839,21 @@
{
if (!hasWhere)
return sql;
- var sqlStringBuilder = new SqlStringBuilder(sql);
- sqlStringBuilder.Add(" and ").Add(sqlWhereString);
- return sqlStringBuilder.ToSqlString();
+ return sql.Append(" and ").Append(sqlWhereString);
}
- private SqlString GenerateSelectSizeString(bool isIntegerIndexed)
+
+ private SqlString GenerateSelectSizeString(ISessionImplementor sessionImplementor)
{
- string selectValue = isIntegerIndexed
+ string selectValue = isCollectionIntegerIndex
? "max(" + IndexColumnNames[0] + ") + 1"
: "count(" + ElementColumnNames[0] + ")"; //sets, maps, bags
-
- var sqlString=new SqlSimpleSelectBuilder(dialect, factory)
- .SetTableName(TableName)
- .AddWhereFragment(KeyColumnNames, KeyType, "=")
- .AddColumn(selectValue).ToSqlString();
- return AddWhereFragment(sqlString);
+
+ return new SqlSimpleSelectBuilder(dialect, factory)
+ .SetTableName(TableName)
+ .AddWhereFragment(KeyColumnNames, KeyType, "=")
+ .AddColumn(selectValue)
+ .ToSqlString()
+ .Append(FilterFragment(TableName, sessionImplementor.EnabledFilters));
}
private SqlString GenerateDetectRowByIndexString()
@@ -1507,7 +1506,12 @@
using(new SessionIdLoggingContext(session.SessionId))
try
{
- IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, sqlSelectSizeString, KeyType.SqlTypes(factory));
+ if(session.EnabledFilters.Count > 0)
+ {
+
+ }
+
+ IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, GenerateSelectSizeString(session), KeyType.SqlTypes(factory));
IDataReader rs = null;
try
{
@@ -1524,7 +1528,7 @@
{
throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, sqle,
"could not retrieve collection size: "
- + MessageHelper.InfoString(this, key, Factory), sqlSelectSizeString);
+ + MessageHelper.InfoString(this, key, Factory), GenerateSelectSizeString(session));
}
}
@@ -1575,7 +1579,7 @@
{
throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, sqle,
"could not check row existence: " + MessageHelper.InfoString(this, key, Factory),
- sqlSelectSizeString);
+ GenerateSelectSizeString(session));
}
}
@@ -1618,7 +1622,7 @@
{
throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, sqle,
"could not read row: " + MessageHelper.InfoString(this, key, Factory),
- sqlSelectSizeString);
+ GenerateSelectSizeString(session));
}
}
@@ -2006,8 +2010,9 @@
#region IPostInsertIdentityPersister Members
private string identitySelectString;
+ private bool isCollectionIntegerIndex;
- public string IdentitySelectString
+ public string IdentitySelectString
{
get
{
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/BagWithLazyExtraAndFilter/Domain.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/BagWithLazyExtraAndFilter/Domain.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/BagWithLazyExtraAndFilter/Domain.cs 2010-12-27 14:12:24 UTC (rev 5341)
@@ -0,0 +1,17 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.BagWithLazyExtraAndFilter
+{
+ public class Env
+ {
+ public virtual long Id { get; set; }
+ public virtual IList<MachineRequest> RequestsFailed { get; set; }
+ }
+
+ public class MachineRequest
+ {
+ public virtual long Id { get; set; }
+ public virtual int MachineRequestCompletionStatusInt { get; set; }
+ public virtual long EnvId { get; set; }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/BagWithLazyExtraAndFilter/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/BagWithLazyExtraAndFilter/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/BagWithLazyExtraAndFilter/Fixture.cs 2010-12-27 14:12:24 UTC (rev 5341)
@@ -0,0 +1,50 @@
+using System.Collections.Generic;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.BagWithLazyExtraAndFilter
+{
+ [TestFixture]
+ public class Fixture: BugTestCase
+ {
+ [Test]
+ public void CanUseFilterForLazyExtra()
+ {
+ using (var s = OpenSession())
+ {
+ s.BeginTransaction();
+ var machineRequest = new MachineRequest { EnvId = 1L, Id = 2L };
+ s.Save(new Env
+ {
+ Id = 1L,
+ RequestsFailed = new List<MachineRequest>
+ {
+ machineRequest
+ }
+ });
+ s.Save(machineRequest);
+ s.Transaction.Commit();
+ }
+
+ using (var s = OpenSession())
+ {
+ var env = s.Load<Env>(1L);
+ Assert.AreEqual(1, env.RequestsFailed.Count);
+ }
+
+ using (var s = OpenSession())
+ {
+ s.EnableFilter("CurrentOnly");
+ var env = s.Load<Env>(1L);
+ Assert.AreEqual(0, env.RequestsFailed.Count);
+ }
+
+ using (var s = OpenSession())
+ {
+ s.BeginTransaction();
+ s.Delete(s.Load<MachineRequest>(2L));
+ s.Delete(s.Load<Env>(1L));
+ s.Transaction.Commit();
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/BagWithLazyExtraAndFilter/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/BagWithLazyExtraAndFilter/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/BagWithLazyExtraAndFilter/Mappings.hbm.xml 2010-12-27 14:12:24 UTC (rev 5341)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.BagWithLazyExtraAndFilter"
+ assembly="NHibernate.Test">
+
+ <class name="Env" table="Envs" discriminator-value="null">
+ <id name="Id" type="Int64" unsaved-value="none">
+ <generator class="assigned"/>
+ </id>
+ <bag name="RequestsFailed" inverse="true" cascade="none" lazy="extra"
+ optimistic-lock="false"
+ where="MachineRequestCompletionStatusInt != 1">
+ <key column="EnvId"/>
+ <one-to-many class="MachineRequest"/>
+ <filter name="CurrentOnly"/>
+ </bag>
+
+ </class>
+
+
+ <class name="MachineRequest" table="MachineRequests" discriminator-value="null">
+ <id name="Id" type="Int64" unsaved-value="none">
+ <generator class="assigned"/>
+ </id>
+ <property name="EnvId"/>
+ <property name="MachineRequestCompletionStatusInt"/>
+ </class>
+
+ <filter-def name="CurrentOnly" condition="1 = 0"/>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-12-26 15:53:13 UTC (rev 5340)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-12-27 14:12:24 UTC (rev 5341)
@@ -457,6 +457,8 @@
<Compile Include="Linq\SumTests.cs" />
<Compile Include="Logging\Log4NetLoggerTest.cs" />
<Compile Include="Logging\LoggerProviderTest.cs" />
+ <Compile Include="NHSpecificTest\BagWithLazyExtraAndFilter\Domain.cs" />
+ <Compile Include="NHSpecificTest\BagWithLazyExtraAndFilter\Fixture.cs" />
<Compile Include="NHSpecificTest\EntityNameAndCompositeId\Fixture.cs" />
<Compile Include="NHSpecificTest\EntityNameWithFullName\Fixture.cs" />
<Compile Include="NHSpecificTest\Futures\LinqFutureFixture.cs" />
@@ -2369,6 +2371,7 @@
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="NHSpecificTest\BagWithLazyExtraAndFilter\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2470\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2056\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2043\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jul...@us...> - 2010-12-31 03:20:23
|
Revision: 5342
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5342&view=rev
Author: julian-maughan
Date: 2010-12-31 03:20:16 +0000 (Fri, 31 Dec 2010)
Log Message:
-----------
Mapping schema correction: added missing 'properties' element to 'subclass' element (ref. NH-2474).
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs
trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2010-12-27 14:12:24 UTC (rev 5341)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2010-12-31 03:20:16 UTC (rev 5342)
@@ -2,7 +2,7 @@
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -83,7 +83,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -110,7 +110,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -128,7 +128,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -193,7 +193,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -207,7 +207,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -372,7 +372,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -386,7 +386,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -413,7 +413,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[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", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[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", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -465,7 +465,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -524,7 +524,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[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", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -565,7 +565,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -586,7 +586,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -618,7 +618,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -636,7 +636,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -774,7 +774,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -788,7 +788,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmOuterJoinStrategy {
@@ -807,7 +807,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmFetchMode {
@@ -822,7 +822,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmLaziness {
@@ -841,7 +841,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmNotFoundMode {
@@ -856,7 +856,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -892,7 +892,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1009,7 +1009,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1027,7 +1027,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1045,7 +1045,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmPropertyGeneration {
@@ -1064,7 +1064,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1125,7 +1125,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1155,7 +1155,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1259,7 +1259,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1281,7 +1281,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmRestrictedLaziness {
@@ -1296,7 +1296,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1333,7 +1333,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1347,7 +1347,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1377,7 +1377,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmCustomSQLCheck {
@@ -1396,7 +1396,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmCollectionFetchMode {
@@ -1415,7 +1415,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1595,7 +1595,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmCollectionLazy {
@@ -1614,7 +1614,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1833,7 +1833,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1855,7 +1855,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmTuplizerEntitymode {
@@ -1874,7 +1874,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1924,7 +1924,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1983,7 +1983,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2028,7 +2028,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmUnsavedValueType {
@@ -2047,7 +2047,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2099,7 +2099,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2117,7 +2117,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2171,7 +2171,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2198,7 +2198,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2284,7 +2284,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2348,7 +2348,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2533,7 +2533,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2727,7 +2727,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2746,7 +2746,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2765,7 +2765,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2791,7 +2791,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2821,7 +2821,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2856,7 +2856,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2891,7 +2891,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2984,7 +2984,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -3126,7 +3126,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmPrimitivearrayOuterjoin {
@@ -3145,7 +3145,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmPrimitivearrayFetch {
@@ -3164,7 +3164,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -3348,7 +3348,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -3531,7 +3531,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -3564,7 +3564,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -3617,7 +3617,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmTimestampUnsavedvalue {
@@ -3632,7 +3632,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmTimestampSource {
@@ -3647,7 +3647,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmVersionGeneration {
@@ -3662,7 +3662,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -3723,7 +3723,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -3775,7 +3775,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -3858,7 +3858,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmJoinFetch {
@@ -3873,7 +3873,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -4034,7 +4034,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -4055,7 +4055,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.4000")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -4086,7 +4086,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.0.0.1001")]
+ [System.Code...
[truncated message content] |
|
From: <pa...@us...> - 2011-01-13 01:12:41
|
Revision: 5344
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5344&view=rev
Author: patearl
Date: 2011-01-13 01:12:33 +0000 (Thu, 13 Jan 2011)
Log Message:
-----------
Use loop to compare binary arrays rather than enumerators for roughly 5x performance increase.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Type/AbstractBinaryType.cs
trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs
Modified: trunk/nhibernate/src/NHibernate/Type/AbstractBinaryType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/AbstractBinaryType.cs 2010-12-31 03:23:40 UTC (rev 5343)
+++ trunk/nhibernate/src/NHibernate/Type/AbstractBinaryType.cs 2011-01-13 01:12:33 UTC (rev 5344)
@@ -46,7 +46,7 @@
if (x == null || y == null)
return false;
- return CollectionHelper.CollectionEquals<byte>(ToInternalFormat(x), ToInternalFormat(y));
+ return ArrayHelper.ArrayEquals(ToInternalFormat(x), ToInternalFormat(y));
}
public IComparer Comparator
Modified: trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs 2010-12-31 03:23:40 UTC (rev 5343)
+++ trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs 2011-01-13 01:12:33 UTC (rev 5344)
@@ -378,5 +378,25 @@
return true;
}
+
+ public static bool ArrayEquals(byte[] a, byte[] b)
+ {
+ if (a.Length != b.Length)
+ {
+ return false;
+ }
+
+ int i = 0;
+ int len = a.Length;
+ while(i < len)
+ {
+ if (a[i] != b[i])
+ {
+ return false;
+ }
+ i++;
+ }
+ return true;
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pa...@us...> - 2011-01-13 18:24:30
|
Revision: 5346
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5346&view=rev
Author: patearl
Date: 2011-01-13 18:24:22 +0000 (Thu, 13 Jan 2011)
Log Message:
-----------
Hql: Fixed NH-2499, allowing multiple when clauses in case statements.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlParser.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g
trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlParser.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlParser.cs 2011-01-13 17:55:17 UTC (rev 5345)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlParser.cs 2011-01-13 18:24:22 UTC (rev 5346)
@@ -1,4 +1,4 @@
-// $ANTLR 3.2 Sep 23, 2009 12:02:23 Hql.g 2011-01-13 10:47:54
+// $ANTLR 3.2 Sep 23, 2009 12:02:23 Hql.g 2011-01-13 11:20:20
// The variable 'variable' is assigned but its value is never used.
#pragma warning disable 168, 219
@@ -1787,7 +1787,7 @@
// AST REWRITE
- // elements: selectClause, selectClause, fromClause
+ // elements: selectClause, fromClause, selectClause
// token labels:
// rule labels: retval
// token list labels:
@@ -2118,7 +2118,7 @@
// AST REWRITE
- // elements: selectedPropertiesList, path
+ // elements: path, selectedPropertiesList
// token labels:
// rule labels: retval
// token list labels:
@@ -3467,7 +3467,7 @@
// AST REWRITE
- // elements: asAlias, propertyFetch, path
+ // elements: path, asAlias, propertyFetch
// token labels:
// rule labels: retval
// token list labels:
@@ -3713,7 +3713,7 @@
// AST REWRITE
- // elements: alias, path
+ // elements: path, alias
// token labels:
// rule labels: retval
// token list labels:
@@ -3921,7 +3921,7 @@
// AST REWRITE
- // elements: path, alias
+ // elements: alias, path
// token labels:
// rule labels: retval
// token list labels:
@@ -7541,7 +7541,7 @@
};
// $ANTLR start "caseExpression"
- // Hql.g:500:1: caseExpression : ( CASE ( whenClause )+ ( elseClause )? END -> ^( CASE whenClause ( elseClause )? ) | CASE unaryExpression ( altWhenClause )+ ( elseClause )? END -> ^( CASE2 unaryExpression ( altWhenClause )+ ( elseClause )? ) );
+ // Hql.g:500:1: caseExpression : ( CASE ( whenClause )+ ( elseClause )? END -> ^( CASE ( whenClause )+ ( elseClause )? ) | CASE unaryExpression ( altWhenClause )+ ( elseClause )? END -> ^( CASE2 unaryExpression ( altWhenClause )+ ( elseClause )? ) );
public HqlParser.caseExpression_return caseExpression() // throws RecognitionException [1]
{
HqlParser.caseExpression_return retval = new HqlParser.caseExpression_return();
@@ -7576,7 +7576,7 @@
RewriteRuleSubtreeStream stream_elseClause = new RewriteRuleSubtreeStream(adaptor,"rule elseClause");
try
{
- // Hql.g:501:2: ( CASE ( whenClause )+ ( elseClause )? END -> ^( CASE whenClause ( elseClause )? ) | CASE unaryExpression ( altWhenClause )+ ( elseClause )? END -> ^( CASE2 unaryExpression ( altWhenClause )+ ( elseClause )? ) )
+ // Hql.g:501:2: ( CASE ( whenClause )+ ( elseClause )? END -> ^( CASE ( whenClause )+ ( elseClause )? ) | CASE unaryExpression ( altWhenClause )+ ( elseClause )? END -> ^( CASE2 unaryExpression ( altWhenClause )+ ( elseClause )? ) )
int alt73 = 2;
int LA73_0 = input.LA(1);
@@ -7694,15 +7694,23 @@
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);
root_0 = (IASTNode)adaptor.GetNilNode();
- // 502:3: -> ^( CASE whenClause ( elseClause )? )
+ // 502:3: -> ^( CASE ( whenClause )+ ( elseClause )? )
{
- // Hql.g:502:6: ^( CASE whenClause ( elseClause )? )
+ // Hql.g:502:6: ^( CASE ( whenClause )+ ( elseClause )? )
{
IASTNode root_1 = (IASTNode)adaptor.GetNilNode();
root_1 = (IASTNode)adaptor.BecomeRoot(stream_CASE.NextNode(), root_1);
- adaptor.AddChild(root_1, stream_whenClause.NextTree());
- // Hql.g:502:24: ( elseClause )?
+ if ( !(stream_whenClause.HasNext()) ) {
+ throw new RewriteEarlyExitException();
+ }
+ while ( stream_whenClause.HasNext() )
+ {
+ adaptor.AddChild(root_1, stream_whenClause.NextTree());
+
+ }
+ stream_whenClause.Reset();
+ // Hql.g:502:25: ( elseClause )?
if ( stream_elseClause.HasNext() )
{
adaptor.AddChild(root_1, stream_elseClause.NextTree());
@@ -7721,10 +7729,10 @@
case 2 :
// Hql.g:503:4: CASE unaryExpression ( altWhenClause )+ ( elseClause )? END
{
- CASE198=(IToken)Match(input,CASE,FOLLOW_CASE_in_caseExpression2525);
+ CASE198=(IToken)Match(input,CASE,FOLLOW_CASE_in_caseExpression2526);
stream_CASE.Add(CASE198);
- PushFollow(FOLLOW_unaryExpression_in_caseExpression2527);
+ PushFollow(FOLLOW_unaryExpression_in_caseExpression2528);
unaryExpression199 = unaryExpression();
state.followingStackPointer--;
@@ -7747,7 +7755,7 @@
case 1 :
// Hql.g:503:26: altWhenClause
{
- PushFollow(FOLLOW_altWhenClause_in_caseExpression2530);
+ PushFollow(FOLLOW_altWhenClause_in_caseExpression2531);
altWhenClause200 = altWhenClause();
state.followingStackPointer--;
@@ -7781,7 +7789,7 @@
case 1 :
// Hql.g:503:43: elseClause
{
- PushFollow(FOLLOW_elseClause_in_caseExpression2535);
+ PushFollow(FOLLOW_elseClause_in_caseExpression2536);
elseClause201 = elseClause();
state.followingStackPointer--;
@@ -7792,13 +7800,13 @@
}
- END202=(IToken)Match(input,END,FOLLOW_END_in_caseExpression2539);
+ END202=(IToken)Match(input,END,FOLLOW_END_in_caseExpression2540);
stream_END.Add(END202);
// AST REWRITE
- // elements: unaryExpression, altWhenClause, elseClause
+ // elements: elseClause, altWhenClause, unaryExpression
// token labels:
// rule labels: retval
// token list labels:
@@ -7902,17 +7910,17 @@
// Hql.g:508:4: ( WHEN logicalExpression THEN expression )
// Hql.g:508:5: WHEN logicalExpression THEN expression
{
- WHEN203=(IToken)Match(input,WHEN,FOLLOW_WHEN_in_whenClause2568);
+ WHEN203=(IToken)Match(input,WHEN,FOLLOW_WHEN_in_whenClause2569);
WHEN203_tree = (IASTNode)adaptor.Create(WHEN203);
root_0 = (IASTNode)adaptor.BecomeRoot(WHEN203_tree, root_0);
- PushFollow(FOLLOW_logicalExpression_in_whenClause2571);
+ PushFollow(FOLLOW_logicalExpression_in_whenClause2572);
logicalExpression204 = logicalExpression();
state.followingStackPointer--;
adaptor.AddChild(root_0, logicalExpression204.Tree);
- THEN205=(IToken)Match(input,THEN,FOLLOW_THEN_in_whenClause2573);
- PushFollow(FOLLOW_expression_in_whenClause2576);
+ THEN205=(IToken)Match(input,THEN,FOLLOW_THEN_in_whenClause2574);
+ PushFollow(FOLLOW_expression_in_whenClause2577);
expression206 = expression();
state.followingStackPointer--;
@@ -7982,17 +7990,17 @@
// Hql.g:512:4: ( WHEN unaryExpression THEN expression )
// Hql.g:512:5: WHEN unaryExpression THEN expression
{
- WHEN207=(IToken)Match(input,WHEN,FOLLOW_WHEN_in_altWhenClause2590);
+ WHEN207=(IToken)Match(input,WHEN,FOLLOW_WHEN_in_altWhenClause2591);
WHEN207_tree = (IASTNode)adaptor.Create(WHEN207);
root_0 = (IASTNode)adaptor.BecomeRoot(WHEN207_tree, root_0);
- PushFollow(FOLLOW_unaryExpression_in_altWhenClause2593);
+ PushFollow(FOLLOW_unaryExpression_in_altWhenClause2594);
unaryExpression208 = unaryExpression();
state.followingStackPointer--;
adaptor.AddChild(root_0, unaryExpression208.Tree);
- THEN209=(IToken)Match(input,THEN,FOLLOW_THEN_in_altWhenClause2595);
- PushFollow(FOLLOW_expression_in_altWhenClause2598);
+ THEN209=(IToken)Match(input,THEN,FOLLOW_THEN_in_altWhenClause2596);
+ PushFollow(FOLLOW_expression_in_altWhenClause2599);
expression210 = expression();
state.followingStackPointer--;
@@ -8058,11 +8066,11 @@
// Hql.g:516:4: ( ELSE expression )
// Hql.g:516:5: ELSE expression
{
- ELSE211=(IToken)Match(input,ELSE,FOLLOW_ELSE_in_elseClause2612);
+ ELSE211=(IToken)Match(input,ELSE,FOLLOW_ELSE_in_elseClause2613);
ELSE211_tree = (IASTNode)adaptor.Create(ELSE211);
root_0 = (IASTNode)adaptor.BecomeRoot(ELSE211_tree, root_0);
- PushFollow(FOLLOW_expression_in_elseClause2615);
+ PushFollow(FOLLOW_expression_in_elseClause2616);
expression212 = expression();
state.followingStackPointer--;
@@ -8175,7 +8183,7 @@
case 1 :
// Hql.g:520:6: SOME
{
- SOME213=(IToken)Match(input,SOME,FOLLOW_SOME_in_quantifiedExpression2630);
+ SOME213=(IToken)Match(input,SOME,FOLLOW_SOME_in_quantifiedExpression2631);
SOME213_tree = (IASTNode)adaptor.Create(SOME213);
root_0 = (IASTNode)adaptor.BecomeRoot(SOME213_tree, root_0);
@@ -8185,7 +8193,7 @@
case 2 :
// Hql.g:520:14: EXISTS
{
- EXISTS214=(IToken)Match(input,EXISTS,FOLLOW_EXISTS_in_quantifiedExpression2635);
+ EXISTS214=(IToken)Match(input,EXISTS,FOLLOW_EXISTS_in_quantifiedExpression2636);
EXISTS214_tree = (IASTNode)adaptor.Create(EXISTS214);
root_0 = (IASTNode)adaptor.BecomeRoot(EXISTS214_tree, root_0);
@@ -8195,7 +8203,7 @@
case 3 :
// Hql.g:520:24: ALL
{
- ALL215=(IToken)Match(input,ALL,FOLLOW_ALL_in_quantifiedExpression2640);
+ ALL215=(IToken)Match(input,ALL,FOLLOW_ALL_in_quantifiedExpression2641);
ALL215_tree = (IASTNode)adaptor.Create(ALL215);
root_0 = (IASTNode)adaptor.BecomeRoot(ALL215_tree, root_0);
@@ -8205,7 +8213,7 @@
case 4 :
// Hql.g:520:31: ANY
{
- ANY216=(IToken)Match(input,ANY,FOLLOW_ANY_in_quantifiedExpression2645);
+ ANY216=(IToken)Match(input,ANY,FOLLOW_ANY_in_quantifiedExpression2646);
ANY216_tree = (IASTNode)adaptor.Create(ANY216);
root_0 = (IASTNode)adaptor.BecomeRoot(ANY216_tree, root_0);
@@ -8247,7 +8255,7 @@
case 1 :
// Hql.g:521:4: identifier
{
- PushFollow(FOLLOW_identifier_in_quantifiedExpression2654);
+ PushFollow(FOLLOW_identifier_in_quantifiedExpression2655);
identifier217 = identifier();
state.followingStackPointer--;
@@ -8258,7 +8266,7 @@
case 2 :
// Hql.g:521:17: collectionExpr
{
- PushFollow(FOLLOW_collectionExpr_in_quantifiedExpression2658);
+ PushFollow(FOLLOW_collectionExpr_in_quantifiedExpression2659);
collectionExpr218 = collectionExpr();
state.followingStackPointer--;
@@ -8272,11 +8280,11 @@
// Hql.g:521:34: ( OPEN ( subQuery ) CLOSE )
// Hql.g:521:35: OPEN ( subQuery ) CLOSE
{
- OPEN219=(IToken)Match(input,OPEN,FOLLOW_OPEN_in_quantifiedExpression2663);
+ OPEN219=(IToken)Match(input,OPEN,FOLLOW_OPEN_in_quantifiedExpression2664);
// Hql.g:521:41: ( subQuery )
// Hql.g:521:43: subQuery
{
- PushFollow(FOLLOW_subQuery_in_quantifiedExpression2668);
+ PushFollow(FOLLOW_subQuery_in_quantifiedExpression2669);
subQuery220 = subQuery();
state.followingStackPointer--;
@@ -8284,7 +8292,7 @@
}
- CLOSE221=(IToken)Match(input,CLOSE,FOLLOW_CLOSE_in_quantifiedExpression2672);
+ CLOSE221=(IToken)Match(input,CLOSE,FOLLOW_CLOSE_in_quantifiedExpression2673);
}
@@ -8363,7 +8371,7 @@
{
root_0 = (IASTNode)adaptor.GetNilNode();
- PushFollow(FOLLOW_primaryExpression_in_atom2691);
+ PushFollow(FOLLOW_primaryExpression_in_atom2692);
primaryExpression222 = primaryExpression();
state.followingStackPointer--;
@@ -8389,11 +8397,11 @@
case 1 :
// Hql.g:530:4: DOT identifier ( options {greedy=true; } : (op= OPEN exprList CLOSE ) )?
{
- DOT223=(IToken)Match(input,DOT,FOLLOW_DOT_in_atom2700);
+ DOT223=(IToken)Match(input,DOT,FOLLOW_DOT_in_atom2701);
DOT223_tree = (IASTNode)adaptor.Create(DOT223);
root_0 = (IASTNode)adaptor.BecomeRoot(DOT223_tree, root_0);
- PushFollow(FOLLOW_identifier_in_atom2703);
+ PushFollow(FOLLOW_identifier_in_atom2704);
identifier224 = identifier();
state.followingStackPointer--;
@@ -8414,17 +8422,17 @@
// Hql.g:532:6: (op= OPEN exprList CLOSE )
// Hql.g:532:8: op= OPEN exprList CLOSE
{
- op=(IToken)Match(input,OPEN,FOLLOW_OPEN_in_atom2731);
+ op=(IToken)Match(input,OPEN,FOLLOW_OPEN_in_atom2732);
op_tree = (IASTNode)adaptor.Create(op);
root_0 = (IASTNode)adaptor.BecomeRoot(op_tree, root_0);
op.Type = METHOD_CALL;
- PushFollow(FOLLOW_exprList_in_atom2736);
+ PushFollow(FOLLOW_exprList_in_atom2737);
exprList225 = exprList();
state.followingStackPointer--;
adaptor.AddChild(root_0, exprList225.Tree);
- CLOSE226=(IToken)Match(input,CLOSE,FOLLOW_CLOSE_in_atom2738);
+ CLOSE226=(IToken)Match(input,CLOSE,FOLLOW_CLOSE_in_atom2739);
}
@@ -8440,17 +8448,17 @@
case 2 :
// Hql.g:533:5: lb= OPEN_BRACKET expression CLOSE_BRACKET
{
- lb=(IToken)Match(input,OPEN_BRACKET,FOLLOW_OPEN_BRACKET_in_atom2752);
+ lb=(IToken)Match(input,OPEN_BRACKET,FOLLOW_OPEN_BRACKET_in_atom2753);
lb_tree = (IASTNode)adaptor.Create(lb);
root_0 = (IASTNode)adaptor.BecomeRoot(lb_tree, root_0);
lb.Type = INDEX_OP;
- PushFollow(FOLLOW_expression_in_atom2757);
+ PushFollow(FOLLOW_expression_in_atom2758);
expression227 = expression();
state.followingStackPointer--;
adaptor.AddChild(root_0, expression227.Tree);
- CLOSE_BRACKET228=(IToken)Match(input,CLOSE_BRACKET,FOLLOW_CLOSE_BRACKET_in_atom2759);
+ CLOSE_BRACKET228=(IToken)Match(input,CLOSE_BRACKET,FOLLOW_CLOSE_BRACKET_in_atom2760);
}
break;
@@ -8592,7 +8600,7 @@
{
root_0 = (IASTNode)adaptor.GetNilNode();
- PushFollow(FOLLOW_identPrimary_in_primaryExpression2779);
+ PushFollow(FOLLOW_identPrimary_in_primaryExpression2780);
identPrimary229 = identPrimary();
state.followingStackPointer--;
@@ -8615,11 +8623,11 @@
case 1 :
// Hql.g:539:46: DOT 'class'
{
- DOT230=(IToken)Match(input,DOT,FOLLOW_DOT_in_primaryExpression2792);
+ DOT230=(IToken)Match(input,DOT,FOLLOW_DOT_in_primaryExpression2793);
DOT230_tree = (IASTNode)adaptor.Create(DOT230);
root_0 = (IASTNode)adaptor.BecomeRoot(DOT230_tree, root_0);
- string_literal231=(IToken)Match(input,CLASS,FOLLOW_CLASS_in_primaryExpression2795);
+ string_literal231=(IToken)Match(input,CLASS,FOLLOW_CLASS_in_primaryExpression2796);
string_literal231_tree = (IASTNode)adaptor.Create(string_literal231);
adaptor.AddChild(root_0, string_literal231_tree);
@@ -8637,7 +8645,7 @@
{
root_0 = (IASTNode)adaptor.GetNilNode();
- PushFollow(FOLLOW_constant_in_primaryExpression2805);
+ PushFollow(FOLLOW_constant_in_primaryExpression2806);
constant232 = constant();
state.followingStackPointer--;
@@ -8650,11 +8658,11 @@
{
root_0 = (IASTNode)adaptor.GetNilNode();
- COLON233=(IToken)Match(input,COLON,FOLLOW_COLON_in_primaryExpression2812);
+ COLON233=(IToken)Match(input,COLON,FOLLOW_COLON_in_primaryExpression2813);
COLON233_tree = (IASTNode)adaptor.Create(COLON233);
root_0 = (IASTNode)adaptor.BecomeRoot(COLON233_tree, root_0);
- PushFollow(FOLLOW_identifier_in_primaryExpression2815);
+ PushFollow(FOLLOW_identifier_in_primaryExpression2816);
identifier234 = identifier();
state.followingStackPointer--;
@@ -8667,7 +8675,7 @@
{
root_0 = (IASTNode)adaptor.GetNilNode();
- OPEN235=(IToken)Match(input,OPEN,FOLLOW_OPEN_in_primaryExpression2824);
+ OPEN235=(IToken)Match(input,OPEN,FOLLOW_OPEN_in_primaryExpression2825);
// Hql.g:543:12: ( expressionOrVector | subQuery )
int alt79 = 2;
int LA79_0 = input.LA(1);
@@ -8692,7 +8700,7 @@
case 1 :
// Hql.g:543:13: expressionOrVector
{
- PushFollow(FOLLOW_expressionOrVector_in_primaryExpression2828);
+ PushFollow(FOLLOW_expressionOrVector_in_primaryExpression2829);
expressionOrVector236 = expressionOrVector();
state.followingStackPointer--;
@@ -8703,7 +8711,7 @@
case 2 :
// Hql.g:543:34: subQuery
{
- PushFollow(FOLLOW_subQuery_in_primaryExpression2832);
+ PushFollow(FOLLOW_subQuery_in_primaryExpression2833);
subQuery237 = subQuery();
state.followingStackPointer--;
@@ -8714,7 +8722,7 @@
}
- CLOSE238=(IToken)Match(input,CLOSE,FOLLOW_CLOSE_in_primaryExpression2835);
+ CLOSE238=(IToken)Match(input,CLOSE,FOLLOW_CLOSE_in_primaryExpression2836);
}
break;
@@ -8723,7 +8731,7 @@
{
root_0 = (IASTNode)adaptor.GetNilNode();
- PARAM239=(IToken)Match(input,PARAM,FOLLOW_PARAM_in_primaryExpression2843);
+ PARAM239=(IToken)Match(input,PARAM,FOLLOW_PARAM_in_primaryExpression2844);
PARAM239_tree = (IASTNode)adaptor.Create(PARAM239);
root_0 = (IASTNode)adaptor.BecomeRoot(PARAM239_tree, root_0);
@@ -8740,7 +8748,7 @@
case 1 :
// Hql.g:544:14: NUM_INT
{
- NUM_INT240=(IToken)Match(input,NUM_INT,FOLLOW_NUM_INT_in_primaryExpression2847);
+ NUM_INT240=(IToken)Match(input,NUM_INT,FOLLOW_NUM_INT_in_primaryExpression2848);
NUM_INT240_tree = (IASTNode)adaptor.Create(NUM_INT240);
adaptor.AddChild(root_0, NUM_INT240_tree);
@@ -8806,7 +8814,7 @@
// Hql.g:550:2: (e= expression (v= vectorExpr )? -> {v != null}? ^( VECTOR_EXPR[\"{vector}\"] $e $v) -> ^( $e) )
// Hql.g:550:4: e= expression (v= vectorExpr )?
{
- PushFollow(FOLLOW_expression_in_expressionOrVector2865);
+ PushFollow(FOLLOW_expression_in_expressionOrVector2866);
e = expression();
state.followingStackPointer--;
@@ -8824,7 +8832,7 @@
case 1 :
// Hql.g:550:19: v= vectorExpr
{
- PushFollow(FOLLOW_vectorExpr_in_expressionOrVector2871);
+ PushFollow(FOLLOW_vectorExpr_in_expressionOrVector2872);
v = vectorExpr();
state.followingStackPointer--;
@@ -8838,7 +8846,7 @@
// AST REWRITE
- // elements: e, e, v
+ // elements: e, v, e
// token labels:
// rule labels: v, retval, e
// token list labels:
@@ -8936,8 +8944,8 @@
{
root_0 = (IASTNode)adaptor.GetNilNode();
- COMMA241=(IToken)Match(input,COMMA,FOLLOW_COMMA_in_vectorExpr2910);
- PushFollow(FOLLOW_expression_in_vectorExpr2913);
+ COMMA241=(IToken)Match(input,COMMA,FOLLOW_COMMA_in_vectorExpr2911);
+ PushFollow(FOLLOW_expression_in_vectorExpr2914);
expression242 = expression();
state.followingStackPointer--;
@@ -8959,8 +8967,8 @@
case 1 :
// Hql.g:556:23: COMMA expression
{
- COMMA243=(IToken)Match(input,COMMA,FOLLOW_COMMA_in_vectorExpr2916);
- PushFollow(FOLLOW_expression_in_vectorExpr2919);
+ COMMA243=(IToken)Match(input,COMMA,FOLLOW_COMMA_in_vectorExpr2917);
+ PushFollow(FOLLOW_expression_in_vectorExpr2920);
expression244 = expression();
state.followingStackPointer--;
@@ -9065,7 +9073,7 @@
{
root_0 = (IASTNode)adaptor.GetNilNode();
- PushFollow(FOLLOW_identifier_in_identPrimary2935);
+ PushFollow(FOLLOW_identifier_in_identPrimary2936);
identifier245 = identifier();
state.followingStackPointer--;
@@ -9095,7 +9103,7 @@
case 1 :
// Hql.g:564:31: DOT ( identifier | o= OBJECT )
{
- DOT246=(IToken)Match(input,DOT,FOLLOW_DOT_in_identPrimary2953);
+ DOT246=(IToken)Match(input,DOT,FOLLOW_DOT_in_identPrimary2954);
DOT246_tree = (IASTNode)adaptor.Create(DOT246);
root_0 = (IASTNode)adaptor.BecomeRoot(DOT246_tree, root_0);
@@ -9123,7 +9131,7 @@
case 1 :
// Hql.g:564:38: identifier
{
- PushFollow(FOLLOW_identifier_in_identPrimary2958);
+ PushFollow(FOLLOW_identifier_in_identPrimary2959);
identifier247 = identifier();
state.followingStackPointer--;
@@ -9134,7 +9142,7 @@
case 2 :
// Hql.g:564:51: o= OBJECT
{
- o=(IToken)Match(input,OBJECT,FOLLOW_OBJECT_in_identPrimary2964);
+ o=(IToken)Match(input,OBJECT,FOLLOW_OBJECT_in_identPrimary2965);
o_tree = (IASTNode)adaptor.Create(o);
adaptor.AddChild(root_0, o_tree);
@@ -9173,17 +9181,17 @@
// Hql.g:565:6: (op= OPEN exprList CLOSE )
// Hql.g:565:8: op= OPEN exprList CLOSE
{
- op=(IToken)Match(input,OPEN,FOLLOW_OPEN_in_identPrimary2982);
+ op=(IToken)Match(input,OPEN,FOLLOW_OPEN_in_identPrimary2983);
op_tree = (IASTNode)adaptor.Create(op);
root_0 = (IASTNode)adaptor.BecomeRoot(op_tree, root_0);
op.Type = METHOD_CALL;
- PushFollow(FOLLOW_exprList_in_identPrimary2987);
+ PushFollow(FOLLOW_exprList_in_identPrimary2988);
exprList248 = exprList();
state.followingStackPointer--;
adaptor.AddChild(root_0, exprList248.Tree);
- CLOSE249=(IToken)Match(input,CLOSE,FOLLOW_CLOSE_in_identPrimary2989);
+ CLOSE249=(IToken)Match(input,CLOSE,FOLLOW_CLOSE_in_identPrimary2990);
}
@@ -9201,7 +9209,7 @@
{
root_0 = (IASTNode)adaptor.GetNilNode();
- PushFollow(FOLLOW_aggregate_in_identPrimary3005);
+ PushFollow(FOLLOW_aggregate_in_identPrimary3006);
aggregate250 = aggregate();
state.followingStackPointer--;
@@ -9354,7 +9362,7 @@
case 1 :
// Hql.g:577:6: op= SUM
{
- op=(IToken)Match(input,SUM,FOLLOW_SUM_in_aggregate3026);
+ op=(IToken)Match(input,SUM,FOLLOW_SUM_in_aggregate3027);
stream_SUM.Add(op);
@@ -9363,7 +9371,7 @@
case 2 :
// Hql.g:577:15: op= AVG
{
- op=(IToken)Match(input,AVG,FOLLOW_AVG_in_aggregate3032);
+ op=(IToken)Match(input,AVG,FOLLOW_AVG_in_aggregate3033);
stream_AVG.Add(op);
@@ -9372,7 +9380,7 @@
case 3 :
// Hql.g:577:24: op= MAX
{
- op=(IToken)Match(input,MAX,FOLLOW_MAX_in_aggregate3038);
+ op=(IToken)Match(input,MAX,FOLLOW_MAX_in_aggregate3039);
stream_MAX.Add(op);
@@ -9381,7 +9389,7 @@
case 4 :
// Hql.g:577:33: op= MIN
{
- op=(IToken)Match(input,MIN,FOLLOW_MIN_in_aggregate3044);
+ op=(IToken)Match(input,MIN,FOLLOW_MIN_in_aggregate3045);
stream_MIN.Add(op);
@@ -9390,15 +9398,15 @@
}
- OPEN251=(IToken)Match(input,OPEN,FOLLOW_OPEN_in_aggregate3048);
+ ...
[truncated message content] |
|
From: <pa...@us...> - 2011-01-13 22:46:31
|
Revision: 5347
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5347&view=rev
Author: patearl
Date: 2011-01-13 22:46:25 +0000 (Thu, 13 Jan 2011)
Log Message:
-----------
Improved flexibility in determining type of CASE statement result. Finds the first THEN clause with a known type and uses that. The original code only worked if the very first THEN clause had a known type.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CaseNode.cs
trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CaseNode.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CaseNode.cs 2011-01-13 18:24:22 UTC (rev 5346)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/CaseNode.cs 2011-01-13 22:46:25 UTC (rev 5347)
@@ -20,15 +20,39 @@
public override IType DataType
{
- get { return GetFirstThenNode().DataType; }
- set { base.DataType = value; }
+ get
+ {
+ for (int i = 0; i < ChildCount; i++)
+ {
+ IASTNode whenOrElseClause = GetChild(i);
+ if (whenOrElseClause.Type == HqlParser.WHEN)
+ {
+ // WHEN Child(0) THEN Child(1)
+ IASTNode thenClause = whenOrElseClause.GetChild(1);
+ if (thenClause is ISelectExpression)
+ {
+ return (thenClause as ISelectExpression).DataType;
+ }
+ }
+ else if (whenOrElseClause.Type == HqlParser.ELSE)
+ {
+ // ELSE Child(0)
+ IASTNode elseClause = whenOrElseClause.GetChild(0);
+ if (elseClause is ISelectExpression)
+ {
+ return (elseClause as ISelectExpression).DataType;
+ }
+ }
+ else
+ {
+ throw new HibernateException("Was expecting a WHEN or ELSE, but found a: " + whenOrElseClause.Text);
+ }
+ }
+ throw new HibernateException("Unable to determine data type of CASE statement.");
+ }
+ set { base.DataType = value; }
}
- private ISelectExpression GetFirstThenNode()
- {
- return (ISelectExpression) GetChild(0).GetChild(0).NextSibling;
- }
-
public override void SetScalarColumnText(int i)
{
ColumnHelper.GenerateSingleScalarColumn(ASTFactory, this, i );
Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs 2011-01-13 18:24:22 UTC (rev 5346)
+++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs 2011-01-13 22:46:25 UTC (rev 5347)
@@ -137,6 +137,69 @@
}
}
+ [Test]
+ public void ParameterInCaseThenClause()
+ {
+ using (ISession s = OpenSession())
+ using (s.BeginTransaction())
+ {
+ s.Save(new Animal { BodyWeight = 12, Description = "Polliwog" });
+ s.Transaction.Commit();
+ }
+
+ try
+ {
+ using (ISession s = OpenSession())
+ {
+ var result = s.CreateQuery("select case when 2=2 then ? else 0 end from Animal a")
+ .SetParameter(0, 1)
+ .UniqueResult();
+ Assert.AreEqual(1, result);
+ }
+ }
+ finally
+ {
+ using (ISession s = OpenSession())
+ using (s.BeginTransaction())
+ {
+ s.CreateQuery("delete from Animal").ExecuteUpdate();
+ s.Transaction.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void ParameterInCaseThenAndElseClausesWithCast()
+ {
+ using (ISession s = OpenSession())
+ using (s.BeginTransaction())
+ {
+ s.Save(new Animal { BodyWeight = 12, Description = "Polliwog" });
+ s.Transaction.Commit();
+ }
+
+ try
+ {
+ using (ISession s = OpenSession())
+ {
+ var result = s.CreateQuery("select case when 2=2 then cast(? as integer) else ? end from Animal a")
+ .SetParameter(0, 1)
+ .SetParameter(1, 0)
+ .UniqueResult();
+ Assert.AreEqual(1, result);
+ }
+ }
+ finally
+ {
+ using (ISession s = OpenSession())
+ using (s.BeginTransaction())
+ {
+ s.CreateQuery("delete from Animal").ExecuteUpdate();
+ s.Transaction.Commit();
+ }
+ }
+ }
+
[Test, Ignore("Not fixed yet.")]
public void SumShouldReturnDouble()
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pa...@us...> - 2011-01-13 23:27:00
|
Revision: 5348
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5348&view=rev
Author: patearl
Date: 2011-01-13 23:26:54 +0000 (Thu, 13 Jan 2011)
Log Message:
-----------
NH-2203: Move OrderBy clauses to end of query model. (Thanks to Jose F. Romaniello)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Linq/ReWriters/MoveOrderByToEndRewriter.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203/Mappings.hbm.xml
Added: trunk/nhibernate/src/NHibernate/Linq/ReWriters/MoveOrderByToEndRewriter.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/ReWriters/MoveOrderByToEndRewriter.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Linq/ReWriters/MoveOrderByToEndRewriter.cs 2011-01-13 23:26:54 UTC (rev 5348)
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Remotion.Data.Linq;
+using Remotion.Data.Linq.Clauses;
+
+namespace NHibernate.Linq.ReWriters
+{
+ public class MoveOrderByToEndRewriter
+ {
+ public static void ReWrite(QueryModel queryModel)
+ {
+ int len = queryModel.BodyClauses.Count;
+ for(int i=0; i<len; i++)
+ {
+ if (queryModel.BodyClauses[i] is OrderByClause)
+ {
+ // If we find an order by clause, move it to the end of the list.
+ // This preserves the ordering of multiple orderby clauses if there are any.
+ IBodyClause clause = queryModel.BodyClauses[i];
+ queryModel.BodyClauses.RemoveAt(i);
+ queryModel.BodyClauses.Add(clause);
+ i--;
+ len--;
+ }
+ }
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs 2011-01-13 22:46:25 UTC (rev 5347)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/QueryModelVisitor.cs 2011-01-13 23:26:54 UTC (rev 5348)
@@ -45,6 +45,9 @@
// Add left joins for references
AddLeftJoinsReWriter.ReWrite(queryModel, parameters.SessionFactory);
+ // Move OrderBy clauses to end
+ MoveOrderByToEndRewriter.ReWrite(queryModel);
+
// rewrite any operators that should be applied on the outer query
// by flattening out the sub-queries that they are located in
ResultOperatorRewriterResult result = ResultOperatorRewriter.Rewrite(queryModel);
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-01-13 22:46:25 UTC (rev 5347)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-01-13 23:26:54 UTC (rev 5348)
@@ -257,6 +257,7 @@
<Compile Include="ITransaction.cs" />
<Compile Include="LazyInitializationException.cs" />
<Compile Include="Linq\Functions\DictionaryGenerator.cs" />
+ <Compile Include="Linq\ReWriters\MoveOrderByToEndRewriter.cs" />
<Compile Include="Linq\ReWriters\ResultOperatorRewriter.cs" />
<Compile Include="Linq\ReWriters\ResultOperatorRewriterResult.cs" />
<Compile Include="Loader\Loader.cs" />
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203
___________________________________________________________________
Added: bugtraq:url
+ http://jira.nhibernate.org/browse/%BUGID%
Added: bugtraq:logregex
+ NH-\d+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203/Domain.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203/Domain.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203/Domain.cs 2011-01-13 23:26:54 UTC (rev 5348)
@@ -0,0 +1,8 @@
+namespace NHibernate.Test.NHSpecificTest.NH2203
+{
+ public class Artist
+ {
+ public virtual int Id { get; set; }
+ public virtual string Name { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203/Fixture.cs 2011-01-13 23:26:54 UTC (rev 5348)
@@ -0,0 +1,51 @@
+using System.Linq;
+using NHibernate.Linq;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.NHSpecificTest.NH2203
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ protected override void OnSetUp()
+ {
+ base.OnSetUp();
+ using (var session = sessions.OpenStatelessSession())
+ using (var tx = session.BeginTransaction())
+ {
+ foreach (var artistName in new[] { "Foo", "Bar", "Baz", "Soz", "Tiz", "Fez" })
+ {
+ session.Insert(new Artist { Name = artistName });
+ }
+ tx.Commit();
+ }
+ }
+
+ [Test]
+ public void QueryShouldWork()
+ {
+ using (var session = sessions.OpenSession())
+ using(session.BeginTransaction())
+ {
+ var actual = session.Query<Artist>()
+ .OrderBy(a => a.Name)
+ .Where(a => a.Name.StartsWith("F"))
+ .ToArray();
+
+ actual.Select(a => a.Name).Should().Have.SameSequenceAs("Fez", "Foo");
+ }
+ }
+
+ protected override void OnTearDown()
+ {
+ using(var session = sessions.OpenStatelessSession())
+ using (var tx = session.BeginTransaction())
+ {
+ session.CreateQuery("delete Artist").ExecuteUpdate();
+ tx.Commit();
+ }
+ base.OnTearDown();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2203/Mappings.hbm.xml 2011-01-13 23:26:54 UTC (rev 5348)
@@ -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.NH2203">
+
+ <class name="Artist">
+ <id name="Id" type="int">
+ <generator class="hilo"/>
+ </id>
+ <property name="Name" />
+ </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 2011-01-13 22:46:25 UTC (rev 5347)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-01-13 23:26:54 UTC (rev 5348)
@@ -496,6 +496,8 @@
<Compile Include="NHSpecificTest\NH2188\AppDomainWithMultipleSearchPath.cs" />
<Compile Include="NHSpecificTest\NH2202\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2202\Model.cs" />
+ <Compile Include="NHSpecificTest\NH2203\Domain.cs" />
+ <Compile Include="NHSpecificTest\NH2203\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2224\Domain.cs" />
<Compile Include="NHSpecificTest\NH2224\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2228\Domain.cs" />
@@ -2371,6 +2373,7 @@
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="NHSpecificTest\NH2203\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\BagWithLazyExtraAndFilter\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2470\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2056\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pa...@us...> - 2011-01-15 17:51:40
|
Revision: 5351
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5351&view=rev
Author: patearl
Date: 2011-01-15 17:51:33 +0000 (Sat, 15 Jan 2011)
Log Message:
-----------
Support subqueries in arithmetic expressions within HQL SQL generation.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g
trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/output/
Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs 2011-01-15 17:38:05 UTC (rev 5350)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Generated/HqlSqlWalker.cs 2011-01-15 17:51:33 UTC (rev 5351)
@@ -1,4 +1,4 @@
-// $ANTLR 3.2 Sep 23, 2009 12:02:23 HqlSqlWalker.g 2011-01-15 09:52:09
+// $ANTLR 3.2 Sep 23, 2009 12:02:23 HqlSqlWalker.g 2011-01-15 10:39:02
// The variable 'variable' is assigned but its value is never used.
#pragma warning disable 168, 219
@@ -677,16 +677,16 @@
// AST REWRITE
- // elements: w, f, s, u
+ // elements: s, u, f, w
// token labels: u
- // rule labels: f, w, retval, s
+ // rule labels: w, f, retval, s
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
RewriteRuleNodeStream stream_u = new RewriteRuleNodeStream(adaptor, "token u", u);
+ RewriteRuleSubtreeStream stream_w = new RewriteRuleSubtreeStream(adaptor, "rule w", w!=null ? w.Tree : null);
RewriteRuleSubtreeStream stream_f = new RewriteRuleSubtreeStream(adaptor, "rule f", f!=null ? f.Tree : null);
- RewriteRuleSubtreeStream stream_w = new RewriteRuleSubtreeStream(adaptor, "rule w", w!=null ? w.Tree : null);
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);
RewriteRuleSubtreeStream stream_s = new RewriteRuleSubtreeStream(adaptor, "rule s", s!=null ? s.Tree : null);
@@ -1757,15 +1757,15 @@
// AST REWRITE
- // elements: o, f, g, s, w
+ // elements: o, g, s, w, f
// token labels:
- // rule labels: w, f, g, retval, s, o
+ // rule labels: f, w, g, retval, s, o
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
+ RewriteRuleSubtreeStream stream_f = new RewriteRuleSubtreeStream(adaptor, "rule f", f!=null ? f.Tree : null);
RewriteRuleSubtreeStream stream_w = new RewriteRuleSubtreeStream(adaptor, "rule w", w!=null ? w.Tree : null);
- RewriteRuleSubtreeStream stream_f = new RewriteRuleSubtreeStream(adaptor, "rule f", f!=null ? f.Tree : null);
RewriteRuleSubtreeStream stream_g = new RewriteRuleSubtreeStream(adaptor, "rule g", g!=null ? g.Tree : null);
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);
RewriteRuleSubtreeStream stream_s = new RewriteRuleSubtreeStream(adaptor, "rule s", s!=null ? s.Tree : null);
@@ -2280,7 +2280,7 @@
// AST REWRITE
- // elements: x, d
+ // elements: d, x
// token labels: d
// rule labels: retval, x
// token list labels:
@@ -4453,7 +4453,7 @@
// AST REWRITE
- // elements: b, w
+ // elements: w, b
// token labels: w
// rule labels: retval, b
// token list labels:
@@ -4556,7 +4556,7 @@
// AST REWRITE
- // elements: b, w
+ // elements: w, b
// token labels: w
// rule labels: retval, b
// token list labels:
@@ -6636,7 +6636,7 @@
};
// $ANTLR start "arithmeticExpr"
- // HqlSqlWalker.g:367:1: arithmeticExpr : ( ^( PLUS expr expr ) | ^( MINUS expr expr ) | ^( DIV expr expr ) | ^( STAR expr expr ) | ^( BNOT expr ) | ^( BAND expr expr ) | ^( BOR expr expr ) | ^( BXOR expr expr ) | ^( UNARY_MINUS expr ) | c= caseExpr );
+ // HqlSqlWalker.g:367:1: arithmeticExpr : ( ^( PLUS exprOrSubquery exprOrSubquery ) | ^( MINUS exprOrSubquery exprOrSubquery ) | ^( DIV exprOrSubquery exprOrSubquery ) | ^( STAR exprOrSubquery exprOrSubquery ) | ^( BNOT exprOrSubquery ) | ^( BAND exprOrSubquery exprOrSubquery ) | ^( BOR exprOrSubquery exprOrSubquery ) | ^( BXOR exprOrSubquery exprOrSubquery ) | ^( UNARY_MINUS exprOrSubquery ) | c= caseExpr );
public HqlSqlWalker.arithmeticExpr_return arithmeticExpr() // throws RecognitionException [1]
{
HqlSqlWalker.arithmeticExpr_return retval = new HqlSqlWalker.arithmeticExpr_return();
@@ -6658,37 +6658,37 @@
IASTNode UNARY_MINUS170 = null;
HqlSqlWalker.caseExpr_return c = default(HqlSqlWalker.caseExpr_return);
- HqlSqlWalker.expr_return expr148 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery148 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr149 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery149 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr151 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery151 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr152 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery152 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr154 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery154 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr155 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery155 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr157 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery157 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr158 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery158 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr160 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery160 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr162 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery162 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr163 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery163 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr165 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery165 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr166 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery166 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr168 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery168 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr169 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery169 = default(HqlSqlWalker.exprOrSubquery_return);
- HqlSqlWalker.expr_return expr171 = default(HqlSqlWalker.expr_return);
+ HqlSqlWalker.exprOrSubquery_return exprOrSubquery171 = default(HqlSqlWalker.exprOrSubquery_return);
IASTNode PLUS147_tree=null;
@@ -6703,7 +6703,7 @@
try
{
- // HqlSqlWalker.g:374:2: ( ^( PLUS expr expr ) | ^( MINUS expr expr ) | ^( DIV expr expr ) | ^( STAR expr expr ) | ^( BNOT expr ) | ^( BAND expr expr ) | ^( BOR expr expr ) | ^( BXOR expr expr ) | ^( UNARY_MINUS expr ) | c= caseExpr )
+ // HqlSqlWalker.g:374:2: ( ^( PLUS exprOrSubquery exprOrSubquery ) | ^( MINUS exprOrSubquery exprOrSubquery ) | ^( DIV exprOrSubquery exprOrSubquery ) | ^( STAR exprOrSubquery exprOrSubquery ) | ^( BNOT exprOrSubquery ) | ^( BAND exprOrSubquery exprOrSubquery ) | ^( BOR exprOrSubquery exprOrSubquery ) | ^( BXOR exprOrSubquery exprOrSubquery ) | ^( UNARY_MINUS exprOrSubquery ) | c= caseExpr )
int alt49 = 10;
switch ( input.LA(1) )
{
@@ -6768,7 +6768,7 @@
switch (alt49)
{
case 1 :
- // HqlSqlWalker.g:374:4: ^( PLUS expr expr )
+ // HqlSqlWalker.g:374:4: ^( PLUS exprOrSubquery exprOrSubquery )
{
root_0 = (IASTNode)adaptor.GetNilNode();
@@ -6786,17 +6786,17 @@
Match(input, Token.DOWN, null);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1866);
- expr148 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1866);
+ exprOrSubquery148 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr148.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery148.Tree);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1868);
- expr149 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1868);
+ exprOrSubquery149 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr149.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery149.Tree);
Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1;
}
@@ -6805,7 +6805,7 @@
}
break;
case 2 :
- // HqlSqlWalker.g:375:4: ^( MINUS expr expr )
+ // HqlSqlWalker.g:375:4: ^( MINUS exprOrSubquery exprOrSubquery )
{
root_0 = (IASTNode)adaptor.GetNilNode();
@@ -6823,17 +6823,17 @@
Match(input, Token.DOWN, null);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1877);
- expr151 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1877);
+ exprOrSubquery151 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr151.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery151.Tree);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1879);
- expr152 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1879);
+ exprOrSubquery152 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr152.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery152.Tree);
Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1;
}
@@ -6842,7 +6842,7 @@
}
break;
case 3 :
- // HqlSqlWalker.g:376:4: ^( DIV expr expr )
+ // HqlSqlWalker.g:376:4: ^( DIV exprOrSubquery exprOrSubquery )
{
root_0 = (IASTNode)adaptor.GetNilNode();
@@ -6860,17 +6860,17 @@
Match(input, Token.DOWN, null);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1888);
- expr154 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1888);
+ exprOrSubquery154 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr154.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery154.Tree);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1890);
- expr155 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1890);
+ exprOrSubquery155 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr155.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery155.Tree);
Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1;
}
@@ -6879,7 +6879,7 @@
}
break;
case 4 :
- // HqlSqlWalker.g:377:4: ^( STAR expr expr )
+ // HqlSqlWalker.g:377:4: ^( STAR exprOrSubquery exprOrSubquery )
{
root_0 = (IASTNode)adaptor.GetNilNode();
@@ -6897,17 +6897,17 @@
Match(input, Token.DOWN, null);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1899);
- expr157 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1899);
+ exprOrSubquery157 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr157.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery157.Tree);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1901);
- expr158 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1901);
+ exprOrSubquery158 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr158.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery158.Tree);
Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1;
}
@@ -6916,7 +6916,7 @@
}
break;
case 5 :
- // HqlSqlWalker.g:378:4: ^( BNOT expr )
+ // HqlSqlWalker.g:378:4: ^( BNOT exprOrSubquery )
{
root_0 = (IASTNode)adaptor.GetNilNode();
@@ -6934,11 +6934,11 @@
Match(input, Token.DOWN, null);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1910);
- expr160 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1910);
+ exprOrSubquery160 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr160.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery160.Tree);
Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1;
}
@@ -6947,7 +6947,7 @@
}
break;
case 6 :
- // HqlSqlWalker.g:379:4: ^( BAND expr expr )
+ // HqlSqlWalker.g:379:4: ^( BAND exprOrSubquery exprOrSubquery )
{
root_0 = (IASTNode)adaptor.GetNilNode();
@@ -6965,17 +6965,17 @@
Match(input, Token.DOWN, null);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1919);
- expr162 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1919);
+ exprOrSubquery162 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr162.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery162.Tree);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1921);
- expr163 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1921);
+ exprOrSubquery163 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr163.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery163.Tree);
Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1;
}
@@ -6984,7 +6984,7 @@
}
break;
case 7 :
- // HqlSqlWalker.g:380:4: ^( BOR expr expr )
+ // HqlSqlWalker.g:380:4: ^( BOR exprOrSubquery exprOrSubquery )
{
root_0 = (IASTNode)adaptor.GetNilNode();
@@ -7002,17 +7002,17 @@
Match(input, Token.DOWN, null);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1930);
- expr165 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1930);
+ exprOrSubquery165 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr165.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery165.Tree);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1932);
- expr166 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1932);
+ exprOrSubquery166 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr166.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery166.Tree);
Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1;
}
@@ -7021,7 +7021,7 @@
}
break;
case 8 :
- // HqlSqlWalker.g:381:4: ^( BXOR expr expr )
+ // HqlSqlWalker.g:381:4: ^( BXOR exprOrSubquery exprOrSubquery )
{
root_0 = (IASTNode)adaptor.GetNilNode();
@@ -7039,17 +7039,17 @@
Match(input, Token.DOWN, null);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1941);
- expr168 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1941);
+ exprOrSubquery168 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr168.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery168.Tree);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1943);
- expr169 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1943);
+ exprOrSubquery169 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr169.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery169.Tree);
Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1;
}
@@ -7058,7 +7058,7 @@
}
break;
case 9 :
- // HqlSqlWalker.g:383:4: ^( UNARY_MINUS expr )
+ // HqlSqlWalker.g:383:4: ^( UNARY_MINUS exprOrSubquery )
{
root_0 = (IASTNode)adaptor.GetNilNode();
@@ -7076,11 +7076,11 @@
Match(input, Token.DOWN, null);
_last = (IASTNode)input.LT(1);
- PushFollow(FOLLOW_expr_in_arithmeticExpr1953);
- expr171 = expr();
+ PushFollow(FOLLOW_exprOrSubquery_in_arithmeticExpr1953);
+ exprOrSubquery171 = exprOrSubquery();
state.followingStackPointer--;
- adaptor.AddChild(root_1, expr171.Tree);
+ adaptor.AddChild(root_1, exprOrSubquery171.Tree);
Match(input, Token.UP, null); adaptor.AddChild(root_0, root_1);_last = _save_last_1;
}
@@ -8576,7 +8576,7 @@
// AST REWRITE
- // elements: d, lhs, rhs
+ // elements: d, rhs, lhs
// token labels: d
// rule labels: retval, rhs, lhs
// token list labels:
@@ -8692,7 +8692,7 @@
// AST REWRITE
- // elements: rhs2, lhs2, i
+ // elements: lhs2, i, rhs2
// token labels: i
// rule labels: retval, rhs2, lhs2
// token list labels:
@@ -9194,7 +9194,7 @@
// AST REWRITE
- // elements: d, rhs, lhs
+ // elements: lhs, rhs, d
// token labels: d
// rule labels: retval, rhs, lhs
// token list labels:
@@ -9900,30 +9900,30 @@
public static readonly BitSet FOLLOW_parameter_in_expr1831 = new BitSet(new ulong[]{0x0000000000000002UL});
public static readonly BitSet FOLLOW_count_in_expr1836 = new BitSet(new ulong[]{0x0000000000000002UL});
public static readonly BitSet FOLLOW_PLUS_in_arithmeticExpr1864 = new BitSet(new ulong[]{0x0000000000000004UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1866 = new BitSet(new ulong[]{0x0082008000109000UL,0x0F3FC007ED009120UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1868 = new BitSet(new ulong[]{0x0000000000000008UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1866 = new BitSet(new ulong[]{0x0086808000109030UL,0x0F3FC007ED109120UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1868 = new BitSet(new ulong[]{0x0000000000000008UL});
public static readonly BitSet FOLLOW_MINUS_in_arithmeticExpr1875 = new BitSet(new ulong[]{0x0000000000000004UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1877 = new BitSet(new ulong[]{0x0082008000109000UL,0x0F3FC007ED009120UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1879 = new BitSet(new ulong[]{0x0000000000000008UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1877 = new BitSet(new ulong[]{0x0086808000109030UL,0x0F3FC007ED109120UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1879 = new BitSet(new ulong[]{0x0000000000000008UL});
public static readonly BitSet FOLLOW_DIV_in_arithmeticExpr1886 = new BitSet(new ulong[]{0x0000000000000004UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1888 = new BitSet(new ulong[]{0x0082008000109000UL,0x0F3FC007ED009120UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1890 = new BitSet(new ulong[]{0x0000000000000008UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1888 = new BitSet(new ulong[]{0x0086808000109030UL,0x0F3FC007ED109120UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1890 = new BitSet(new ulong[]{0x0000000000000008UL});
public static readonly BitSet FOLLOW_STAR_in_arithmeticExpr1897 = new BitSet(new ulong[]{0x0000000000000004UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1899 = new BitSet(new ulong[]{0x0082008000109000UL,0x0F3FC007ED009120UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1901 = new BitSet(new ulong[]{0x0000000000000008UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1899 = new BitSet(new ulong[]{0x0086808000109030UL,0x0F3FC007ED109120UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1901 = new BitSet(new ulong[]{0x0000000000000008UL});
public static readonly BitSet FOLLOW_BNOT_in_arithmeticExpr1908 = new BitSet(new ulong[]{0x0000000000000004UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1910 = new BitSet(new ulong[]{0x0000000000000008UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1910 = new BitSet(new ulong[]{0x0000000000000008UL});
public static readonly BitSet FOLLOW_BAND_in_arithmeticExpr1917 = new BitSet(new ulong[]{0x0000000000000004UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1919 = new BitSet(new ulong[]{0x0082008000109000UL,0x0F3FC007ED009120UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1921 = new BitSet(new ulong[]{0x0000000000000008UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1919 = new BitSet(new ulong[]{0x0086808000109030UL,0x0F3FC007ED109120UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1921 = new BitSet(new ulong[]{0x0000000000000008UL});
public static readonly BitSet FOLLOW_BOR_in_arithmeticExpr1928 = new BitSet(new ulong[]{0x0000000000000004UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1930 = new BitSet(new ulong[]{0x0082008000109000UL,0x0F3FC007ED009120UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1932 = new BitSet(new ulong[]{0x0000000000000008UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1930 = new BitSet(new ulong[]{0x0086808000109030UL,0x0F3FC007ED109120UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1932 = new BitSet(new ulong[]{0x0000000000000008UL});
public static readonly BitSet FOLLOW_BXOR_in_arithmeticExpr1939 = new BitSet(new ulong[]{0x0000000000000004UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1941 = new BitSet(new ulong[]{0x0082008000109000UL,0x0F3FC007ED009120UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1943 = new BitSet(new ulong[]{0x0000000000000008UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1941 = new BitSet(new ulong[]{0x0086808000109030UL,0x0F3FC007ED109120UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1943 = new BitSet(new ulong[]{0x0000000000000008UL});
public static readonly BitSet FOLLOW_UNARY_MINUS_in_arithmeticExpr1951 = new BitSet(new ulong[]{0x0000000000000004UL});
- public static readonly BitSet FOLLOW_expr_in_arithmeticExpr1953 = new BitSet(new ulong[]{0x0000000000000008UL});
+ public static readonly BitSet FOLLOW_exprOrSubquery_in_arithmeticExpr1953 = new BitSet(new ulong[]{0x0000000000000008UL});
public static readonly BitSet FOLLOW_caseExpr_in_arithmeticExpr1961 = new BitSet(new ulong[]{0x0000000000000002UL});
public static readonly BitSet FOLLOW_CASE_in_caseExpr1973 = new BitSet(new ulong[]{0x0000000000000004UL});
public static readonly BitSet FOLLOW_WHEN_in_caseExpr1979 = new BitSet(new ulong[]{0x0000000000000004UL});
Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g 2011-01-15 17:38:05 UTC (rev 5350)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.g 2011-01-15 17:51:33 UTC (rev 5351)
@@ -371,16 +371,16 @@
PrepareArithmeticOperator( $arithmeticExpr.tree );
}
}
- : ^(PLUS expr expr)
- | ^(MINUS expr expr)
- | ^(DIV expr expr)
- | ^(STAR expr expr)
- | ^(BNOT expr)
- | ^(BAND expr expr)
- | ^(BOR expr expr)
- | ^(BXOR expr expr)
-// | ^(CONCAT expr (expr)+ )
- | ^(UNARY_MINUS expr)
+ : ^(PLUS exprOrSubquery exprOrSubquery)
+ | ^(MINUS exprOrSubquery exprOrSubquery)
+ | ^(DIV exprOrSubquery exprOrSubquery)
+ | ^(STAR exprOrSubquery exprOrSubquery)
+ | ^(BNOT exprOrSubquery)
+ | ^(BAND exprOrSubquery exprOrSubquery)
+ | ^(BOR exprOrSubquery exprOrSubquery)
+ | ^(BXOR exprOrSubquery exprOrSubquery)
+// | ^(CONCAT exprOrSubquery (exprOrSubquery)+ )
+ | ^(UNARY_MINUS exprOrSubquery)
| c=caseExpr
;
Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs 2011-01-15 17:38:05 UTC (rev 5350)
+++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/HqlFixture.cs 2011-01-15 17:51:33 UTC (rev 5351)
@@ -200,6 +200,36 @@
}
}
+ [Test]
+ public void SubselectAddition()
+ ...
[truncated message content] |
|
From: <pa...@us...> - 2011-01-16 20:55:20
|
Revision: 5354
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5354&view=rev
Author: patearl
Date: 2011-01-16 20:55:13 +0000 (Sun, 16 Jan 2011)
Log Message:
-----------
Linq: Fixed group by on multiple keys. Added more group by tests.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs
trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs
trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessGroupBy.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2362/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/Linq/ByMethod/GroupByTests.cs
Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs 2011-01-16 20:48:51 UTC (rev 5353)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeBuilder.cs 2011-01-16 20:55:13 UTC (rev 5354)
@@ -321,9 +321,9 @@
return new HqlDirectionDescending(_factory);
}
- public HqlGroupBy GroupBy(HqlExpression expression)
+ public HqlGroupBy GroupBy(params HqlExpression[] expressions)
{
- return new HqlGroupBy(_factory, expression);
+ return new HqlGroupBy(_factory, expressions);
}
public HqlAll All()
Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs 2011-01-16 20:48:51 UTC (rev 5353)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/HqlTreeNode.cs 2011-01-16 20:55:13 UTC (rev 5354)
@@ -786,7 +786,7 @@
public class HqlGroupBy : HqlStatement
{
- public HqlGroupBy(IASTFactory factory, HqlExpression expression) : base(HqlSqlWalker.GROUP, "group by", factory, expression)
+ public HqlGroupBy(IASTFactory factory, params HqlExpression[] expressions) : base(HqlSqlWalker.GROUP, "group by", factory, expressions)
{
}
}
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessGroupBy.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessGroupBy.cs 2011-01-16 20:48:51 UTC (rev 5353)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessGroupBy.cs 2011-01-16 20:55:13 UTC (rev 5354)
@@ -1,5 +1,8 @@
-using NHibernate.Hql.Ast;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+using NHibernate.Hql.Ast;
using Remotion.Data.Linq.Clauses.ResultOperators;
+using System.Linq;
namespace NHibernate.Linq.Visitors.ResultOperatorProcessors
{
@@ -7,9 +10,15 @@
{
public void Process(GroupResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree)
{
- tree.AddGroupByClause(tree.TreeBuilder.GroupBy(
- HqlGeneratorExpressionTreeVisitor.Visit(resultOperator.KeySelector, queryModelVisitor.VisitorParameters)
- .AsExpression()));
+ IEnumerable<Expression> groupByKeys;
+ if (resultOperator.KeySelector is NewExpression)
+ groupByKeys = (resultOperator.KeySelector as NewExpression).Arguments;
+ else
+ groupByKeys = new[] {resultOperator.KeySelector};
+
+ IEnumerable<HqlExpression> hqlGroupByKeys = groupByKeys.Select(k => HqlGeneratorExpressionTreeVisitor.Visit(k, queryModelVisitor.VisitorParameters).AsExpression());
+
+ tree.AddGroupByClause(tree.TreeBuilder.GroupBy(hqlGroupByKeys.ToArray()));
}
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Linq/ByMethod/GroupByTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Linq/ByMethod/GroupByTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Linq/ByMethod/GroupByTests.cs 2011-01-16 20:55:13 UTC (rev 5354)
@@ -0,0 +1,120 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NHibernate.DomainModel.Northwind.Entities;
+using NUnit.Framework;
+
+namespace NHibernate.Test.Linq.ByMethod
+{
+ [TestFixture]
+ public class GroupByTests : LinqTestCase
+ {
+ [Test]
+ public void SingleKeyGroupAndCount()
+ {
+ var orderCounts = db.Orders.GroupBy(o => o.Customer).Select(g => g.Count()).ToList();
+ Assert.AreEqual(89, orderCounts.Count);
+ Assert.AreEqual(830, orderCounts.Sum());
+ }
+
+ [Test]
+ public void MultipleKeyGroupAndCount()
+ {
+ var orderCounts = db.Orders.GroupBy(o => new {o.Customer, o.Employee}).Select(g => g.Count()).ToList();
+ Assert.AreEqual(464, orderCounts.Count);
+ Assert.AreEqual(830, orderCounts.Sum());
+ }
+
+ [Test]
+ [Ignore("Not working yet.")]
+ public void SingleKeyGrouping()
+ {
+ var orders = db.Orders.GroupBy(o => o.Customer).ToList();
+ Assert.That(orders.Count, Is.EqualTo(830));
+ CheckGrouping(orders, o => o.Customer);
+ }
+
+ [Test]
+ [Ignore("Not working yet.")]
+ public void MultipleKeyGrouping()
+ {
+ var orders = db.Orders.GroupBy(o => new { o.Customer, o.Employee }).ToList();
+ Assert.That(orders.Count, Is.EqualTo(830));
+
+ CheckGrouping(
+ orders.Select(g => new TupGrouping<Customer, Employee, Order>(g.Key.Customer, g.Key.Employee, g)),
+ o => o.Customer,
+ o => o.Employee);
+ }
+
+ private void CheckGrouping<TKey, TElement>(IEnumerable<IGrouping<TKey, TElement>> groupedItems, Func<TElement, TKey> groupBy)
+ {
+ HashSet<object> used = new HashSet<object>();
+ foreach (IGrouping<TKey, TElement> group in groupedItems)
+ {
+ Assert.IsFalse(used.Contains(group.Key));
+ used.Add(group.Key);
+
+ foreach (var item in group)
+ {
+ Assert.AreEqual(group.Key, groupBy(item));
+ }
+ }
+ }
+
+ private void CheckGrouping<TKey1, TKey2, TElement>(IEnumerable<TupGrouping<TKey1, TKey2, TElement>> groupedItems, Func<TElement, TKey1> groupBy1, Func<TElement, TKey2> groupBy2)
+ {
+ HashSet<object> used = new HashSet<object>();
+ foreach (IGrouping<Tup<TKey1, TKey2>, TElement> group in groupedItems)
+ {
+ Assert.IsFalse(used.Contains(group.Key.Item1));
+ used.Add(group.Key.Item1);
+ Assert.IsFalse(used.Contains(group.Key.Item2));
+ used.Add(group.Key.Item2);
+
+ foreach (var item in group)
+ {
+ Assert.AreEqual(group.Key.Item1, groupBy1(item));
+ Assert.AreEqual(group.Key.Item2, groupBy2(item));
+ }
+ }
+ }
+
+ private class TupGrouping<TKey1, TKey2, TElement> : IGrouping<Tup<TKey1, TKey2>, TElement>
+ {
+ private IEnumerable<TElement> Elements { get; set; }
+
+ public TupGrouping(TKey1 key1, TKey2 key2, IEnumerable<TElement> elements)
+ {
+ Key = new Tup<TKey1, TKey2>(key1, key2);
+ Elements = elements;
+ }
+
+ public IEnumerator<TElement> GetEnumerator()
+ {
+ return Elements.GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ public Tup<TKey1, TKey2> Key { get; private set; }
+ }
+
+ private class Tup<T1, T2>
+ {
+ public T1 Item1 { get; private set; }
+ public T2 Item2 { get; private set; }
+
+ public Tup(T1 item1, T2 item2)
+ {
+ Item1 = item1;
+ Item2 = item2;
+ }
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2362/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2362/Fixture.cs 2011-01-16 20:48:51 UTC (rev 5353)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2362/Fixture.cs 2011-01-16 20:55:13 UTC (rev 5354)
@@ -4,10 +4,10 @@
namespace NHibernate.Test.NHSpecificTest.NH2362
{
- [Ignore("Not fixed yet.")]
public class Fixture : BugTestCase
{
[Test]
+ [Ignore("Not working yet.")]
public void CanParseMultipleGroupByAndSelect()
{
using (var session = OpenSession())
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-01-16 20:48:51 UTC (rev 5353)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-01-16 20:55:13 UTC (rev 5354)
@@ -427,6 +427,7 @@
<Compile Include="Linq\BinaryBooleanExpressionTests.cs" />
<Compile Include="Linq\BinaryExpressionOrdererTests.cs" />
<Compile Include="Linq\BooleanMethodExtensionExample.cs" />
+ <Compile Include="Linq\ByMethod\GroupByTests.cs" />
<Compile Include="Linq\CasingTest.cs" />
<Compile Include="Linq\CollectionAssert.cs" />
<Compile Include="Linq\CustomExtensionsExample.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pa...@us...> - 2011-01-16 21:55:47
|
Revision: 5355
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5355&view=rev
Author: patearl
Date: 2011-01-16 21:55:41 +0000 (Sun, 16 Jan 2011)
Log Message:
-----------
Linq: Ignore duplicate joins when building expression map (NH2362).
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Visitors/LeftJoinDetector.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2362/Fixture.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/LeftJoinDetector.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/LeftJoinDetector.cs 2011-01-16 20:55:13 UTC (rev 5354)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/LeftJoinDetector.cs 2011-01-16 21:55:41 UTC (rev 5355)
@@ -31,8 +31,9 @@
if (expression.Type.IsNonPrimitive() && IsEntity(expression.Type))
{
var newExpr = AddJoin(expression);
- _expressionMap.Add(expression, newExpr);
- return newExpr;
+ if (!_expressionMap.ContainsKey(expression) || !_expressionMap[expression].Equals(newExpr)) // Second clause is sanity check.
+ _expressionMap.Add(expression, newExpr);
+ return newExpr;
}
return base.VisitMemberExpression(expression);
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2362/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2362/Fixture.cs 2011-01-16 20:55:13 UTC (rev 5354)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2362/Fixture.cs 2011-01-16 21:55:41 UTC (rev 5355)
@@ -7,7 +7,6 @@
public class Fixture : BugTestCase
{
[Test]
- [Ignore("Not working yet.")]
public void CanParseMultipleGroupByAndSelect()
{
using (var session = OpenSession())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pa...@us...> - 2011-01-16 22:48:52
|
Revision: 5356
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5356&view=rev
Author: patearl
Date: 2011-01-16 22:48:45 +0000 (Sun, 16 Jan 2011)
Log Message:
-----------
HQL: Fixed a bug relating to composite key SQL generation (NH-2280, Thanks Alex Baker).
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/InvalidSqlTest.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/Organisation.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/OrganisationCode.cs
Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2011-01-16 21:55:41 UTC (rev 5355)
+++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2011-01-16 22:48:45 UTC (rev 5356)
@@ -459,7 +459,10 @@
}
string result = StringHelper.Join(", ", cols);
- return cols.Length == 1 ? result : "(" + result + ")";
+ // There used to be code here that added parentheses if the number of columns was greater than one.
+ // This was causing invalid queries like select (c1, c2) from x. I couldn't think of a reason that
+ // parentheses would be wanted around a list of columns, so I removed them.
+ return result;
}
public void HandlePropertyBeingDereferenced(IType propertySource, string propertyName)
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/InvalidSqlTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/InvalidSqlTest.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/InvalidSqlTest.cs 2011-01-16 22:48:45 UTC (rev 5356)
@@ -0,0 +1,24 @@
+using System;
+
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using NHibernate.Dialect;
+using NHibernate.Linq;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH2280
+{
+ [TestFixture]
+ public class InvalidSqlTest : BugTestCase
+ {
+ [Test]
+ public void CompositeKeyTest()
+ {
+ using (ISession session = OpenSession())
+ {
+ session.Query<Organisation>().Where(o => o.Codes.Any(c => c.Key.Code == "1476")).ToList();
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/Mappings.hbm.xml 2011-01-16 22:48:45 UTC (rev 5356)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH2280">
+ <class name="Organisation" abstract="false" table="tblTrnOrganisation">
+ <id name="OrganisationId">
+ <generator class="guid"></generator>
+ </id>
+ <property name="LegalName" column="OrganisationLegalName"/>
+ <property name="Abn" />
+ <property name="Acn" />
+
+ <set name="Codes" table="tblTrnRtoCode" cascade="all-delete-orphan" inverse="true" >
+ <key column="OrganisationId"/>
+ <one-to-many class="OrganisationCode"/>
+ </set>
+ </class>
+
+ <class name="OrganisationCode" table="tblTrnRtoCode" dynamic-insert="true" dynamic-update="true">
+ <composite-id class="NHibernate.Test.NHSpecificTest.NH2280.OrganisationCodeKey, NHibernate.Test" name="Key" >
+ <key-many-to-one column="OrganisationId" class="Organisation" name="Organisation"/>
+ <key-property column="RtoCode" name="Code"/>
+ <key-property column="RtoCodeStartDate" name="StartDate"/>
+ </composite-id>
+ <property name="EndDate" column="RtoCodeEndDate"/>
+ </class>
+</hibernate-mapping>
+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/Organisation.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/Organisation.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/Organisation.cs 2011-01-16 22:48:45 UTC (rev 5356)
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Iesi.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH2280
+{
+ public class Organisation
+ {
+ public virtual Guid OrganisationId { get; set; }
+
+ public virtual ISet<OrganisationCode> Codes { get; protected internal set; }
+
+ public virtual string LegalName { get; set; }
+ public virtual string Abn { get; set; }
+ public virtual string Acn { get; set; }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/OrganisationCode.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/OrganisationCode.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2280/OrganisationCode.cs 2011-01-16 22:48:45 UTC (rev 5356)
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH2280
+{
+ public class OrganisationCode
+ {
+ private OrganisationCodeKey key = new OrganisationCodeKey();
+
+ public virtual DateTime StartDate
+ {
+ get { return key.StartDate; }
+ set { key.StartDate = value; }
+ }
+
+ public virtual string Code
+ {
+ get { return key.Code; }
+ set { key.Code = value; }
+ }
+
+ public virtual OrganisationCodeKey Key
+ {
+ get { return key; }
+ protected set { key = value; }
+ }
+
+ /// <summary>
+ /// Need comments for intellisense.
+ /// </summary>
+ public virtual Organisation Organisation
+ {
+ get { return key.Organisation; }
+ set { key.Organisation = value; }
+ }
+
+
+ public virtual DateTime? EndDate { get; set; }
+
+ public override bool Equals(object obj)
+ {
+ var other = obj as OrganisationCodeKey;
+ if (other == null)
+ {
+ return false;
+ }
+
+ return this.Code == other.Code && this.StartDate == other.StartDate;
+ }
+
+ public override int GetHashCode()
+ {
+ return Code == null ? 0 : Code.GetHashCode() ^ StartDate.GetHashCode();
+ }
+
+ public override string ToString()
+ {
+ return Code;
+ }
+ }
+
+ /// <summary>
+ /// blah blah blah
+ /// </summary>
+ [Serializable,
+ DebuggerDisplay("Organisation: {Organisation}, Code: {Code}, StartDate: {StartDate:d}")]
+ public class OrganisationCodeKey
+ {
+ public string Code { get; set; }
+ public DateTime StartDate { get; set; }
+ public Organisation Organisation { get; set; }
+
+ public override bool Equals(object obj)
+ {
+ OrganisationCodeKey other = obj as OrganisationCodeKey;
+ if (other == null)
+ {
+ return false;
+ }
+
+ return this.Organisation.OrganisationId == other.Organisation.OrganisationId && this.Code == other.Code &&
+ this.StartDate == other.StartDate;
+ }
+
+ public override int GetHashCode()
+ {
+ return (Organisation == null ? 0 : Organisation.GetHashCode()) ^ (Code == null ? 0 : Code.GetHashCode())
+ ^ StartDate.GetHashCode();
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-01-16 21:55:41 UTC (rev 5355)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-01-16 22:48:45 UTC (rev 5356)
@@ -521,6 +521,9 @@
<Compile Include="NHSpecificTest\NH2279\B.cs" />
<Compile Include="NHSpecificTest\NH2279\C.cs" />
<Compile Include="NHSpecificTest\NH2279\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH2280\InvalidSqlTest.cs" />
+ <Compile Include="NHSpecificTest\NH2280\Organisation.cs" />
+ <Compile Include="NHSpecificTest\NH2280\OrganisationCode.cs" />
<Compile Include="NHSpecificTest\NH2287\Domain.cs" />
<Compile Include="NHSpecificTest\NH2287\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2288\Fixture.cs" />
@@ -2375,6 +2378,7 @@
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="NHSpecificTest\NH2280\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2203\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\BagWithLazyExtraAndFilter\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2470\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pa...@us...> - 2011-01-17 04:00:37
|
Revision: 5357
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5357&view=rev
Author: patearl
Date: 2011-01-17 04:00:30 +0000 (Mon, 17 Jan 2011)
Log Message:
-----------
Linq: Generate left joins for order by clauses. (NH-2412)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/ReWriters/AddLeftJoinsReWriter.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Customer.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Order.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/ReWriters/AddLeftJoinsReWriter.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/ReWriters/AddLeftJoinsReWriter.cs 2011-01-16 22:48:45 UTC (rev 5356)
+++ trunk/nhibernate/src/NHibernate/Linq/ReWriters/AddLeftJoinsReWriter.cs 2011-01-17 04:00:30 UTC (rev 5357)
@@ -1,10 +1,10 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq.Expressions;
+using NHibernate.Linq.Visitors;
using Remotion.Data.Linq;
using Remotion.Data.Linq.Clauses;
-namespace NHibernate.Linq.Visitors
+namespace NHibernate.Linq.ReWriters
{
public class AddLeftJoinsReWriter : QueryModelVisitorBase
{
@@ -24,20 +24,37 @@
public override void VisitSelectClause(SelectClause selectClause, QueryModel queryModel)
{
- var joins = LeftJoinDetector.Detect(selectClause.Selector, new NameGenerator(queryModel), _sessionFactory);
+ selectClause.Selector = JoinReplacer(queryModel, selectClause.Selector);
+ }
- if (joins.Joins.Count > 0)
- {
- selectClause.Selector = joins.Selector;
+ public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
+ {
+ foreach (Ordering ordering in orderByClause.Orderings)
+ {
+ ordering.Expression = JoinReplacer(queryModel, ordering.Expression);
+ }
+ }
- queryModel.TransformExpressions(e => ExpressionSwapper.Swap(e, joins.ExpressionMap));
+ private Expression JoinReplacer(QueryModel queryModel, Expression expression)
+ {
+ var joins = LeftJoinDetector.Detect(expression, new NameGenerator(queryModel), _sessionFactory);
- foreach (var join in joins.Joins)
- {
- queryModel.BodyClauses.Add(join);
- }
- }
- }
+ Expression result = expression;
+
+ if (joins.Joins.Count > 0)
+ {
+ result = joins.Selector;
+
+ queryModel.TransformExpressions(e => ExpressionSwapper.Swap(e, joins.ExpressionMap));
+
+ foreach (var join in joins.Joins)
+ {
+ queryModel.BodyClauses.Add(join);
+ }
+ }
+
+ return result;
+ }
}
public class ExpressionSwapper : NhExpressionTreeVisitor
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Customer.cs (from rev 5344, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2392/A.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Customer.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Customer.cs 2011-01-17 04:00:30 UTC (rev 5357)
@@ -0,0 +1,11 @@
+using System;
+using System.Collections;
+
+namespace NHibernate.Test.NHSpecificTest.NH2412
+{
+ public class Customer
+ {
+ public int? Id { get; set; }
+ public string Name { get; set; }
+ }
+}
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Fixture.cs (from rev 5344, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2392/Fixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Fixture.cs 2011-01-17 04:00:30 UTC (rev 5357)
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NHibernate.Criterion;
+using NHibernate.Linq;
+using NHibernate.Linq.Functions;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH2412
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ protected override void OnTearDown()
+ {
+ using (ISession s = sessions.OpenSession())
+ {
+ s.Delete("from Order");
+ s.Delete("from Customer");
+ s.Flush();
+ }
+ }
+
+ [Test]
+ public void OrderByUsesLeftJoin()
+ {
+ ISession s = OpenSession();
+ try
+ {
+ Customer c1 = new Customer {Name = "Allen"};
+ s.Save(c1);
+ Customer c2 = new Customer {Name = "Bob"};
+ s.Save(c2);
+ Customer c3 = new Customer {Name = "Charlie"};
+ s.Save(c3);
+
+ s.Save(new Order {Customer = c1});
+ s.Save(new Order {Customer = c3});
+ s.Save(new Order {Customer = c2});
+ s.Save(new Order());
+
+ s.Flush();
+ }
+ finally
+ {
+ s.Close();
+ }
+
+ s = OpenSession();
+ try
+ {
+ var orders = s.Query<Order>().OrderBy(o => o.Customer.Name).ToList();
+ Assert.AreEqual(4, orders.Count);
+ if (orders[0].Customer == null)
+ {
+ CollectionAssert.AreEqual(new[] {"Allen", "Bob", "Charlie"}, orders.Skip(1).Select(o => o.Customer.Name).ToArray());
+ }
+ else
+ {
+ CollectionAssert.AreEqual(new[] { "Allen", "Bob", "Charlie" }, orders.Take(3).Select(o => o.Customer.Name).ToArray());
+ }
+ }
+ finally
+ {
+ s.Close();
+ }
+ }
+ }
+}
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Mappings.hbm.xml (from rev 5344, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2392/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Mappings.hbm.xml 2011-01-17 04:00:30 UTC (rev 5357)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH2412" default-lazy="false">
+ <class name="Customer" table="customers">
+ <id name="Id" column="id" unsaved-value="null">
+ <generator class="native" />
+ </id>
+ <property name="Name"/>
+ </class>
+ <class name="Order" table="orders">
+ <id name="Id" column="id" unsaved-value="null">
+ <generator class="native" />
+ </id>
+ <many-to-one name="Customer" class="Customer" column="customerid"/>
+ </class>
+</hibernate-mapping>
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Order.cs (from rev 5344, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2392/A.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Order.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2412/Order.cs 2011-01-17 04:00:30 UTC (rev 5357)
@@ -0,0 +1,11 @@
+using System;
+using System.Collections;
+
+namespace NHibernate.Test.NHSpecificTest.NH2412
+{
+ public class Order
+ {
+ public int? Id { get; set; }
+ public Customer Customer { get; set; }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-01-16 22:48:45 UTC (rev 5356)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-01-17 04:00:30 UTC (rev 5357)
@@ -579,6 +579,9 @@
<Compile Include="NHSpecificTest\NH2409\Message.cs" />
<Compile Include="NHSpecificTest\NH2409\MessageReading.cs" />
<Compile Include="NHSpecificTest\NH2409\User.cs" />
+ <Compile Include="NHSpecificTest\NH2412\Order.cs" />
+ <Compile Include="NHSpecificTest\NH2412\Customer.cs" />
+ <Compile Include="NHSpecificTest\NH2412\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2420\DummyEnlistment.cs" />
<Compile Include="NHSpecificTest\NH2420\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2420\MyTable.cs" />
@@ -2378,6 +2381,7 @@
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="NHSpecificTest\NH2412\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2280\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2203\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\BagWithLazyExtraAndFilter\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pa...@us...> - 2011-01-17 04:37:37
|
Revision: 5358
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5358&view=rev
Author: patearl
Date: 2011-01-17 04:37:31 +0000 (Mon, 17 Jan 2011)
Log Message:
-----------
Linq: Fixed query cache for "x is Type" operator. (NH-2459, thanks to Alex Baker for test.)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2459/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2459/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2459/Test.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2459/TrainingComponent.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs 2011-01-17 04:00:30 UTC (rev 5357)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs 2011-01-17 04:37:31 UTC (rev 5358)
@@ -198,7 +198,13 @@
protected override Expression VisitTypeBinaryExpression(TypeBinaryExpression expression)
{
- return base.VisitTypeBinaryExpression(expression);
+ _string.Append("IsType(");
+ VisitExpression(expression.Expression);
+ _string.Append(", ");
+ _string.Append(expression.TypeOperand.FullName);
+ _string.Append(")");
+
+ return expression;
}
protected override Expression VisitUnaryExpression(UnaryExpression expression)
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2459/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2459/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2459/Mappings.hbm.xml 2011-01-17 04:37:31 UTC (rev 5358)
@@ -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.NH2459">
+
+ <class name="TrainingComponent" abstract="true" table="tblTrnNrt" discriminator-value="-1">
+ <id name ="Id" column="NrtId">
+ <generator class="guid"></generator>
+ </id>
+ <discriminator column="NrtObjectTypeId" type="int" />
+
+ <property name="Code" column="NationalCode" length="12"></property>
+ <property name="Title" column="NationalTitle" length="200"></property>
+
+ </class>
+
+ <subclass name="SkillSet" discriminator-value="1" extends="TrainingComponent">
+
+ </subclass>
+
+ <subclass name="Qualification" discriminator-value="2" extends="TrainingComponent">
+
+ </subclass>
+
+</hibernate-mapping>
+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2459/Test.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2459/Test.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2459/Test.cs 2011-01-17 04:37:31 UTC (rev 5358)
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using log4net;
+using log4net.Appender;
+using log4net.Repository.Hierarchy;
+using NHibernate.Linq;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH2459
+{
+ [TestFixture]
+ public class Test : BugTestCase
+ {
+ protected override void OnSetUp()
+ {
+ using (ISession session = OpenSession())
+ {
+ SkillSet skillSet = new SkillSet() { Code = "123", Title = "Skill Set" };
+ Qualification qualification = new Qualification() { Code = "124", Title = "Qualification" };
+
+ session.Save(skillSet);
+ session.Save(qualification);
+ session.Flush();
+ }
+ }
+
+ [Test]
+ public void IsTypeOperator()
+ {
+ using (ISession session = OpenSession())
+ {
+ //first query is OK
+ IQueryable<TrainingComponent> query = session.Query<TrainingComponent>().Where(c => c is SkillSet);
+ Assert.That(!query.ToList().Any(c => !(c is SkillSet)));
+
+ //Second time round the a cached version of the SQL for the query is used BUT the type parameter is not updated...
+ query = session.Query<TrainingComponent>().Where(c => c is Qualification);
+ Assert.That(!query.ToList().Any(c => !(c is Qualification)));
+ }
+ }
+
+ protected override void OnTearDown()
+ {
+ using (ISession session = OpenSession())
+ {
+ session.Delete("from TrainingComponent");
+ session.Flush();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2459/TrainingComponent.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2459/TrainingComponent.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2459/TrainingComponent.cs 2011-01-17 04:37:31 UTC (rev 5358)
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH2459
+{
+ public class TrainingComponent
+ {
+ protected TrainingComponent() {}
+ public virtual Guid Id { get; set; }
+ public virtual string Code { get; set; }
+ public virtual string Title { get; set; }
+ }
+
+ public class SkillSet : TrainingComponent {
+
+ }
+
+ public class Qualification : TrainingComponent {
+
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-01-17 04:00:30 UTC (rev 5357)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-01-17 04:37:31 UTC (rev 5358)
@@ -587,6 +587,8 @@
<Compile Include="NHSpecificTest\NH2420\MyTable.cs" />
<Compile Include="NHSpecificTest\NH2441\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2441\Model.cs" />
+ <Compile Include="NHSpecificTest\NH2459\Test.cs" />
+ <Compile Include="NHSpecificTest\NH2459\TrainingComponent.cs" />
<Compile Include="NHSpecificTest\NH2470\Class1Class2Classes.cs" />
<Compile Include="NHSpecificTest\NH2470\Class1Class2DTOs.cs" />
<Compile Include="NHSpecificTest\NH2470\Class1Class2Tests.cs" />
@@ -2381,6 +2383,7 @@
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="NHSpecificTest\NH2459\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2412\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2280\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2203\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pa...@us...> - 2011-01-17 04:39:30
|
Revision: 5359
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5359&view=rev
Author: patearl
Date: 2011-01-17 04:39:24 +0000 (Mon, 17 Jan 2011)
Log Message:
-----------
Fixed indentation on a few lines.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs
trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs
Modified: trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2011-01-17 04:37:31 UTC (rev 5358)
+++ trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2011-01-17 04:39:24 UTC (rev 5359)
@@ -90,11 +90,11 @@
IList List(IQueryExpression queryExpression, QueryParameters parameters);
/// <summary>
- /// Create a new instance of <c>Query</c> for the given query expression
- /// <param name="queryExpression">A hibernate query expression</param>
- /// <returns>The query</returns>
- /// </summary>
- IQuery CreateQuery(IQueryExpression queryExpression);
+ /// Create a new instance of <c>Query</c> for the given query expression
+ /// <param name="queryExpression">A hibernate query expression</param>
+ /// <returns>The query</returns>
+ /// </summary>
+ IQuery CreateQuery(IQueryExpression queryExpression);
void List(string query, QueryParameters parameters, IList results);
Modified: trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs 2011-01-17 04:37:31 UTC (rev 5358)
+++ trunk/nhibernate/src/NHibernate/Linq/LinqExtensionMethods.cs 2011-01-17 04:39:24 UTC (rev 5359)
@@ -14,10 +14,10 @@
return new NhQueryable<T>(session as ISessionImplementor);
}
- public static IQueryable<T> Query<T>(this IStatelessSession session)
- {
- return new NhQueryable<T>(session as ISessionImplementor);
- }
+ public static IQueryable<T> Query<T>(this IStatelessSession session)
+ {
+ return new NhQueryable<T>(session as ISessionImplementor);
+ }
public static IQueryable<T> Cacheable<T>(this IQueryable<T> query)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pa...@us...> - 2011-01-17 05:55:54
|
Revision: 5360
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5360&view=rev
Author: patearl
Date: 2011-01-17 05:55:48 +0000 (Mon, 17 Jan 2011)
Log Message:
-----------
Linq: Fixed caching related to generic method calls. (NH-2433, Thanks to Dean Ward for patch.)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs
trunk/nhibernate/src/NHibernate.Test/Linq/ParameterisedQueries.cs
Modified: trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs 2011-01-17 04:39:24 UTC (rev 5359)
+++ trunk/nhibernate/src/NHibernate/Linq/Visitors/ExpressionKeyVisitor.cs 2011-01-17 05:55:48 UTC (rev 5360)
@@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Linq;
using System.Linq.Expressions;
+using System.Reflection;
using System.Text;
namespace NHibernate.Linq.Visitors
@@ -42,7 +44,7 @@
{
_string.Append(expression.Method.DeclaringType.Name);
_string.Append(".");
- _string.Append(expression.Method.Name);
+ VisitMethod(expression.Method);
}
else
{
@@ -85,7 +87,10 @@
}
else
{
- _string.Append(expression.Value);
+ if (expression.Value == null)
+ _string.Append("NULL");
+ else
+ _string.Append(expression.Value);
}
return base.VisitConstantExpression(expression);
@@ -165,7 +170,7 @@
{
VisitExpression(expression.Object);
_string.Append('.');
- _string.Append(expression.Method.Name);
+ VisitMethod(expression.Method);
_string.Append('(');
VisitList(expression.Arguments, AppendCommas);
_string.Append(')');
@@ -221,5 +226,16 @@
{
return base.VisitUnknownExpression(expression);
}
+
+ private void VisitMethod(MethodInfo methodInfo)
+ {
+ _string.Append(methodInfo.Name);
+ if (methodInfo.IsGenericMethod)
+ {
+ _string.Append('[');
+ _string.Append(string.Join(",", methodInfo.GetGenericArguments().Select(a => a.FullName).ToArray()));
+ _string.Append(']');
+ }
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/Linq/ParameterisedQueries.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Linq/ParameterisedQueries.cs 2011-01-17 04:39:24 UTC (rev 5359)
+++ trunk/nhibernate/src/NHibernate.Test/Linq/ParameterisedQueries.cs 2011-01-17 05:55:48 UTC (rev 5360)
@@ -169,6 +169,42 @@
}
}
+ [Test]
+ public void Different_OfType_Returns_Different_Keys()
+ {
+ using (var session = OpenSession())
+ {
+ Expression<Func<IEnumerable>> ofType1 = () => (from a in session.Query<Animal>().OfType<Cat>() where a.Pregnant select a.Id);
+ Expression<Func<IEnumerable>> ofType2 = () => (from a in session.Query<Animal>().OfType<Dog>() where a.Pregnant select a.Id);
+
+ var nhOfType1 = new NhLinqExpression(ofType1.Body);
+ var nhOfType2 = new NhLinqExpression(ofType2.Body);
+
+ Assert.AreNotEqual(nhOfType1.Key, nhOfType2.Key);
+ }
+ }
+
+ [Test]
+ public void Different_Null_Returns_Different_Keys()
+ {
+ using (var session = OpenSession())
+ {
+ string nullVariable = null;
+ string notNullVariable = "Hello";
+
+ Expression<Func<IEnumerable>> null1 = () => (from a in session.Query<Animal>() where a.Description == null select a);
+ Expression<Func<IEnumerable>> null2 = () => (from a in session.Query<Animal>() where a.Description == nullVariable select a);
+ Expression<Func<IEnumerable>> notNull = () => (from a in session.Query<Animal>() where a.Description == notNullVariable select a);
+
+ var nhNull1 = new NhLinqExpression(null1.Body);
+ var nhNull2 = new NhLinqExpression(null2.Body);
+ var nhNotNull = new NhLinqExpression(notNull.Body);
+
+ Assert.AreNotEqual(nhNull1.Key, nhNotNull.Key);
+ Assert.AreNotEqual(nhNull2.Key, nhNotNull.Key);
+ }
+ }
+
// TODO - different parameter names
protected override IList Mappings
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ric...@us...> - 2011-01-22 13:50:37
|
Revision: 5364
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5364&view=rev
Author: ricbrown
Date: 2011-01-22 13:50:30 +0000 (Sat, 22 Jan 2011)
Log Message:
-----------
Fix NH-2467 (Futures in 3.0.0.GA not working when using PostgreSQL) - thanks to Artem Tikhomirov for the patch.
Also fixes PostgresSQL tests:
NHibernate.Test.NHSpecificTest.NH2251.Fixture.EnlistingFirstThePaginationAndThenTheRowCountDoesNotThrows
NHibernate.Test.NHSpecificTest.NH2251.Fixture.FuturePagedHql
NHibernate.Test.NHSpecificTest.NH2251.Fixture.WhenUseFutureSkipTakeThenNotThrow
NHibernate.Test.NHSpecificTest.NH2362.Fixture.CanParseMultipleGroupBy
NHibernate.Test.NHSpecificTest.NH2362.Fixture.CanParseMultipleGroupByAndSelect
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs
trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs
trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/DomainClass.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/NH2467Test.cs
Modified: trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-01-18 07:02:44 UTC (rev 5363)
+++ trunk/nhibernate/src/NHibernate/Engine/QueryParameters.cs 2011-01-22 13:50:30 UTC (rev 5364)
@@ -553,12 +553,12 @@
else
{
paramTypeList.Add(NHibernateUtil.Int32);
- limitParameterIndex = totalSpan;
+ limitParameterIndex = startParameterIndex + totalSpan;
if (addOffset)
{
paramTypeList.Add(NHibernateUtil.Int32);
- offsetParameterIndex = totalSpan;
- limitParameterIndex = totalSpan + 1;
+ offsetParameterIndex = startParameterIndex + totalSpan;
+ limitParameterIndex = startParameterIndex + totalSpan + 1;
}
}
Modified: trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2011-01-18 07:02:44 UTC (rev 5363)
+++ trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2011-01-22 13:50:30 UTC (rev 5364)
@@ -5,11 +5,10 @@
using System.Diagnostics;
using Iesi.Collections;
using Iesi.Collections.Generic;
-
using NHibernate.Cache;
+using NHibernate.Criterion;
using NHibernate.Driver;
using NHibernate.Engine;
-using NHibernate.Criterion;
using NHibernate.Loader.Criteria;
using NHibernate.SqlCommand;
using NHibernate.SqlTypes;
@@ -319,18 +318,19 @@
{
int limitParameterSpan = BindLimitParametersFirstIfNeccesary(command, queryIndex, colIndex);
colIndex = BindQueryParameters(command, queryIndex, colIndex + limitParameterSpan);
- BindLimitParametersLastIfNeccesary(command, queryIndex, colIndex);
+ colIndex += BindLimitParametersLastIfNeccesary(command, queryIndex, colIndex);
}
}
- private void BindLimitParametersLastIfNeccesary(IDbCommand command, int queryIndex, int colIndex)
+ private int BindLimitParametersLastIfNeccesary(IDbCommand command, int queryIndex, int colIndex)
{
QueryParameters parameter = parameters[queryIndex];
RowSelection selection = parameter.RowSelection;
if (Loader.Loader.UseLimit(selection, dialect) && !dialect.BindLimitParametersFirst)
{
- Loader.Loader.BindLimitParameters(command, colIndex, selection, session);
+ return Loader.Loader.BindLimitParameters(command, colIndex, selection, session);
}
+ return 0;
}
private int BindQueryParameters(IDbCommand command, int queryIndex, int colIndex)
Modified: trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2011-01-18 07:02:44 UTC (rev 5363)
+++ trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2011-01-22 13:50:30 UTC (rev 5364)
@@ -1,9 +1,10 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using Iesi.Collections;
-
+using Iesi.Collections.Generic;
using NHibernate.Cache;
using NHibernate.Driver;
using NHibernate.Engine;
@@ -12,8 +13,6 @@
using NHibernate.SqlTypes;
using NHibernate.Transform;
using NHibernate.Type;
-using Iesi.Collections.Generic;
-using System.Collections.Generic;
namespace NHibernate.Impl
{
@@ -653,18 +652,19 @@
{
int limitParameterSpan = BindLimitParametersFirstIfNeccesary(command, queryIndex, colIndex);
colIndex = BindQueryParameters(command, queryIndex, colIndex + limitParameterSpan);
- BindLimitParametersLastIfNeccesary(command, queryIndex, colIndex);
+ colIndex += BindLimitParametersLastIfNeccesary(command, queryIndex, colIndex);
}
}
- private void BindLimitParametersLastIfNeccesary(IDbCommand command, int queryIndex, int colIndex)
+ private int BindLimitParametersLastIfNeccesary(IDbCommand command, int queryIndex, int colIndex)
{
QueryParameters parameter = parameters[queryIndex];
RowSelection selection = parameter.RowSelection;
if (Loader.Loader.UseLimit(selection, dialect) && !dialect.BindLimitParametersFirst)
{
- Loader.Loader.BindLimitParameters(command, colIndex, selection, session);
+ return Loader.Loader.BindLimitParameters(command, colIndex, selection, session);
}
+ return 0;
}
private int BindQueryParameters(IDbCommand command, int queryIndex, int colIndex)
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/DomainClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/DomainClass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/DomainClass.cs 2011-01-22 13:50:30 UTC (rev 5364)
@@ -0,0 +1,20 @@
+
+
+namespace NHibernate.Test.NHSpecificTest.NH2467
+{
+ public class DomainClass
+ {
+
+ public int Id
+ {
+ get;
+ set;
+ }
+
+ public string Data
+ {
+ get;
+ set;
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/Mappings.hbm.xml 2011-01-22 13:50:30 UTC (rev 5364)
@@ -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.NH2467"
+ default-lazy="false">
+ <class name="DomainClass">
+ <id name="Id">
+ <generator class="assigned" />
+ </id>
+ <property name="Data" />
+ </class>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/NH2467Test.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/NH2467Test.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2467/NH2467Test.cs 2011-01-22 13:50:30 UTC (rev 5364)
@@ -0,0 +1,126 @@
+using System.Linq;
+using NHibernate.Criterion;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH2467
+{
+ [TestFixture]
+ public class NH2467Test : BugTestCase
+ {
+ protected override void OnSetUp()
+ {
+ base.OnSetUp();
+ using (var session = OpenSession())
+ {
+ var entity = new DomainClass {Id = 1, Data = "Test"};
+ session.Save(entity);
+ session.Flush();
+ }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect.SupportsLimit && !dialect.BindLimitParametersFirst;
+ }
+
+ protected override void OnTearDown()
+ {
+ base.OnTearDown();
+ using (var session = OpenSession())
+ {
+ session.Delete("from System.Object");
+ session.Flush();
+ }
+ }
+
+ [Test]
+ public void ShouldNotThrowOnFuturePaging()
+ {
+ using (var session = OpenSession())
+ {
+
+ var contentQuery = session
+ .CreateCriteria<DomainClass>()
+ .Add(Restrictions.Eq("Data", "Test"));
+ contentQuery.SetMaxResults(2);
+ contentQuery.SetFirstResult(0);
+ var content = contentQuery.Future<DomainClass>();
+
+ var countQuery = session
+ .CreateCriteria<DomainClass>()
+ .Add(Restrictions.Eq("Data", "Test"));
+ countQuery.SetProjection(Projections.RowCount());
+ var count = countQuery.FutureValue<int>();
+
+ // triggers batch operation, should not throw
+ var result = content.ToList();
+ }
+ }
+
+ [Test]
+ public void ShouldNotThrowOnReversedFuturePaging()
+ {
+ using (var session = OpenSession())
+ {
+
+ var countQuery = session
+ .CreateCriteria<DomainClass>()
+ .Add(Restrictions.Eq("Data", "Test"));
+ countQuery.SetProjection(Projections.RowCount());
+ var count = countQuery.FutureValue<int>();
+
+ var contentQuery = session
+ .CreateCriteria<DomainClass>()
+ .Add(Restrictions.Eq("Data", "Test"));
+ contentQuery.SetMaxResults(2);
+ contentQuery.SetFirstResult(0);
+ var content = contentQuery.Future<DomainClass>();
+
+ // triggers batch operation, should not throw
+ var result = content.ToList();
+ }
+ }
+
+ [Test]
+ public void ShouldNotThrowOnFuturePagingUsingHql()
+ {
+ using (var session = OpenSession())
+ {
+
+ var contentQuery = session.CreateQuery("from DomainClass as d where d.Data = ?");
+ contentQuery.SetString(0, "Test");
+ contentQuery.SetMaxResults(2);
+ contentQuery.SetFirstResult(0);
+ var content = contentQuery.Future<DomainClass>();
+
+ var countQuery = session.CreateQuery("select count(d) from DomainClass as d where d.Data = ?");
+ countQuery.SetString(0, "Test");
+ var count = countQuery.FutureValue<long>();
+
+ Assert.AreEqual(1, content.ToList().Count);
+ Assert.AreEqual(1, count.Value);
+ }
+ }
+
+ [Test]
+ public void ShouldNotThrowOnReversedFuturePagingUsingHql()
+ {
+ using (var session = OpenSession())
+ {
+
+ var contentQuery = session.CreateQuery("from DomainClass as d where d.Data = ?");
+ contentQuery.SetString(0, "Test");
+ contentQuery.SetMaxResults(2);
+ contentQuery.SetFirstResult(0);
+ var content = contentQuery.Future<DomainClass>();
+
+ var countQuery = session.CreateQuery("select count(d) from DomainClass as d where d.Data = ?");
+ countQuery.SetString(0, "Test");
+ var count = countQuery.FutureValue<long>();
+
+ Assert.AreEqual(1, content.ToList().Count);
+ Assert.AreEqual(1, count.Value);
+ }
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-01-18 07:02:44 UTC (rev 5363)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-01-22 13:50:30 UTC (rev 5364)
@@ -598,6 +598,8 @@
<Compile Include="NHSpecificTest\NH2420\MyTable.cs" />
<Compile Include="NHSpecificTest\NH2441\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2441\Model.cs" />
+ <Compile Include="NHSpecificTest\NH2467\DomainClass.cs" />
+ <Compile Include="NHSpecificTest\NH2467\NH2467Test.cs" />
<Compile Include="NHSpecificTest\NH2459\Test.cs" />
<Compile Include="NHSpecificTest\NH2459\TrainingComponent.cs" />
<Compile Include="NHSpecificTest\NH2470\Class1Class2Classes.cs" />
@@ -2397,6 +2399,7 @@
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="NHSpecificTest\NH2467\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2459\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2412\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2280\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-01-22 14:50:36
|
Revision: 5365
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5365&view=rev
Author: fabiomaulo
Date: 2011-01-22 14:50:28 +0000 (Sat, 22 Jan 2011)
Log Message:
-----------
Fix NH-2473
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameAndInheritance/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameAndInheritance/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameAndInheritance/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2011-01-22 13:50:30 UTC (rev 5364)
+++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2011-01-22 14:50:28 UTC (rev 5365)
@@ -3898,29 +3898,19 @@
{
return this;
}
- else
+ // TODO : really need a way to do something like :
+ // getTuplizer(entityMode).determineConcreteSubclassEntityName(instance)
+ var clazz = instance.GetType();
+ if (clazz == GetMappedClass(entityMode))
{
- // TODO : really need a way to do something like :
- // getTuplizer(entityMode).determineConcreteSubclassEntityName(instance)
- System.Type clazz = instance.GetType();
- if (clazz == GetMappedClass(entityMode))
- {
- return this;
- }
- else
- {
- string subclassEntityName = GetSubclassEntityName(clazz);
- if (subclassEntityName == null)
- {
- throw new HibernateException("instance not of expected entity type: " + clazz.FullName + " is not a: "
- + EntityName);
- }
- else
- {
- return factory.GetEntityPersister(subclassEntityName);
- }
- }
+ return this;
}
+ var subclassEntityName = GetSubclassEntityName(clazz);
+ if (subclassEntityName == null || EntityName.Equals(subclassEntityName))
+ {
+ return this;
+ }
+ return factory.GetEntityPersister(subclassEntityName);
}
public virtual EntityMode? GuessEntityMode(object obj)
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameAndInheritance/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameAndInheritance/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameAndInheritance/Fixture.cs 2011-01-22 14:50:28 UTC (rev 5365)
@@ -0,0 +1,48 @@
+
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.EntityNameAndInheritance
+{
+ public class Fixture : BugTestCase
+ {
+ private int id;
+ private const string entityName = "SuperClass";
+
+ protected override void OnSetUp()
+ {
+ using (var s = OpenSession())
+ {
+ using (var tx = s.BeginTransaction())
+ {
+ id = (int)s.Save(entityName, new Hashtable());
+ tx.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void DoesNotCrash()
+ {
+ using (var s = OpenSession())
+ {
+ using (s.BeginTransaction())
+ {
+ Assert.IsNotNull(s.Get(entityName, id));
+ }
+ }
+ }
+
+ protected override void OnTearDown()
+ {
+ using (var s = OpenSession())
+ {
+ using (var tx = s.BeginTransaction())
+ {
+ s.CreateSQLQuery("delete from " + entityName).ExecuteUpdate();
+ tx.Commit();
+ }
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameAndInheritance/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameAndInheritance/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityNameAndInheritance/Mappings.hbm.xml 2011-01-22 14:50:28 UTC (rev 5365)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.EntityNameAndCompositeId"
+ assembly="NHibernate.Test">
+ <class entity-name="SuperClass">
+ <id name="Id" type="int">
+ <generator class="native"/>
+ </id>
+ <discriminator column="DISC" type="string" />
+ <subclass entity-name="Subclass" discriminator-value="B" />
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-01-22 13:50:30 UTC (rev 5364)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-01-22 14:50:28 UTC (rev 5365)
@@ -473,6 +473,7 @@
<Compile Include="NHSpecificTest\BagWithLazyExtraAndFilter\Domain.cs" />
<Compile Include="NHSpecificTest\BagWithLazyExtraAndFilter\Fixture.cs" />
<Compile Include="NHSpecificTest\EntityNameAndCompositeId\Fixture.cs" />
+ <Compile Include="NHSpecificTest\EntityNameAndInheritance\Fixture.cs" />
<Compile Include="NHSpecificTest\EntityNameWithFullName\Fixture.cs" />
<Compile Include="NHSpecificTest\Futures\LinqFutureFixture.cs" />
<Compile Include="NHSpecificTest\NH1136\Address.cs" />
@@ -2399,6 +2400,7 @@
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="NHSpecificTest\EntityNameAndInheritance\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2467\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2459\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2412\Mappings.hbm.xml" />
@@ -2777,7 +2779,6 @@
<EmbeddedResource Include="DynamicEntity\Tuplizer\Customer.hbm.xml" />
</ItemGroup>
<ItemGroup>
- <Folder Include="Cascade\Circle" />
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jul...@us...> - 2011-01-24 15:51:57
|
Revision: 5367
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5367&view=rev
Author: julian-maughan
Date: 2011-01-24 15:51:51 +0000 (Mon, 24 Jan 2011)
Log Message:
-----------
Changed SqlClientDriver to push out the parameter size to int.MaxValue/2147483647 if the IType is, 1) a BinaryType with internal SqlType Length greater than 8000, or 2) a BinaryBlobType. Blobs and Clobs are now handled similarly by the driver [ref. NH-2484]
Updated SqlClientDriverFixture dialect - so tests execute on MS SQL Server 2008.
Also performed some light refactoring of the driver: no functional changes, for readability.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs
trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs
trunk/nhibernate/src/NHibernate/Driver/SqlClientDriver.cs
trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlClientDriverFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2011-01-23 19:45:35 UTC (rev 5366)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2011-01-24 15:51:51 UTC (rev 5367)
@@ -5,6 +5,7 @@
using System.Text.RegularExpressions;
using NHibernate.Dialect.Function;
using NHibernate.Dialect.Schema;
+using NHibernate.Driver;
using NHibernate.Engine;
using NHibernate.Mapping;
using NHibernate.SqlCommand;
@@ -40,18 +41,16 @@
/// </remarks>
public class MsSql2000Dialect : Dialect
{
- public const int MaxSizeForLengthLimitedStrings = 4000;
- /// <summary></summary>
public MsSql2000Dialect()
{
RegisterColumnType(DbType.AnsiStringFixedLength, "CHAR(255)");
RegisterColumnType(DbType.AnsiStringFixedLength, 8000, "CHAR($l)");
RegisterColumnType(DbType.AnsiString, "VARCHAR(255)");
- RegisterColumnType(DbType.AnsiString, 8000, "VARCHAR($l)");
- RegisterColumnType(DbType.AnsiString, 2147483647, "TEXT");
+ RegisterColumnType(DbType.AnsiString, SqlClientDriver.MaxSizeForLengthLimitedAnsiString, "VARCHAR($l)");
+ RegisterColumnType(DbType.AnsiString, SqlClientDriver.MaxSizeForAnsiClob, "TEXT");
RegisterColumnType(DbType.Binary, "VARBINARY(8000)");
- RegisterColumnType(DbType.Binary, 8000, "VARBINARY($l)");
- RegisterColumnType(DbType.Binary, 2147483647, "IMAGE");
+ RegisterColumnType(DbType.Binary, SqlClientDriver.MaxSizeForLengthLimitedBinary, "VARBINARY($l)");
+ RegisterColumnType(DbType.Binary, SqlClientDriver.MaxSizeForBlob, "IMAGE");
RegisterColumnType(DbType.Boolean, "BIT");
RegisterColumnType(DbType.Byte, "TINYINT");
RegisterColumnType(DbType.Currency, "MONEY");
@@ -66,10 +65,10 @@
RegisterColumnType(DbType.Int64, "BIGINT");
RegisterColumnType(DbType.Single, "REAL"); //synonym for FLOAT(24)
RegisterColumnType(DbType.StringFixedLength, "NCHAR(255)");
- RegisterColumnType(DbType.StringFixedLength, MaxSizeForLengthLimitedStrings, "NCHAR($l)");
+ RegisterColumnType(DbType.StringFixedLength, SqlClientDriver.MaxSizeForLengthLimitedString, "NCHAR($l)");
RegisterColumnType(DbType.String, "NVARCHAR(255)");
- RegisterColumnType(DbType.String, MaxSizeForLengthLimitedStrings, "NVARCHAR($l)");
- RegisterColumnType(DbType.String, 1073741823, "NTEXT");
+ RegisterColumnType(DbType.String, SqlClientDriver.MaxSizeForLengthLimitedString, "NVARCHAR($l)");
+ RegisterColumnType(DbType.String, SqlClientDriver.MaxSizeForClob, "NTEXT");
RegisterColumnType(DbType.Time, "DATETIME");
RegisterFunction("count", new CountBigQueryFunction());
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2011-01-23 19:45:35 UTC (rev 5366)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2011-01-24 15:51:51 UTC (rev 5367)
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Data;
+using NHibernate.Driver;
using NHibernate.Mapping;
using NHibernate.SqlCommand;
using NHibernate.Util;
@@ -11,9 +12,9 @@
{
public MsSql2005Dialect()
{
- RegisterColumnType(DbType.String, 1073741823, "NVARCHAR(MAX)");
- RegisterColumnType(DbType.AnsiString, 2147483647, "VARCHAR(MAX)");
- RegisterColumnType(DbType.Binary, 2147483647, "VARBINARY(MAX)");
+ RegisterColumnType(DbType.String, SqlClientDriver.MaxSizeForClob, "NVARCHAR(MAX)");
+ RegisterColumnType(DbType.AnsiString, SqlClientDriver.MaxSizeForAnsiClob, "VARCHAR(MAX)");
+ RegisterColumnType(DbType.Binary, SqlClientDriver.MaxSizeForBlob, "VARBINARY(MAX)");
RegisterColumnType(DbType.Xml, "XML");
}
Modified: trunk/nhibernate/src/NHibernate/Driver/SqlClientDriver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/SqlClientDriver.cs 2011-01-23 19:45:35 UTC (rev 5366)
+++ trunk/nhibernate/src/NHibernate/Driver/SqlClientDriver.cs 2011-01-24 15:51:51 UTC (rev 5367)
@@ -12,8 +12,19 @@
/// </summary>
public class SqlClientDriver : DriverBase, IEmbeddedBatcherFactoryProvider
{
+ public const int MaxSizeForAnsiClob = 2147483647; // int.MaxValue
+ public const int MaxSizeForClob = 1073741823; // int.MaxValue / 2
+ public const int MaxSizeForBlob = 2147483647; // int.MaxValue
+ public const int MaxSizeForLengthLimitedAnsiString = 8000;
+ public const int MaxSizeForLengthLimitedString = 4000;
+ public const int MaxSizeForLengthLimitedBinary = 8000;
+ public const byte MaxPrecision = 28;
+ public const byte MaxScale = 5;
+ public const byte MaxDateTime2 = 8;
+ public const byte MaxDateTimeOffset = 10;
+
/// <summary>
- /// Creates an uninitialized <see cref="IDbConnection" /> object for
+ /// Creates an uninitialized <see cref="IDbConnection" /> object for
/// the SqlClientDriver.
/// </summary>
/// <value>An unitialized <see cref="System.Data.SqlClient.SqlConnection"/> object.</value>
@@ -23,7 +34,7 @@
}
/// <summary>
- /// Creates an uninitialized <see cref="IDbCommand" /> object for
+ /// Creates an uninitialized <see cref="IDbCommand" /> object for
/// the SqlClientDriver.
/// </summary>
/// <value>An unitialized <see cref="System.Data.SqlClient.SqlCommand"/> object.</value>
@@ -33,7 +44,7 @@
}
/// <summary>
- /// MsSql requires the use of a Named Prefix in the SQL statement.
+ /// MsSql requires the use of a Named Prefix in the SQL statement.
/// </summary>
/// <remarks>
/// <see langword="true" /> because MsSql uses "<c>@</c>".
@@ -44,7 +55,7 @@
}
/// <summary>
- /// MsSql requires the use of a Named Prefix in the Parameter.
+ /// MsSql requires the use of a Named Prefix in the Parameter.
/// </summary>
/// <remarks>
/// <see langword="true" /> because MsSql uses "<c>@</c>".
@@ -55,7 +66,7 @@
}
/// <summary>
- /// The Named Prefix for parameters.
+ /// The Named Prefix for parameters.
/// </summary>
/// <value>
/// Sql Server uses <c>"@"</c>.
@@ -71,8 +82,8 @@
/// </summary>
/// <value><see langword="false" /> - it is not supported.</value>
/// <remarks>
- /// MS SQL Server 2000 (and 7) throws an exception when multiple IDataReaders are
- /// attempted to be opened. When SQL Server 2005 comes out a new driver will be
+ /// MS SQL Server 2000 (and 7) throws an exception when multiple IDataReaders are
+ /// attempted to be opened. When SQL Server 2005 comes out a new driver will be
/// created for it because SQL Server 2005 is supposed to support it.
/// </remarks>
public override bool SupportsMultipleOpenReaders
@@ -80,6 +91,20 @@
get { return false; }
}
+ public override bool SupportsMultipleQueries
+ {
+ get { return true; }
+ }
+
+ public override IDbCommand GenerateCommand(CommandType type, SqlString sqlString, SqlType[] parameterTypes)
+ {
+ IDbCommand command = base.GenerateCommand(type, sqlString, parameterTypes);
+
+ SetParameterSizes(command.Parameters, parameterTypes);
+
+ return command;
+ }
+
// Used from SqlServerCeDriver as well
public static void SetParameterSizes(IDataParameterCollection parameters, SqlType[] parameterTypes)
{
@@ -89,34 +114,33 @@
}
}
- private const int MaxAnsiStringSize = 8000;
- private const int MaxBinarySize = MaxAnsiStringSize;
- private const int MaxStringSize = MaxAnsiStringSize / 2;
- private const int MaxBinaryBlobSize = int.MaxValue;
- private const int MaxStringClobSize = MaxBinaryBlobSize / 2;
- private const byte MaxPrecision = 28;
- private const byte MaxScale = 5;
- private const byte MaxDateTime2 = 8;
- private const byte MaxDateTimeOffset = 10;
+ private static void SetVariableLengthParameterSize(IDbDataParameter dbParam, SqlType sqlType)
+ {
+ SetDefaultParameterSize(dbParam, sqlType);
+ // Override the defaults using data from SqlType - except for LOB types
+ if (sqlType.LengthDefined && !IsText(dbParam, sqlType) && !IsBlob(dbParam, sqlType))
+ {
+ dbParam.Size = sqlType.Length;
+ }
+
+ if (sqlType.PrecisionDefined)
+ {
+ dbParam.Precision = sqlType.Precision;
+ dbParam.Scale = sqlType.Scale;
+ }
+ }
+
private static void SetDefaultParameterSize(IDbDataParameter dbParam, SqlType sqlType)
{
switch (dbParam.DbType)
{
case DbType.AnsiString:
case DbType.AnsiStringFixedLength:
- dbParam.Size = MaxAnsiStringSize;
+ dbParam.Size = MaxSizeForLengthLimitedAnsiString;
break;
-
case DbType.Binary:
- if (sqlType is BinaryBlobSqlType)
- {
- dbParam.Size = MaxBinaryBlobSize;
- }
- else
- {
- dbParam.Size = MaxBinarySize;
- }
+ dbParam.Size = IsBlob(dbParam, sqlType) ? MaxSizeForBlob : MaxSizeForLengthLimitedBinary;
break;
case DbType.Decimal:
dbParam.Precision = MaxPrecision;
@@ -124,7 +148,7 @@
break;
case DbType.String:
case DbType.StringFixedLength:
- dbParam.Size = IsText(dbParam, sqlType) ? MaxStringClobSize : MaxStringSize;
+ dbParam.Size = IsText(dbParam, sqlType) ? MaxSizeForClob : MaxSizeForLengthLimitedString;
break;
case DbType.DateTime2:
dbParam.Size = MaxDateTime2;
@@ -135,44 +159,28 @@
}
}
+ /// <summary>
+ /// Interprets if a parameter is a Clob (for the purposes of setting its default size)
+ /// </summary>
+ /// <param name="dbParam">The parameter</param>
+ /// <param name="sqlType">The <see cref="SqlType" /> of the parameter</param>
+ /// <returns>True, if the parameter should be interpreted as a Clob, otherwise False</returns>
private static bool IsText(IDbDataParameter dbParam, SqlType sqlType)
{
- return (sqlType is StringClobSqlType) || (sqlType.LengthDefined && sqlType.Length > MsSql2000Dialect.MaxSizeForLengthLimitedStrings &&
- (DbType.String == dbParam.DbType || DbType.StringFixedLength == dbParam.DbType));
+ return (sqlType is StringClobSqlType) || ((DbType.String == dbParam.DbType || DbType.StringFixedLength == dbParam.DbType) && sqlType.LengthDefined && (sqlType.Length > MaxSizeForLengthLimitedString));
}
-
- private static void SetVariableLengthParameterSize(IDbDataParameter dbParam, SqlType sqlType)
+
+ /// <summary>
+ /// Interprets if a parameter is a Blob (for the purposes of setting its default size)
+ /// </summary>
+ /// <param name="dbParam">The parameter</param>
+ /// <param name="sqlType">The <see cref="SqlType" /> of the parameter</param>
+ /// <returns>True, if the parameter should be interpreted as a Blob, otherwise False</returns>
+ private static bool IsBlob(IDbDataParameter dbParam, SqlType sqlType)
{
- SetDefaultParameterSize(dbParam, sqlType);
-
- // Override the defaults using data from SqlType.
- if (sqlType.LengthDefined && !IsText(dbParam, sqlType))
- {
- dbParam.Size = sqlType.Length;
- }
-
- if (sqlType.PrecisionDefined)
- {
- dbParam.Precision = sqlType.Precision;
- dbParam.Scale = sqlType.Scale;
- }
+ return (sqlType is BinaryBlobSqlType) || ((DbType.Binary == dbParam.DbType) && sqlType.LengthDefined && (sqlType.Length > MaxSizeForLengthLimitedBinary));
}
- public override IDbCommand GenerateCommand(CommandType type, SqlString sqlString, SqlType[] parameterTypes)
- {
- IDbCommand command = base.GenerateCommand(type, sqlString, parameterTypes);
- //if (IsPrepareSqlEnabled)
- {
- SetParameterSizes(command.Parameters, parameterTypes);
- }
- return command;
- }
-
- public override bool SupportsMultipleQueries
- {
- get { return true; }
- }
-
#region IEmbeddedBatcherFactoryProvider Members
System.Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass
@@ -182,4 +190,4 @@
#endregion
}
-}
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlClientDriverFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlClientDriverFixture.cs 2011-01-23 19:45:35 UTC (rev 5366)
+++ trunk/nhibernate/src/NHibernate.Test/DriverTest/SqlClientDriverFixture.cs 2011-01-24 15:51:51 UTC (rev 5367)
@@ -29,10 +29,6 @@
[TestFixture]
public class SqlClientDriverFixture : TestCase
{
- protected override void Configure(Configuration configuration)
- {
- configuration.SetProperty(Environment.PrepareSql, "true");
- }
protected override string MappingsAssembly
{
get { return "NHibernate.Test"; }
@@ -45,24 +41,28 @@
protected override bool AppliesTo(Dialect.Dialect dialect)
{
- return dialect is MsSql2000Dialect;
+ return dialect is MsSql2008Dialect;
}
[Test]
public void Crud()
{
- // Should use default dimension for CRUD op and prepare_sql='true' because the mapping does not
+ // Should use default dimension for CRUD op because the mapping does not
// have dimensions specified.
object savedId;
using (ISession s = OpenSession())
using (ITransaction t = s.BeginTransaction())
{
savedId = s.Save(new MultiTypeEntity
- {
- StringProp = "a", StringClob = "a",BinaryBlob = new byte[]{1,2,3},
- Binary = new byte[] { 4, 5, 6 }, Currency = 123.4m, Double = 123.5d,
- Decimal = 789.5m
- });
+ {
+ StringProp = "a",
+ StringClob = "a",
+ BinaryBlob = new byte[]{1,2,3},
+ Binary = new byte[] { 4, 5, 6 },
+ Currency = 123.4m,
+ Double = 123.5d,
+ Decimal = 789.5m
+ });
t.Commit();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|