|
From: <te...@us...> - 2009-07-09 11:32:27
|
Revision: 4595
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4595&view=rev
Author: tehlike
Date: 2009-07-09 11:32:22 +0000 (Thu, 09 Jul 2009)
Log Message:
-----------
Merging the fix for NH-1877
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/Projections.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Criterion/GroupedProjection.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Person.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Person.cs
Property Changed:
----------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Customer.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/
Copied: trunk/nhibernate/src/NHibernate/Criterion/GroupedProjection.cs (from rev 4594, branches/2.1.x/nhibernate/src/NHibernate/Criterion/GroupedProjection.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/GroupedProjection.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Criterion/GroupedProjection.cs 2009-07-09 11:32:22 UTC (rev 4595)
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NHibernate.Engine;
+using NHibernate.SqlCommand;
+using NHibernate.Type;
+using NHibernate.Util;
+
+namespace NHibernate.Criterion
+{
+ [Serializable]
+ public class GroupedProjection:IProjection
+ {
+ private readonly IProjection projection;
+
+ public GroupedProjection(IProjection projection)
+ {
+ this.projection = projection;
+ }
+
+ public virtual SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
+ {
+ return projection.ToSqlString(criteria, position, criteriaQuery, enabledFilters);
+ }
+
+ public virtual SqlString ToGroupSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
+ {
+ return StringHelper.RemoveAsAliasesFromSql(this.projection.ToSqlString(criteria, 0, criteriaQuery, enabledFilters));
+ }
+
+ public virtual IType[] GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery)
+ {
+ return projection.GetTypes(criteria, criteriaQuery);
+ }
+
+ public virtual IType[] GetTypes(String alias, ICriteria criteria, ICriteriaQuery criteriaQuery)
+ {
+ return this.projection.GetTypes(alias,criteria,criteriaQuery);
+ }
+
+ public virtual string[] GetColumnAliases(int loc)
+ {
+ return projection.GetColumnAliases(loc);
+ }
+
+ public virtual string[] GetColumnAliases(string alias, int loc)
+ {
+ return null;
+ }
+
+ public virtual string[] Aliases
+ {
+ get { return new string[] { }; }
+ }
+
+ public virtual bool IsGrouped
+ {
+ get { return true; }
+ }
+
+ public bool IsAggregate
+ {
+ get { return projection.IsAggregate; }
+ }
+
+ /// <summary>
+ /// Gets the typed values for parameters in this projection
+ /// </summary>
+ /// <param name="criteria">The criteria.</param>
+ /// <param name="criteriaQuery">The criteria query.</param>
+ /// <returns></returns>
+ public TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery criteriaQuery)
+ {
+ return projection.GetTypedValues(criteria, criteriaQuery);
+ }
+
+ public override string ToString()
+ {
+ return projection.ToString();
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate/Criterion/Projections.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/Projections.cs 2009-07-09 10:46:19 UTC (rev 4594)
+++ trunk/nhibernate/src/NHibernate/Criterion/Projections.cs 2009-07-09 11:32:22 UTC (rev 4595)
@@ -202,6 +202,16 @@
}
/// <summary>
+ /// A grouping projection value
+ /// </summary>
+ /// <param name="projection"></param>
+ /// <returns></returns>
+ public static GroupedProjection GroupProperty(IProjection projection)
+ {
+ return new GroupedProjection(projection);
+ }
+
+ /// <summary>
/// A projected property value
/// </summary>
/// <param name="propertyName"></param>
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-09 10:46:19 UTC (rev 4594)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-07-09 11:32:22 UTC (rev 4595)
@@ -485,6 +485,7 @@
<Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" />
<Compile Include="Cfg\MappingSchema\HbmVersion.cs" />
<Compile Include="Cfg\MappingSchema\IDecoratable.cs" />
+ <Compile Include="Criterion\GroupedProjection.cs" />
<Compile Include="Criterion\IPropertyProjection.cs" />
<Compile Include="Criterion\QueryOverJoinBuilder.cs" />
<Compile Include="Dialect\MsSql2008Dialect.cs" />
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Customer.cs
___________________________________________________________________
Modified: svn:mergeinfo
-
+ /branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Customer.cs:4593-4594
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs
___________________________________________________________________
Modified: svn:mergeinfo
-
+ /branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs:4593-4594
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Mappings.hbm.xml
___________________________________________________________________
Modified: svn:mergeinfo
-
+ /branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Mappings.hbm.xml:4593-4594
Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Fixture.cs
===================================================================
--- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Fixture.cs 2009-07-09 10:46:19 UTC (rev 4594)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Fixture.cs 2009-07-09 11:32:22 UTC (rev 4595)
@@ -1,63 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using NHibernate.Criterion;
-using NUnit.Framework;
-
-namespace NHibernate.Test.NHSpecificTest.NH1877
-{
- [TestFixture]
- public class Fixture : BugTestCase
- {
- protected override void OnSetUp()
- {
- using(var session=OpenSession())
- using(var tran=session.BeginTransaction())
- {
- session.Save(new Person {BirthDate = new DateTime(1988, 7, 21)});
- session.Save(new Person { BirthDate = new DateTime(1987, 7, 22) });
- session.Save(new Person { BirthDate = new DateTime(1986, 7, 23) });
- session.Save(new Person { BirthDate = new DateTime(1987, 7, 24) });
- session.Save(new Person { BirthDate = new DateTime(1988, 7, 25) });
- tran.Commit();
- }
- }
-
- protected override void OnTearDown()
- {
- using (var session = OpenSession())
- using (var tran = session.BeginTransaction())
- {
- session.CreateQuery("delete from Person").ExecuteUpdate();
- tran.Commit();
- }
- }
-
- [Test]
- public void CanGroupByWithPropertyName()
- {
- using(var session=OpenSession())
- {
- var crit = session.CreateCriteria(typeof (Person))
- .SetProjection(Projections.GroupProperty("BirthDate"),
- Projections.Count("Id"));
- var result = crit.List();
- Assert.That(result,Has.Count.EqualTo(5));
- }
- }
-
- [Test]
- public void CanGroupByWithSqlFunctionProjection()
- {
- using (var session = OpenSession())
- {
- var crit = session.CreateCriteria(typeof (Person))
- .SetProjection(
- Projections.GroupProperty(Projections.SqlFunction("month", NHibernateUtil.Int32, Projections.Property("BirthDate"))));
-
- var result = crit.UniqueResult();
- Assert.That(result,Is.EqualTo(7));
- }
- }
- }
-}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Fixture.cs (from rev 4594, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Fixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Fixture.cs 2009-07-09 11:32:22 UTC (rev 4595)
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NHibernate.Criterion;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1877
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ protected override void OnSetUp()
+ {
+ using(var session=OpenSession())
+ using(var tran=session.BeginTransaction())
+ {
+ session.Save(new Person {BirthDate = new DateTime(1988, 7, 21)});
+ session.Save(new Person { BirthDate = new DateTime(1987, 7, 22) });
+ session.Save(new Person { BirthDate = new DateTime(1986, 7, 23) });
+ session.Save(new Person { BirthDate = new DateTime(1987, 7, 24) });
+ session.Save(new Person { BirthDate = new DateTime(1988, 7, 25) });
+ tran.Commit();
+ }
+ }
+
+ protected override void OnTearDown()
+ {
+ using (var session = OpenSession())
+ using (var tran = session.BeginTransaction())
+ {
+ session.CreateQuery("delete from Person").ExecuteUpdate();
+ tran.Commit();
+ }
+ }
+
+ [Test]
+ public void CanGroupByWithPropertyName()
+ {
+ using(var session=OpenSession())
+ {
+ var crit = session.CreateCriteria(typeof (Person))
+ .SetProjection(Projections.GroupProperty("BirthDate"),
+ Projections.Count("Id"));
+ var result = crit.List();
+ Assert.That(result,Has.Count.EqualTo(5));
+ }
+ }
+
+ [Test]
+ public void CanGroupByWithSqlFunctionProjection()
+ {
+ using (var session = OpenSession())
+ {
+ var crit = session.CreateCriteria(typeof (Person))
+ .SetProjection(
+ Projections.GroupProperty(Projections.SqlFunction("month", NHibernateUtil.Int32, Projections.Property("BirthDate"))));
+
+ var result = crit.UniqueResult();
+ Assert.That(result,Is.EqualTo(7));
+ }
+ }
+ }
+}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Mappings.hbm.xml
===================================================================
--- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Mappings.hbm.xml 2009-07-09 10:46:19 UTC (rev 4594)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Mappings.hbm.xml 2009-07-09 11:32:22 UTC (rev 4595)
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
- namespace="NHibernate.Test.NHSpecificTest.NH1877"
- default-lazy="false">
-
- <class name="Person">
- <id name="Id">
- <generator class="hilo"/>
- </id>
- <property name="BirthDate"/>
-
- </class>
-</hibernate-mapping>
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Mappings.hbm.xml (from rev 4594, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Mappings.hbm.xml 2009-07-09 11:32:22 UTC (rev 4595)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1877"
+ default-lazy="false">
+
+ <class name="Person">
+ <id name="Id">
+ <generator class="hilo"/>
+ </id>
+ <property name="BirthDate"/>
+
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Person.cs
===================================================================
--- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Person.cs 2009-07-09 10:46:19 UTC (rev 4594)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Person.cs 2009-07-09 11:32:22 UTC (rev 4595)
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace NHibernate.Test.NHSpecificTest.NH1877
-{
- public class Person
- {
- public virtual long Id { get; set; }
- public virtual DateTime BirthDate { get; set; }
- }
-}
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Person.cs (from rev 4594, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Person.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Person.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1877/Person.cs 2009-07-09 11:32:22 UTC (rev 4595)
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1877
+{
+ public class Person
+ {
+ public virtual long Id { get; set; }
+ public virtual DateTime BirthDate { get; set; }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-09 10:46:19 UTC (rev 4594)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-09 11:32:22 UTC (rev 4595)
@@ -542,6 +542,8 @@
<Compile Include="NHSpecificTest\NH1867\AddMappingTest.cs" />
<Compile Include="NHSpecificTest\NH1868\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1868\Model.cs" />
+ <Compile Include="NHSpecificTest\NH1877\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1877\Person.cs" />
<Compile Include="NHSpecificTest\NH473\Child.cs" />
<Compile Include="NHSpecificTest\NH473\Fixture.cs" />
<Compile Include="NHSpecificTest\NH473\Parent.cs" />
@@ -1953,6 +1955,7 @@
<EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" />
<EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1877\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1868\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1857\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1859\Mappings.hbm.xml" />
Property changes on: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/2.1.x/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests:4507-4508,4510-4513,4537-4538
+ /branches/2.1.x/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests:4507-4508,4510-4513,4537-4538,4593-4594
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|