You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fab...@us...> - 2008-10-09 18:19:10
|
Revision: 3818 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3818&view=rev Author: fabiomaulo Date: 2008-10-09 18:19:03 +0000 (Thu, 09 Oct 2008) Log Message: ----------- Fix NH-727 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/SqlTest/IdentityInsertWithStoredProcsTest.cs trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLIdentityInsertWithStoredProcs.hbm.xml trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLIdentityInsertWithStoredProcsTest.cs Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2008-10-09 16:41:52 UTC (rev 3817) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2008-10-09 18:19:03 UTC (rev 3818) @@ -3300,10 +3300,10 @@ if (IsIdentifierAssignedByInsert) { identityDelegate = ((IPostInsertIdentifierGenerator)IdentifierGenerator).GetInsertGeneratedIdentifierDelegate(this, Factory, UseGetGeneratedKeys()); - SqlCommandInfo defaultInsert = GenerateInsertString(PropertyInsertability, 0); + SqlCommandInfo defaultInsert = GenerateIdentityInsertString(PropertyInsertability); sqlIdentityInsertString = customSQLInsert[0] != null ? new SqlCommandInfo(customSQLInsert[0], defaultInsert.ParameterTypes) - : GenerateIdentityInsertString(PropertyInsertability); + : defaultInsert; } else { Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-09 16:41:52 UTC (rev 3817) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-09 18:19:03 UTC (rev 3818) @@ -804,9 +804,11 @@ <Compile Include="SqlTest\FireBirdTest.cs" /> <Compile Include="SqlTest\GeneralTest.cs" /> <Compile Include="SqlTest\HandSQLTest.cs" /> + <Compile Include="SqlTest\IdentityInsertWithStoredProcsTest.cs" /> <Compile Include="SqlTest\Item.cs" /> <Compile Include="SqlTest\MonetaryAmount.cs" /> <Compile Include="SqlTest\MonetaryAmountUserType.cs" /> + <Compile Include="SqlTest\MSSQLIdentityInsertWithStoredProcsTest.cs" /> <Compile Include="SqlTest\MSSQLTest.cs" /> <Compile Include="SqlTest\NullDateUserType.cs" /> <Compile Include="SqlTest\Order.cs" /> @@ -1485,6 +1487,7 @@ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="SqlTest\MSSQLIdentityInsertWithStoredProcs.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1508\Mappings.hbm.xml" /> <EmbeddedResource Include="GenericTest\OrderedSetGeneric\OrderedSetFixture.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1293\Mappings.hbm.xml" /> Added: trunk/nhibernate/src/NHibernate.Test/SqlTest/IdentityInsertWithStoredProcsTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/SqlTest/IdentityInsertWithStoredProcsTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/SqlTest/IdentityInsertWithStoredProcsTest.cs 2008-10-09 18:19:03 UTC (rev 3818) @@ -0,0 +1,68 @@ +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.SqlTest +{ + public abstract class IdentityInsertWithStoredProcsTest : TestCase + { + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected abstract string GetExpectedInsertOrgLogStatement(string orgName); + + /// <summary> + /// Organization should be mappend with "identity" id strategy AND custom sql-insert (a stored proc). + /// The insert stored proc will return the new primary key and NH should recognize it and apply it + /// just like a normal insert. + /// </summary> + [Test] + public void InsertUsesStoredProc() + { + using (var spy = new SqlLogSpy()) + { + Organization ifa; + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + ifa = new Organization("IFA"); + s.Save(ifa); + t.Commit(); + } + + Assert.AreEqual(1, spy.Appender.GetEvents().Length, "Num loggedEvents"); + Assert.AreEqual(1, ifa.Id, "ifa.Id"); + Assert.AreEqual(GetExpectedInsertOrgLogStatement("IFA"), spy.Appender.GetEvents()[0].MessageObject, "Message 1"); + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Delete(ifa); + t.Commit(); + } + } + + using (var spy = new SqlLogSpy()) + { + Organization efa; + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + efa = new Organization("EFA"); + s.Save(efa); + t.Commit(); + } + + Assert.AreEqual(1, spy.Appender.GetEvents().Length, "Num loggedEvents"); + Assert.AreEqual(2, efa.Id, "efa.Id"); + Assert.AreEqual(GetExpectedInsertOrgLogStatement("EFA"), spy.Appender.GetEvents()[0].MessageObject, "Message 2"); + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Delete(efa); + t.Commit(); + } + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLIdentityInsertWithStoredProcs.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLIdentityInsertWithStoredProcs.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLIdentityInsertWithStoredProcs.hbm.xml 2008-10-09 18:19:03 UTC (rev 3818) @@ -0,0 +1,201 @@ +<?xml version="1.0"?> +<!-- + + This mapping demonstrates the use of Hibernate with + all-handwritten SQL! + + This version is for Sybase/mssql +--> +<hibernate-mapping + xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.SqlTest" + default-access="field.camelcase"> + + <class name="Organization" table="ORGANIZATION"> + <id name="Id" unsaved-value="0" column="ORGID"> + <generator class="identity"/> + </id> + <property name="Name" not-null="true" column="NAME"/> + <set name="Employments" + inverse="true" + order-by="DUMMY"> + <key column="EMPLOYER"/> + <!-- only needed for DDL generation --> + <one-to-many class="Employment"/> + <loader query-ref="organizationEmployments"/> + </set> + <!-- query-list name="currentEmployments" + query-ref="organizationCurrentEmployments"--> + <loader query-ref="organization"/> + <sql-insert>exec nh_organization_native_id_insert ?</sql-insert> + <sql-update>UPDATE ORGANIZATION SET NAME=UPPER(?) WHERE ORGID=?</sql-update> + <sql-delete>DELETE FROM ORGANIZATION WHERE ORGID=?</sql-delete> + </class> + + <class name="Person" table="PERSON"> + <id name="Id" unsaved-value="0" column="PERID"> + <generator class="increment"/> + </id> + <property name="Name" not-null="true" column="NAME"/> + <loader query-ref="person"/> + <sql-insert>INSERT INTO PERSON (NAME, PERID) VALUES ( UPPER(?), ? )</sql-insert> + <sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE PERID=?</sql-update> + <sql-delete>DELETE FROM PERSON WHERE PERID=?</sql-delete> + </class> + + <class name="Employment" table="EMPLOYMENT"> + <id name="employmentId" unsaved-value="0" column="EMPID"> + <generator class="increment"/> + </id> + <many-to-one name="Employee" column="EMPLOYEE" not-null="true" update="false"/> + <many-to-one name="Employer" column="EMPLOYER" not-null="true" update="false"/> + <property name="StartDate" column="STARTDATE" not-null="true" update="false" insert="false"/> + <property name="EndDate" column="ENDDATE" insert="false" type="NHibernate.Test.SqlTest.NullDateUserType, NHibernate.Test"/> + <property name="RegionCode" column="REGIONCODE" update="false"/> + <property name="Salary" type="NHibernate.Test.SqlTest.MonetaryAmountUserType, NHibernate.Test"> + <column name="VALUE" sql-type="float"/> + <column name="CURRENCY"/> + </property> + <loader query-ref="employment"/> + <sql-insert> + INSERT INTO EMPLOYMENT + (EMPLOYEE, EMPLOYER, STARTDATE, REGIONCODE, VALUE, CURRENCY, EMPID) + VALUES (?, ?, getdate(), UPPER(?), ?, ?, ?) + </sql-insert> + <sql-update>UPDATE EMPLOYMENT SET ENDDATE=?, VALUE=?, CURRENCY=? WHERE EMPID=?</sql-update> + <sql-delete>DELETE FROM EMPLOYMENT WHERE EMPID=?</sql-delete> + </class> + + <resultset name="org-emp-regionCode"> + <return-scalar column="regionCode" type="string"/> + <return alias="org" class="Organization"/> + <return-join alias="emp" property="org.Employments"/> + </resultset> + + <resultset name="org-emp-person"> + <return alias="org" class="Organization"/> + <return-join alias="emp" property="org.Employments"/> + <return-join alias="pers" property="emp.Employee"/> + </resultset> + + <sql-query name="person"> + <return alias="p" class="Person" lock-mode="upgrade"/> + SELECT NAME AS {p.Name}, PERID AS {p.Id} FROM PERSON WHERE PERID=? /*FOR UPDATE*/ + </sql-query> + + <sql-query name="organization"> + <return alias="org" class="Organization"/> + <return-join alias="emp" property="org.Employments"/> + SELECT {org.*}, {emp.*} + FROM ORGANIZATION org + LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID = emp.EMPLOYER + WHERE org.ORGID=? + </sql-query> + + + <!--sql-query name="organization"> + <return alias="org" class="Organization"/> + SELECT NAME AS {org.name}, ORGID AS {org.id} FROM ORGANIZATION + WHERE ORGID=? + </sql-query--> + + <sql-query name="allOrganizationsWithEmployees" flush-mode="never"> + <return alias="org" class="Organization"/> + SELECT DISTINCT org.NAME AS {org.Name}, org.ORGID AS {org.Id} + FROM ORGANIZATION org + INNER JOIN EMPLOYMENT e ON e.EMPLOYER = org.ORGID + </sql-query> + + <sql-query name="employment"> + <return alias="emp" class="Employment"/> + SELECT EMPLOYEE AS {emp.Employee}, EMPLOYER AS {emp.Employer}, + STARTDATE AS {emp.StartDate}, ENDDATE AS {emp.EndDate}, + REGIONCODE as {emp.RegionCode}, EMPID AS {emp.Id} + FROM EMPLOYMENT + WHERE EMPID = ? + </sql-query> + + <sql-query name="organizationEmployments"> + <load-collection alias="empcol" role="Organization.Employments"/> + SELECT {empcol.*} + FROM EMPLOYMENT empcol + WHERE EMPLOYER = :id + ORDER BY STARTDATE ASC, EMPLOYEE ASC + </sql-query> + + + <sql-query name="organizationCurrentEmployments"> + <return alias="emp" class="Employment"> + <return-property name="Salary"> + <!-- as multi column properties are not supported via the + {}-syntax, we need to provide an explicit column list for salary via <return-property> --> + <return-column name="VALUE"/> + <return-column name="CURRENCY"/> + </return-property> + <!-- Here we are remapping endDate. Notice that we can still use {emp.EndDate} in the SQL. --> + <return-property name="EndDate" column="myEndDate"/> + </return> + <synchronize table="EMPLOYMENT"/> + SELECT EMPLOYEE AS {emp.Employee}, EMPLOYER AS {emp.Employer}, + STARTDATE AS {emp.StartDate}, ENDDATE AS {emp.EndDate}, + REGIONCODE as {emp.RegionCode}, EMPID AS {emp.Id}, VALUE, CURRENCY + FROM EMPLOYMENT + WHERE EMPLOYER = :id AND ENDDATE IS NULL + ORDER BY STARTDATE ASC + </sql-query> + + <sql-query name="simpleScalar"> + <return-scalar column="name" type="string"/> + <return-scalar column="value" type="long"/> + exec simpleScalar :number + </sql-query> + + <sql-query name="paramhandling"> + <return-scalar column="value" type="long"/> + <return-scalar column="value2" type="long"/> + exec paramHandling ?, ? + </sql-query> + + <sql-query name="paramhandling_mixed"> + <return-scalar column="value" type="long" /> + <return-scalar column="value2" type="long" /> + exec paramHandling ?, :second + </sql-query> + + <sql-query name="selectAllEmployments"> + <return class="Employment"> + <return-property name="Employee" column="EMPLOYEE"/> + <return-property name="Employer" column="EMPLOYER"/> + <return-property name="StartDate" column="STARTDATE"/> + <return-property name="EndDate" column="ENDDATE"/> + <return-property name="RegionCode" column="REGIONCODE"/> + <return-property name="id" column="EMPID"/> + <return-property name="Salary"> + <!-- as multi column properties are not supported via the + {}-syntax, we need to provide an explicit column list for salary via <return-property> --> + <return-column name="VALUE"/> + <return-column name="CURRENCY"/> + </return-property> + </return> + exec selectAllEmployments + </sql-query> + + <database-object> + <create> + CREATE PROCEDURE nh_organization_native_id_insert + ( + @NAME as varchar + ) + AS + BEGIN + INSERT INTO organization(NAME) VALUES(@NAME) + SELECT SCOPE_IDENTITY() + END + </create> + <drop> + IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'dbo.nh_organization_native_id_insert') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) + DROP PROCEDURE dbo.nh_organization_native_id_insert + </drop> + </database-object> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLIdentityInsertWithStoredProcsTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLIdentityInsertWithStoredProcsTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLIdentityInsertWithStoredProcsTest.cs 2008-10-09 18:19:03 UTC (rev 3818) @@ -0,0 +1,25 @@ +using System.Collections; +using NHibernate.Dialect; +using NUnit.Framework; + +namespace NHibernate.Test.SqlTest +{ + [TestFixture] + public class MSSQLIdentityInsertWithStoredProcsTest : IdentityInsertWithStoredProcsTest + { + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect is MsSql2000Dialect || dialect is MsSql2005Dialect; + } + + protected override string GetExpectedInsertOrgLogStatement(string orgName) + { + return string.Format("exec nh_organization_native_id_insert @p0; @p0 = '{0}'", orgName); + } + + protected override IList Mappings + { + get { return new[] {"SqlTest.MSSQLIdentityInsertWithStoredProcs.hbm.xml"}; } + } + } +} \ 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...> - 2008-10-09 16:41:58
|
Revision: 3817 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3817&view=rev Author: fabiomaulo Date: 2008-10-09 16:41:52 +0000 (Thu, 09 Oct 2008) Log Message: ----------- Fix NH-1493 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/Properties/PropertyAccessorFactory.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Properties/BackFieldStrategy.cs trunk/nhibernate/src/NHibernate.Test/PropertyTest/BackFieldAccessorFixture.cs Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-10-08 15:16:52 UTC (rev 3816) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-10-09 16:41:52 UTC (rev 3817) @@ -450,6 +450,7 @@ <Compile Include="AdoNet\ResultSetWrapper.cs" /> <Compile Include="AdoNet\SqlClientBatchingBatcherFactory.cs" /> <Compile Include="AdoNet\TooManyRowsAffectedException.cs" /> + <Compile Include="Properties\BackFieldStrategy.cs" /> <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> <Compile Include="Bytecode\DefaultProxyFactoryFactory.cs" /> <Compile Include="Bytecode\IAccessOptimizer.cs" /> Added: trunk/nhibernate/src/NHibernate/Properties/BackFieldStrategy.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Properties/BackFieldStrategy.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Properties/BackFieldStrategy.cs 2008-10-09 16:41:52 UTC (rev 3817) @@ -0,0 +1,14 @@ +namespace NHibernate.Properties +{ + public class BackFieldStrategy : IFieldNamingStrategy + { + #region Implementation of IFieldNamingStrategy + + public string GetFieldName(string propertyName) + { + return string.Concat("<",propertyName.Trim(),">k__BackingField"); + } + + #endregion + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate/Properties/BackFieldStrategy.cs ___________________________________________________________________ Added: svn:mergeinfo + Modified: trunk/nhibernate/src/NHibernate/Properties/PropertyAccessorFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Properties/PropertyAccessorFactory.cs 2008-10-08 15:16:52 UTC (rev 3816) +++ trunk/nhibernate/src/NHibernate/Properties/PropertyAccessorFactory.cs 2008-10-09 16:41:52 UTC (rev 3817) @@ -20,6 +20,7 @@ accessors = new Dictionary<string, IPropertyAccessor>(19); accessors["property"] = new BasicPropertyAccessor(); accessors["field"] = new FieldAccessor(); + accessors["backfield"] = new FieldAccessor(new BackFieldStrategy()); accessors["field.camelcase"] = new FieldAccessor(new CamelCaseStrategy()); accessors["field.camelcase-underscore"] = new FieldAccessor(new CamelCaseUnderscoreStrategy()); accessors["field.lowercase"] = new FieldAccessor(new LowerCaseStrategy()); Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-08 15:16:52 UTC (rev 3816) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-09 16:41:52 UTC (rev 3817) @@ -747,6 +747,7 @@ <Compile Include="PropertyRef\A.cs" /> <Compile Include="PropertyRef\B.cs" /> <Compile Include="PropertyRef\KeyPropertyRefFixture.cs" /> + <Compile Include="PropertyTest\BackFieldAccessorFixture.cs" /> <Compile Include="PropertyTest\BasicSetterExceptionFixture.cs" /> <Compile Include="PropertyTest\FieldAccessorFixture.cs" /> <Compile Include="PropertyTest\FieldCamelCaseFixture.cs" /> Added: trunk/nhibernate/src/NHibernate.Test/PropertyTest/BackFieldAccessorFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/PropertyTest/BackFieldAccessorFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/PropertyTest/BackFieldAccessorFixture.cs 2008-10-09 16:41:52 UTC (rev 3817) @@ -0,0 +1,57 @@ +using NHibernate.Properties; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; + +namespace NHibernate.Test.PropertyTest +{ + [TestFixture] + public class BackFieldAccessorFixture + { + [Test] + public void GetValue() + { + var accessor = PropertyAccessorFactory.GetPropertyAccessor("backfield"); + var getter = accessor.GetGetter(typeof(MyAutoProp), "AutoProp"); + var rogetter = accessor.GetGetter(typeof(MyAutoProp), "ReadOnlyAutoProp"); + + Assert.That(getter.Get(new MyAutoProp { AutoProp = -1 }), Is.EqualTo(-1)); + Assert.That(getter.Get(new MyAutoProp { AutoProp = 1 }), Is.EqualTo(1)); + + Assert.That(rogetter.Get(new MyAutoProp()), Is.EqualTo(0)); + Assert.That(rogetter.Get(new MyAutoProp(5)), Is.EqualTo(5)); + } + + [Test] + public void SetValue() + { + var accessor = PropertyAccessorFactory.GetPropertyAccessor("backfield"); + var getter = accessor.GetGetter(typeof(MyAutoProp), "AutoProp"); + var setter = accessor.GetSetter(typeof(MyAutoProp), "AutoProp"); + + var rogetter = accessor.GetGetter(typeof(MyAutoProp), "ReadOnlyAutoProp"); + var rosetter = accessor.GetSetter(typeof(MyAutoProp), "ReadOnlyAutoProp"); + + var i = new MyAutoProp { AutoProp = -1 }; + Assert.That(getter.Get(i), Is.EqualTo(-1)); + setter.Set(i, 5); + Assert.That(getter.Get(i), Is.EqualTo(5)); + + Assert.That(rogetter.Get(new MyAutoProp()), Is.EqualTo(0)); + rosetter.Set(i, 123); + Assert.That(rogetter.Get(i), Is.EqualTo(123)); + } + } + + public class MyAutoProp + { + public MyAutoProp() {} + + public MyAutoProp(int readOnlyAutoProp) + { + ReadOnlyAutoProp = readOnlyAutoProp; + } + + public int AutoProp { get; set; } + public int ReadOnlyAutoProp { get; private set; } + } +} \ 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: Marchiano U. <imb...@tu...> - 2008-10-09 09:31:55
|
Neew llife! http://cid-56f1f4028e4aa039.spaces.live.com/blog/cns!56F1F4028E4AA039!107.entry Which give the name significance for a few, and the great principle be declared to 'me as to how, devoured their food, for the little place had his zeal for the foundation and glory of islam. E. Sewell, another bostonian and a lawyer who. |
From: <fab...@us...> - 2008-10-08 15:17:06
|
Revision: 3816 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3816&view=rev Author: fabiomaulo Date: 2008-10-08 15:16:52 +0000 (Wed, 08 Oct 2008) Log Message: ----------- Log info per Operation Threshold in statistics (from H3.2.6) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs trunk/nhibernate/src/NHibernate/Engine/Loading/CollectionLoadContext.cs trunk/nhibernate/src/NHibernate/Engine/TwoPhaseLoad.cs trunk/nhibernate/src/NHibernate/Event/Default/DefaultInitializeCollectionEventListener.cs trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs trunk/nhibernate/src/NHibernate/Stat/IStatistics.cs trunk/nhibernate/src/NHibernate/Stat/IStatisticsImplementor.cs trunk/nhibernate/src/NHibernate/Stat/QueryStatistics.cs trunk/nhibernate/src/NHibernate/Stat/StatisticsImpl.cs trunk/nhibernate/src/NHibernate.Test/Stats/StatsFixture.cs Modified: trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Action/CollectionRecreateAction.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using NHibernate.Collection; using NHibernate.Engine; using NHibernate.Event; @@ -13,8 +14,18 @@ : base(persister, collection, key, session) { } /// <summary> Execute this action</summary> + /// <remarks> + /// This method is called when a new non-null collection is persisted + /// or when an existing (non-null) collection is moved to a new owner + /// </remarks> public override void Execute() { + bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled; + var stopWath = new Stopwatch(); + if (statsEnabled) + { + stopWath.Start(); + } IPersistentCollection collection = Collection; PreRecreate(); @@ -26,10 +37,10 @@ Evict(); PostRecreate(); - - if (Session.Factory.Statistics.IsStatisticsEnabled) + if (statsEnabled) { - Session.Factory.StatisticsImplementor.RecreateCollection(Persister.Role); + stopWath.Stop(); + Session.Factory.StatisticsImplementor.RecreateCollection(Persister.Role, stopWath.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Action/CollectionRemoveAction.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using NHibernate.Collection; using NHibernate.Engine; using NHibernate.Event; @@ -56,6 +57,13 @@ public override void Execute() { + bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled; + var stopWath = new Stopwatch(); + if (statsEnabled) + { + stopWath.Start(); + } + PreRemove(); if (!emptySnapshot) @@ -73,9 +81,10 @@ PostRemove(); - if (Session.Factory.Statistics.IsStatisticsEnabled) + if (statsEnabled) { - Session.Factory.StatisticsImplementor.RemoveCollection(Persister.Role); + stopWath.Stop(); + Session.Factory.StatisticsImplementor.RemoveCollection(Persister.Role, stopWath.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Action/CollectionUpdateAction.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using NHibernate.Cache; using NHibernate.Cache.Entry; using NHibernate.Collection; @@ -29,6 +30,13 @@ IPersistentCollection collection = Collection; bool affectedByFilters = persister.IsAffectedByEnabledFilters(session); + bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled; + var stopWath = new Stopwatch(); + if (statsEnabled) + { + stopWath.Start(); + } + PreUpdate(); if (!collection.WasInitialized) @@ -72,9 +80,10 @@ PostUpdate(); - if (Session.Factory.Statistics.IsStatisticsEnabled) + if (statsEnabled) { - Session.Factory.StatisticsImplementor.UpdateCollection(Persister.Role); + stopWath.Stop(); + Session.Factory.StatisticsImplementor.UpdateCollection(Persister.Role, stopWath.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Action/EntityDeleteAction.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using NHibernate.Cache; using NHibernate.Engine; using NHibernate.Event; @@ -34,6 +35,13 @@ ISessionImplementor session = Session; object instance = Instance; + bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled; + var stopWath = new Stopwatch(); + if (statsEnabled) + { + stopWath.Start(); + } + bool veto = PreDelete(); object tmpVersion = version; @@ -83,9 +91,10 @@ PostDelete(); - if (Session.Factory.Statistics.IsStatisticsEnabled && !veto) + if (statsEnabled && !veto) { - Session.Factory.StatisticsImplementor.DeleteEntity(Persister.EntityName); + stopWath.Stop(); + Session.Factory.StatisticsImplementor.DeleteEntity(Persister.EntityName, stopWath.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Action/EntityIdentityInsertAction.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using NHibernate.Engine; using NHibernate.Event; using NHibernate.Persister.Entity; @@ -57,6 +58,13 @@ IEntityPersister persister = Persister; object instance = Instance; + bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled; + var stopWath = new Stopwatch(); + if (statsEnabled) + { + stopWath.Start(); + } + bool veto = PreInsert(); // Don't need to lock the cache here, since if someone @@ -84,9 +92,10 @@ }*/ PostInsert(); - if (Session.Factory.Statistics.IsStatisticsEnabled && !veto) + if (statsEnabled && !veto) { - Session.Factory.StatisticsImplementor.InsertEntity(Persister.EntityName); + stopWath.Stop(); + Session.Factory.StatisticsImplementor.InsertEntity(Persister.EntityName, stopWath.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Action/EntityInsertAction.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using NHibernate.Cache; using NHibernate.Cache.Entry; using NHibernate.Engine; @@ -41,6 +42,13 @@ object instance = Instance; object id = Id; + bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled; + var stopWath = new Stopwatch(); + if (statsEnabled) + { + stopWath.Start(); + } + bool veto = PreInsert(); // Don't need to lock the cache here, since if someone @@ -87,9 +95,10 @@ PostInsert(); - if (factory.Statistics.IsStatisticsEnabled && !veto) + if (statsEnabled && !veto) { - factory.StatisticsImplementor.InsertEntity(Persister.EntityName); + stopWath.Stop(); + factory.StatisticsImplementor.InsertEntity(Persister.EntityName, stopWath.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Action/EntityUpdateAction.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using NHibernate.Cache; using NHibernate.Cache.Entry; using NHibernate.Engine; @@ -46,6 +47,13 @@ IEntityPersister persister = Persister; object instance = Instance; + bool statsEnabled = Session.Factory.Statistics.IsStatisticsEnabled; + var stopWath = new Stopwatch(); + if (statsEnabled) + { + stopWath.Start(); + } + bool veto = PreUpdate(); ISessionFactoryImplementor factory = Session.Factory; @@ -119,9 +127,10 @@ PostUpdate(); - if (factory.Statistics.IsStatisticsEnabled && !veto) + if (statsEnabled && !veto) { - factory.StatisticsImplementor.UpdateEntity(Persister.EntityName); + stopWath.Stop(); + factory.StatisticsImplementor.UpdateEntity(Persister.EntityName, stopWath.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Engine/Loading/CollectionLoadContext.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Loading/CollectionLoadContext.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Engine/Loading/CollectionLoadContext.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Diagnostics; using Iesi.Collections.Generic; using log4net; using NHibernate.Cache; @@ -238,6 +239,13 @@ ISessionImplementor session = LoadContext.PersistenceContext.Session; EntityMode em = session.EntityMode; + bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled; + var stopWath = new Stopwatch(); + if (statsEnabled) + { + stopWath.Start(); + } + bool hasNoQueuedAdds = lce.Collection.EndRead(persister); // warning: can cause a recursive calls! (proxy initialization) if (persister.CollectionType.HasHolder(em)) @@ -268,9 +276,10 @@ log.Debug("collection fully initialized: " + MessageHelper.InfoString(persister, lce.Key, session.Factory)); } - if (session.Factory.Statistics.IsStatisticsEnabled) + if (statsEnabled) { - session.Factory.StatisticsImplementor.LoadCollection(persister.Role); + stopWath.Stop(); + session.Factory.StatisticsImplementor.LoadCollection(persister.Role, stopWath.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Engine/TwoPhaseLoad.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/TwoPhaseLoad.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Engine/TwoPhaseLoad.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,3 +1,4 @@ +using System.Diagnostics; using log4net; using NHibernate.Cache; using NHibernate.Cache.Entry; @@ -47,6 +48,14 @@ public static void InitializeEntity(object entity, bool readOnly, ISessionImplementor session, PreLoadEvent preLoadEvent, PostLoadEvent postLoadEvent) { //TODO: Should this be an InitializeEntityEventListener??? (watch out for performance!) + + bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled; + var stopWath = new Stopwatch(); + if (statsEnabled) + { + stopWath.Start(); + } + IPersistenceContext persistenceContext = session.PersistenceContext; EntityEntry entityEntry = persistenceContext.GetEntry(entity); if (entityEntry == null) @@ -140,9 +149,10 @@ if (log.IsDebugEnabled) log.Debug("done materializing entity " + MessageHelper.InfoString(persister, id, session.Factory)); - if (factory.Statistics.IsStatisticsEnabled) + if (statsEnabled) { - factory.StatisticsImplementor.LoadEntity(persister.EntityName); + stopWath.Stop(); + factory.StatisticsImplementor.LoadEntity(persister.EntityName, stopWath.Elapsed); } } Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultInitializeCollectionEventListener.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/Default/DefaultInitializeCollectionEventListener.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultInitializeCollectionEventListener.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using log4net; using NHibernate.Cache; using NHibernate.Cache.Entry; @@ -20,6 +21,13 @@ IPersistentCollection collection = @event.Collection; ISessionImplementor source = @event.Session; + bool statsEnabled = source.Factory.Statistics.IsStatisticsEnabled; + var stopWath = new Stopwatch(); + if (statsEnabled) + { + stopWath.Start(); + } + CollectionEntry ce = source.PersistenceContext.GetCollectionEntry(collection); if (ce == null) throw new HibernateException("collection was evicted"); @@ -43,9 +51,10 @@ ce.LoadedPersister.Initialize(ce.LoadedKey, source); log.Debug("collection initialized"); - if (source.Factory.Statistics.IsStatisticsEnabled) + if (statsEnabled) { - source.Factory.StatisticsImplementor.FetchCollection(ce.LoadedPersister.Role); + stopWath.Stop(); + source.Factory.StatisticsImplementor.FetchCollection(ce.LoadedPersister.Role, stopWath.Elapsed); } } } Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using log4net; using NHibernate.Cache; using NHibernate.Cache.Entry; @@ -328,11 +329,20 @@ protected virtual object LoadFromDatasource(LoadEvent @event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) { ISessionImplementor source = @event.Session; + + bool statsEnabled = source.Factory.Statistics.IsStatisticsEnabled; + var stopWath = new Stopwatch(); + if (statsEnabled) + { + stopWath.Start(); + } + object entity = persister.Load(@event.EntityId, @event.InstanceToLoad, @event.LockMode, source); - if (@event.IsAssociationFetch && source.Factory.Statistics.IsStatisticsEnabled) + if (@event.IsAssociationFetch && statsEnabled) { - source.Factory.StatisticsImplementor.FetchEntity(@event.EntityClassName); + stopWath.Stop(); + source.Factory.StatisticsImplementor.FetchEntity(@event.EntityClassName, stopWath.Elapsed); } return entity; Modified: trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Hql/Classic/QueryTranslator.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Data; +using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; @@ -1288,11 +1289,14 @@ public IEnumerable GetEnumerable(QueryParameters parameters, ISessionImplementor session) { - bool stats = session.Factory.Statistics.IsStatisticsEnabled; - long startTime = 0; - if (stats) - startTime = DateTime.Now.Ticks; + bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled; + var stopWath = new Stopwatch(); + if (statsEnabled) + { + stopWath.Start(); + } + IDbCommand cmd = PrepareQueryCommand(parameters, false, session); // This IDataReader is disposed of in EnumerableImpl.Dispose @@ -1301,12 +1305,13 @@ HolderInstantiator.CreateClassicHolderInstantiator(holderConstructor, parameters.ResultTransformer); IEnumerable result = new EnumerableImpl(rs, cmd, session, ReturnTypes, ScalarColumnNames, parameters.RowSelection, hi); - if (stats) + if (statsEnabled) { - session.Factory.StatisticsImplementor.QueryExecuted("HQL: " + queryString, 0, (DateTime.Now.Ticks - startTime)); + stopWath.Stop(); + session.Factory.StatisticsImplementor.QueryExecuted("HQL: " + queryString, 0, stopWath.Elapsed); // NH: Different behavior (H3.2 use QueryLoader in AST parser) we need statistic for orginal query too. // probably we have a bug some where else for statistic RowCount - session.Factory.StatisticsImplementor.QueryExecuted(QueryIdentifier, 0, (DateTime.Now.Ticks - startTime)); + session.Factory.StatisticsImplementor.QueryExecuted(QueryIdentifier, 0, stopWath.Elapsed); } return result; } Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Data; +using System.Diagnostics; using System.Runtime.CompilerServices; using Iesi.Collections; using Iesi.Collections.Generic; @@ -1686,11 +1687,11 @@ /// <returns></returns> protected IList DoList(ISessionImplementor session, QueryParameters queryParameters) { - bool stats = Factory.Statistics.IsStatisticsEnabled; - long startTime = 0; - if (stats) + bool statsEnabled = Factory.Statistics.IsStatisticsEnabled; + var stopWath = new Stopwatch(); + if (statsEnabled) { - startTime = DateTime.Now.Ticks; + stopWath.Start(); } IList result; @@ -1708,9 +1709,10 @@ throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, sqle, "could not execute query", SqlString, queryParameters.PositionalParameterValues, queryParameters.NamedParameters); } - if (stats) + if (statsEnabled) { - Factory.StatisticsImplementor.QueryExecuted(QueryIdentifier, result.Count, (DateTime.Now.Ticks - startTime)); + stopWath.Stop(); + Factory.StatisticsImplementor.QueryExecuted(QueryIdentifier, result.Count, stopWath.Elapsed); } return result; } Modified: trunk/nhibernate/src/NHibernate/Stat/IStatistics.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Stat/IStatistics.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Stat/IStatistics.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,12 +1,11 @@ using System; +using System.Diagnostics; namespace NHibernate.Stat { /// <summary> - /// Statistics for a particular <tt>SessionFactory</tt>. - /// Beware of milliseconds metrics, they are dependent of the JVM precision: - /// you may then encounter a 10 ms approximation depending on your OS platform. - /// Please refer to the JVM documentation for more information. + /// Statistics for a particular <see cref="ISessionFactory"/>. + /// Beware of metrics, they are dependent of the <see cref="Stopwatch"/> precision: /// </summary> public interface IStatistics { @@ -28,8 +27,8 @@ /// <summary> Global number of executed queries</summary> long QueryExecutionCount { get;} - /// <summary> The time in milliseconds of the slowest query.</summary> - long QueryExecutionMaxTime { get;} + /// <summary> The <see cref="TimeSpan"/> of the slowest query.</summary> + TimeSpan QueryExecutionMaxTime { get; } /// <summary> The query string for the slowest query.</summary> string QueryExecutionMaxTimeQueryString { get;} @@ -141,5 +140,11 @@ /// <summary> log in info level the main statistics</summary> void LogSummary(); + + /// <summary> + /// The OperationThreshold to a value greater than <see cref="TimeSpan.MinValue"/> to enable logging of long running operations. + /// </summary> + /// <remarks>Operations that exceed the level will be logged.</remarks> + TimeSpan OperationThreshold { get; set; } } } Modified: trunk/nhibernate/src/NHibernate/Stat/IStatisticsImplementor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Stat/IStatisticsImplementor.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Stat/IStatisticsImplementor.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,3 +1,4 @@ +using System; namespace NHibernate.Stat { /// <summary> Statistics SPI for the NHibernate core </summary> @@ -7,20 +8,20 @@ void CloseSession(); void Flush(); void Connect(); - void LoadEntity(string entityName); - void FetchEntity(string entityName); - void UpdateEntity(string entityName); - void InsertEntity(string entityName); - void DeleteEntity(string entityName); - void LoadCollection(string role); - void FetchCollection(string role); - void UpdateCollection(string role); - void RecreateCollection(string role); - void RemoveCollection(string role); + void LoadEntity(string entityName, TimeSpan time); + void FetchEntity(string entityName, TimeSpan time); + void UpdateEntity(string entityName, TimeSpan time); + void InsertEntity(string entityName, TimeSpan time); + void DeleteEntity(string entityName, TimeSpan time); + void LoadCollection(string role, TimeSpan time); + void FetchCollection(string role, TimeSpan time); + void UpdateCollection(string role, TimeSpan time); + void RecreateCollection(string role, TimeSpan time); + void RemoveCollection(string role, TimeSpan time); void SecondLevelCachePut(string regionName); void SecondLevelCacheHit(string regionName); void SecondLevelCacheMiss(string regionName); - void QueryExecuted(string hql, int rows, long time); + void QueryExecuted(string hql, int rows, TimeSpan time); void QueryCacheHit(string hql, string regionName); void QueryCacheMiss(string hql, string regionName); void QueryCachePut(string hql, string regionName); Modified: trunk/nhibernate/src/NHibernate/Stat/QueryStatistics.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Stat/QueryStatistics.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Stat/QueryStatistics.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -13,9 +13,9 @@ internal long cachePutCount; private long executionCount; private long executionRowCount; - private long executionAvgTime; - private long executionMaxTime; - private long executionMinTime; + private TimeSpan executionAvgTime; + private TimeSpan executionMaxTime; + private TimeSpan executionMinTime = TimeSpan.MaxValue; public QueryStatistics(string categoryName) : base(categoryName) { } @@ -44,17 +44,17 @@ get { return executionRowCount; } } - public long ExecutionAvgTime + public TimeSpan ExecutionAvgTime { get { return executionAvgTime; } } - public long ExecutionMaxTime + public TimeSpan ExecutionMaxTime { get { return executionMaxTime; } } - public long ExecutionMinTime + public TimeSpan ExecutionMinTime { get { return executionMinTime; } } @@ -62,7 +62,7 @@ /// <summary> Add statistics report of a DB query </summary> /// <param name="rows">rows count returned </param> /// <param name="time">time taken </param> - internal void Executed(long rows, long time) + internal void Executed(long rows, TimeSpan time) { if (time < executionMinTime) executionMinTime = time; @@ -70,7 +70,7 @@ executionMaxTime = time; executionCount++; executionRowCount += rows; - executionAvgTime = (executionAvgTime * executionCount + time) / executionCount; + executionAvgTime = TimeSpan.FromTicks((executionAvgTime.Ticks * executionCount + time.Ticks) / executionCount); } public override string ToString() Modified: trunk/nhibernate/src/NHibernate/Stat/StatisticsImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Stat/StatisticsImpl.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate/Stat/StatisticsImpl.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Runtime.CompilerServices; +using System.Text; using System.Threading; using log4net; using NHibernate.Cache; @@ -20,8 +21,10 @@ private long entityLoadCount; private long entityFetchCount; private long entityUpdateCount; + // log operations that take longer than this value + private TimeSpan operationThreshold = TimeSpan.MaxValue; private long queryExecutionCount; - private long queryExecutionMaxTime; + private TimeSpan queryExecutionMaxTime; private string queryExecutionMaxTimeQueryString; private long queryCacheHitCount; private long queryCacheMissCount; @@ -39,7 +42,6 @@ private long collectionRemoveCount; private long collectionRecreateCount; private DateTime startTime; - private bool isStatisticsEnabled; private long commitedTransactionCount; private long transactionCount; private long prepareStatementCount; @@ -54,8 +56,22 @@ // entity statistics per query string (HQL or SQL) private readonly Dictionary<string, QueryStatistics> queryStatistics = new Dictionary<string, QueryStatistics>(); + internal const string OperationLoad = "load "; + internal const string OperationFetch = "fetch "; + internal const string OperationUpdate = "update "; + internal const string OperationInsert = "insert "; + internal const string OperationDelete = "delete "; + internal const string OperationLoadCollection = "loadCollection "; + internal const string OperationFetchCollection = "fetchCollection "; + internal const string OperationUpdateCollection = "updateCollection "; + internal const string OperationRecreateCollection = "recreateCollection "; + internal const string OperationRemoveCollection = "removeCollection "; + internal const string OperationExecuteQuery = "executeQuery "; + internal const string OperationEndTransaction = "endTransaction "; + public StatisticsImpl() { + Clear(); } public StatisticsImpl(ISessionFactoryImplementor sessionFactory) @@ -107,7 +123,7 @@ get { return queryExecutionCount; } } - public long QueryExecutionMaxTime + public TimeSpan QueryExecutionMaxTime { get { return queryExecutionMaxTime; } } @@ -197,17 +213,13 @@ get { return startTime; } } - public bool IsStatisticsEnabled - { - get { return isStatisticsEnabled; } - set { isStatisticsEnabled = value; } - } + public bool IsStatisticsEnabled { get; set; } public string[] Queries { get { - string[] result = new string[queryStatistics.Keys.Count]; + var result = new string[queryStatistics.Keys.Count]; queryStatistics.Keys.CopyTo(result,0); return result; } @@ -219,7 +231,7 @@ { if (sessionFactory == null) { - string[] result = new string[entityStatistics.Keys.Count]; + var result = new string[entityStatistics.Keys.Count]; entityStatistics.Keys.CopyTo(result, 0); return result; } @@ -236,14 +248,14 @@ { if (sessionFactory == null) { - string[] result = new string[collectionStatistics.Keys.Count]; + var result = new string[collectionStatistics.Keys.Count]; collectionStatistics.Keys.CopyTo(result, 0); return result; } else { ICollection<string> kc = sessionFactory.GetAllCollectionMetadata().Keys; - string[] result = new string[kc.Count]; + var result = new string[kc.Count]; kc.CopyTo(result, 0); return result; } @@ -256,7 +268,7 @@ { if (sessionFactory == null) { - string[] result = new string[secondLevelCacheStatistics.Keys.Count]; + var result = new string[secondLevelCacheStatistics.Keys.Count]; secondLevelCacheStatistics.Keys.CopyTo(result, 0); return result; } @@ -323,7 +335,7 @@ queryExecutionCount = 0; queryCacheHitCount = 0; - queryExecutionMaxTime = 0; + queryExecutionMaxTime = TimeSpan.MinValue; queryExecutionMaxTimeQueryString = null; queryCacheMissCount = 0; queryCachePutCount = 0; @@ -348,8 +360,7 @@ lock (SyncRoot) { EntityStatistics es; - entityStatistics.TryGetValue(entityName, out es); - if (es == null) + if (!entityStatistics.TryGetValue(entityName, out es)) { es = new EntityStatistics(entityName); entityStatistics[entityName] = es; @@ -364,8 +375,7 @@ lock (SyncRoot) { CollectionStatistics cs; - collectionStatistics.TryGetValue(role, out cs); - if (cs == null) + if (!collectionStatistics.TryGetValue(role, out cs)) { cs = new CollectionStatistics(role); collectionStatistics[role] = cs; @@ -380,8 +390,8 @@ lock (SyncRoot) { SecondLevelCacheStatistics slcs; - secondLevelCacheStatistics.TryGetValue(regionName, out slcs); - if (slcs == null) + + if (!secondLevelCacheStatistics.TryGetValue(regionName, out slcs)) { if (sessionFactory == null) return null; @@ -401,8 +411,7 @@ lock (SyncRoot) { QueryStatistics qs; - queryStatistics.TryGetValue(queryString, out qs); - if (qs == null) + if (!queryStatistics.TryGetValue(queryString, out qs)) { qs = new QueryStatistics(queryString); queryStatistics[queryString] = qs; @@ -414,7 +423,7 @@ public void LogSummary() { log.Info("Logging statistics...."); - log.Info(string.Format("start time: {0}", startTime));// TODO change format to show ms + log.Info(string.Format("start time: {0}", startTime.ToString("o"))); log.Info("sessions opened: " + sessionOpenCount); log.Info("sessions closed: " + sessionCloseCount); log.Info("transactions: " + transactionCount); @@ -441,9 +450,25 @@ log.Info("query cache puts: " + queryCachePutCount); log.Info("query cache hits: " + queryCacheHitCount); log.Info("query cache misses: " + queryCacheMissCount); - log.Info("max query time: " + queryExecutionMaxTime + "ms"); + log.Info("max query time: " + queryExecutionMaxTime.Milliseconds + "ms"); } + public TimeSpan OperationThreshold + { + get + { + return operationThreshold; + } + [MethodImpl(MethodImplOptions.Synchronized)] + set + { + lock (SyncRoot) + { + operationThreshold = value; + } + } + } + #endregion #region IStatisticsImplementor Members @@ -485,103 +510,143 @@ } [MethodImpl(MethodImplOptions.Synchronized)] - public void LoadEntity(string entityName) + public void LoadEntity(string entityName, TimeSpan time) { lock (SyncRoot) { entityLoadCount++; GetEntityStatistics(entityName).loadCount++; } + if (operationThreshold < time) + { + LogOperation(OperationLoad, entityName, time); + } } [MethodImpl(MethodImplOptions.Synchronized)] - public void FetchEntity(string entityName) + public void FetchEntity(string entityName, TimeSpan time) { lock (SyncRoot) { entityFetchCount++; GetEntityStatistics(entityName).fetchCount++; } + if (operationThreshold < time) + { + LogOperation(OperationLoad, entityName, time); + } } [MethodImpl(MethodImplOptions.Synchronized)] - public void UpdateEntity(string entityName) + public void UpdateEntity(string entityName, TimeSpan time) { lock (SyncRoot) { entityUpdateCount++; GetEntityStatistics(entityName).updateCount++; } + if (operationThreshold < time) + { + LogOperation(OperationUpdate, entityName, time); + } } [MethodImpl(MethodImplOptions.Synchronized)] - public void InsertEntity(string entityName) + public void InsertEntity(string entityName, TimeSpan time) { lock (SyncRoot) { entityInsertCount++; GetEntityStatistics(entityName).insertCount++; } + if (operationThreshold < time) + { + LogOperation(OperationInsert, entityName, time); + } } [MethodImpl(MethodImplOptions.Synchronized)] - public void DeleteEntity(string entityName) + public void DeleteEntity(string entityName, TimeSpan time) { lock (SyncRoot) { entityDeleteCount++; GetEntityStatistics(entityName).deleteCount++; } + if (operationThreshold < time) + { + LogOperation(OperationDelete, entityName, time); + } } [MethodImpl(MethodImplOptions.Synchronized)] - public void LoadCollection(string role) + public void LoadCollection(string role, TimeSpan time) { lock (SyncRoot) { collectionLoadCount++; GetCollectionStatistics(role).loadCount++; } + if (operationThreshold < time) + { + LogOperation(OperationLoadCollection, role, time); + } } [MethodImpl(MethodImplOptions.Synchronized)] - public void FetchCollection(string role) + public void FetchCollection(string role, TimeSpan time) { lock (SyncRoot) { collectionFetchCount++; GetCollectionStatistics(role).fetchCount++; } + if (operationThreshold < time) + { + LogOperation(OperationFetchCollection, role, time); + } } [MethodImpl(MethodImplOptions.Synchronized)] - public void UpdateCollection(string role) + public void UpdateCollection(string role, TimeSpan time) { lock (SyncRoot) { collectionUpdateCount++; GetCollectionStatistics(role).updateCount++; } + if (operationThreshold < time) + { + LogOperation(OperationUpdateCollection, role, time); + } } [MethodImpl(MethodImplOptions.Synchronized)] - public void RecreateCollection(string role) + public void RecreateCollection(string role, TimeSpan time) { lock (SyncRoot) { collectionRecreateCount++; GetCollectionStatistics(role).recreateCount++; } + if (operationThreshold < time) + { + LogOperation(OperationRecreateCollection, role, time); + } } [MethodImpl(MethodImplOptions.Synchronized)] - public void RemoveCollection(string role) + public void RemoveCollection(string role, TimeSpan time) { lock (SyncRoot) { collectionRemoveCount++; GetCollectionStatistics(role).removeCount++; } + if (operationThreshold < time) + { + LogOperation(OperationRecreateCollection, role, time); + } } [MethodImpl(MethodImplOptions.Synchronized)] @@ -627,7 +692,7 @@ } [MethodImpl(MethodImplOptions.Synchronized)] - public void QueryExecuted(string hql, int rows, long time) + public void QueryExecuted(string hql, int rows, TimeSpan time) { lock (SyncRoot) { @@ -643,6 +708,10 @@ qs.Executed(rows, time); } } + if (operationThreshold < time) + { + LogOperation(OperationExecuteQuery, hql, time); + } } [MethodImpl(MethodImplOptions.Synchronized)] @@ -726,5 +795,34 @@ } #endregion + + private static void LogOperation(string operation, string entityName, TimeSpan time) + { + if (entityName != null) + log.Info(operation + entityName + " " + time.Milliseconds + "ms"); + else + log.Info(operation); // just log that the event occurred + } + + public override string ToString() + { + return + new StringBuilder().Append("Statistics[").Append("start time=").Append(startTime).Append(",sessions opened=").Append + (sessionOpenCount).Append(",sessions closed=").Append(sessionCloseCount).Append(",transactions=").Append( + transactionCount).Append(",successful transactions=").Append(commitedTransactionCount).Append( + ",optimistic lock failures=").Append(optimisticFailureCount).Append(",flushes=").Append(flushCount).Append( + ",connections obtained=").Append(connectCount).Append(",statements prepared=").Append(prepareStatementCount).Append + (",statements closed=").Append(closeStatementCount).Append(",second level cache puts=").Append( + secondLevelCachePutCount).Append(",second level cache hits=").Append(secondLevelCacheHitCount).Append( + ",second level cache misses=").Append(secondLevelCacheMissCount).Append(",entities loaded=").Append(entityLoadCount) + .Append(",entities updated=").Append(entityUpdateCount).Append(",entities inserted=").Append(entityInsertCount). + Append(",entities deleted=").Append(entityDeleteCount).Append(",entities fetched=").Append(entityFetchCount).Append + (",collections loaded=").Append(collectionLoadCount).Append(",collections updated=").Append(collectionUpdateCount). + Append(",collections removed=").Append(collectionRemoveCount).Append(",collections recreated=").Append( + collectionRecreateCount).Append(",collections fetched=").Append(collectionFetchCount).Append( + ",queries executed to database=").Append(queryExecutionCount).Append(",query cache puts=").Append( + queryCachePutCount).Append(",query cache hits=").Append(queryCacheHitCount).Append(",query cache misses=").Append( + queryCacheMissCount).Append(",max query time=").Append(queryExecutionMaxTime).Append(']').ToString(); + } } } Modified: trunk/nhibernate/src/NHibernate.Test/Stats/StatsFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Stats/StatsFixture.cs 2008-10-05 13:07:29 UTC (rev 3815) +++ trunk/nhibernate/src/NHibernate.Test/Stats/StatsFixture.cs 2008-10-08 15:16:52 UTC (rev 3816) @@ -155,7 +155,7 @@ Assert.IsNotNull(continentStats, "stats were null"); Assert.AreEqual(1, continentStats.ExecutionCount, "unexpected execution count"); Assert.AreEqual(results, continentStats.ExecutionRowCount, "unexpected row count"); - long maxTime = continentStats.ExecutionMaxTime; + var maxTime = continentStats.ExecutionMaxTime; Assert.AreEqual(maxTime, stats.QueryExecutionMaxTime); //Assert.AreEqual( continents, stats.QueryExecutionMaxTimeQueryString ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2008-10-05 13:10:11
|
Revision: 3815 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3815&view=rev Author: tehlike Date: 2008-10-05 13:07:29 +0000 (Sun, 05 Oct 2008) Log Message: ----------- -Making some more visit methods virtual. -Initials for SelectJoinGatherer. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Linq/Expressions/AssociationPropertyExpression.cs trunk/nhibernate/src/NHibernate.Linq/Expressions/NHExpressionType.cs trunk/nhibernate/src/NHibernate.Linq/Expressions/OneToManyPropertyExpression.cs trunk/nhibernate/src/NHibernate.Linq/Expressions/OneToOnePropertyExpression.cs trunk/nhibernate/src/NHibernate.Linq/NHibernate.Linq.csproj trunk/nhibernate/src/NHibernate.Linq/Visitors/AssociationRewriteVisitor.cs trunk/nhibernate/src/NHibernate.Linq/Visitors/NHibernateExpressionVisitor.cs trunk/nhibernate/src/NHibernate.Linq.Test/NHibernate.Linq.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Linq/Expressions/QueryParameterExpression.cs trunk/nhibernate/src/NHibernate.Linq/Visitors/SelectJoinGatherer.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Linq/Visitors/JoinGatherer.cs Modified: trunk/nhibernate/src/NHibernate.Linq/Expressions/AssociationPropertyExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Linq/Expressions/AssociationPropertyExpression.cs 2008-10-04 19:27:55 UTC (rev 3814) +++ trunk/nhibernate/src/NHibernate.Linq/Expressions/AssociationPropertyExpression.cs 2008-10-05 13:07:29 UTC (rev 3815) @@ -7,14 +7,16 @@ namespace NHibernate.Linq.Expressions { - public abstract class AssociationPropertyExpression:PropertyExpression + public abstract class AssociationPropertyExpression : PropertyExpression { - public AssociationPropertyExpression(string name,NHExpressionType nodeType,System.Type type, - Expression source,IType nhType):base(name,nodeType,type,source,nhType) + public AssociationPropertyExpression(string name, string alias, NHExpressionType nodeType, + System.Type type, Expression source, IType nhType) + : base(name, nodeType, type, source, nhType) { - + } public IAssociationType AssociationType { get { return base.NHibernateType as IAssociationType; } } + public string Alias { get; protected set; } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Linq/Expressions/NHExpressionType.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Linq/Expressions/NHExpressionType.cs 2008-10-04 19:27:55 UTC (rev 3814) +++ trunk/nhibernate/src/NHibernate.Linq/Expressions/NHExpressionType.cs 2008-10-05 13:07:29 UTC (rev 3815) @@ -9,6 +9,7 @@ ComponentProperty, OneToManyProperty, OneToOneProperty, + Parameter, Order, } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Linq/Expressions/OneToManyPropertyExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Linq/Expressions/OneToManyPropertyExpression.cs 2008-10-04 19:27:55 UTC (rev 3814) +++ trunk/nhibernate/src/NHibernate.Linq/Expressions/OneToManyPropertyExpression.cs 2008-10-05 13:07:29 UTC (rev 3815) @@ -9,8 +9,8 @@ { public class OneToManyPropertyExpression : AssociationPropertyExpression { - public OneToManyPropertyExpression(string name, System.Type type, Expression source, IType nhibernateType) - : base(name,NHExpressionType.OneToManyProperty, type, source, nhibernateType) + public OneToManyPropertyExpression(string name, string alias, System.Type type, Expression source, IType nhibernateType) + : base(name,alias,NHExpressionType.OneToManyProperty, type, source, nhibernateType) { } Modified: trunk/nhibernate/src/NHibernate.Linq/Expressions/OneToOnePropertyExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Linq/Expressions/OneToOnePropertyExpression.cs 2008-10-04 19:27:55 UTC (rev 3814) +++ trunk/nhibernate/src/NHibernate.Linq/Expressions/OneToOnePropertyExpression.cs 2008-10-05 13:07:29 UTC (rev 3815) @@ -9,8 +9,8 @@ { public class OneToOnePropertyExpression:AssociationPropertyExpression { - public OneToOnePropertyExpression(string name, System.Type type, Expression source, IType nhType) - : base(name, NHExpressionType.OneToOneProperty, type, source, nhType) + public OneToOnePropertyExpression(string name,string alias, System.Type type, Expression source, IType nhType) + : base(name,alias, NHExpressionType.OneToOneProperty, type, source, nhType) { } Added: trunk/nhibernate/src/NHibernate.Linq/Expressions/QueryParameterExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Linq/Expressions/QueryParameterExpression.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Linq/Expressions/QueryParameterExpression.cs 2008-10-05 13:07:29 UTC (rev 3815) @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; + +namespace NHibernate.Linq.Expressions +{ + public class QueryParameterExpression:NHExpression + { + public QueryParameterExpression(object value, int ordinal, System.Type type) + : base(NHExpressionType.Parameter, type) + { + this.Value = value; + this.Ordinal = ordinal; + } + + public object Value { get; protected set; } + public int Ordinal { get; protected set; } + } +} Property changes on: trunk/nhibernate/src/NHibernate.Linq/Expressions/QueryParameterExpression.cs ___________________________________________________________________ Added: svn:mergeinfo + Modified: trunk/nhibernate/src/NHibernate.Linq/NHibernate.Linq.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Linq/NHibernate.Linq.csproj 2008-10-04 19:27:55 UTC (rev 3814) +++ trunk/nhibernate/src/NHibernate.Linq/NHibernate.Linq.csproj 2008-10-05 13:07:29 UTC (rev 3815) @@ -44,7 +44,7 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> - <ProjectReference Include="..\NHibernate\NHibernate-3.5.csproj"> + <ProjectReference Include="..\NHibernate\NHibernate.csproj"> <Project>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</Project> <Name>NHibernate-3.5</Name> </ProjectReference> @@ -56,6 +56,7 @@ <Compile Include="Expressions\OneToOnePropertyExpression.cs" /> <Compile Include="Expressions\OrderExpression.cs" /> <Compile Include="Expressions\OrderType.cs" /> + <Compile Include="Expressions\QueryParameterExpression.cs" /> <Compile Include="Expressions\ProjectionExpression.cs" /> <Compile Include="Expressions\PropertyExpression.cs" /> <Compile Include="Expressions\SelectExpression.cs" /> @@ -67,7 +68,6 @@ <Compile Include="Util\Guard.cs" /> <Compile Include="Util\LinqUtil.cs" /> <Compile Include="Visitors\AssociationRewriteVisitor.cs" /> - <Compile Include="Visitors\JoinGatherer.cs" /> <Compile Include="Visitors\LogicalExpressionReducer.cs" /> <Compile Include="ExpressionVisitor.cs" /> <Compile Include="NHibernateExtensions.cs" /> @@ -80,6 +80,7 @@ <Compile Include="Visitors\OrderByTransformer.cs" /> <Compile Include="Visitors\Replacer.cs" /> <Compile Include="Visitors\QuerySpacesFinderVisitor.cs" /> + <Compile Include="Visitors\SelectJoinGatherer.cs" /> <Compile Include="Visitors\SqlExpressionTranslator.cs" /> <Compile Include="Visitors\NHExpressionToSqlExpressionTransformer.cs" /> <Compile Include="Visitors\WhereExpressionCombiner.cs" /> Modified: trunk/nhibernate/src/NHibernate.Linq/Visitors/AssociationRewriteVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Linq/Visitors/AssociationRewriteVisitor.cs 2008-10-04 19:27:55 UTC (rev 3814) +++ trunk/nhibernate/src/NHibernate.Linq/Visitors/AssociationRewriteVisitor.cs 2008-10-05 13:07:29 UTC (rev 3815) @@ -14,12 +14,13 @@ public class AssociationRewriteVisitor : NHibernateExpressionVisitor { private readonly ISessionFactoryImplementor sessionFactory; + private int parameterOrder; private int aliasOrder; - public AssociationRewriteVisitor(ISessionFactoryImplementor factory) { - sessionFactory = factory; - aliasOrder = 0; + this.sessionFactory = factory; + this.aliasOrder = 0; + this.parameterOrder = 0; } public static Expression Rewrite(Expression expr, ISessionFactoryImplementor factory) @@ -62,7 +63,7 @@ else if (propertyType is OneToOneType) { Expression source = base.Visit(expr.Expression); - return new OneToOnePropertyExpression(propertyName, expr.Type, source, propertyType); + return new OneToOnePropertyExpression(propertyName,GenerateAliasString(), expr.Type, source, propertyType); } else if(!propertyType.IsAssociationType)//assume simple property { @@ -82,8 +83,12 @@ var loadable = sessionFactory.GetEntityPersister(elementType.FullName) as IOuterJoinLoadable; return new QuerySourceExpression(type, loadable); } - - return c; + else + return new QueryParameterExpression(c.Type, parameterOrder++, c.Type); } + private string GenerateAliasString() + { + return string.Format("a_{0}", aliasOrder++); + } } } \ No newline at end of file Deleted: trunk/nhibernate/src/NHibernate.Linq/Visitors/JoinGatherer.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Linq/Visitors/JoinGatherer.cs 2008-10-04 19:27:55 UTC (rev 3814) +++ trunk/nhibernate/src/NHibernate.Linq/Visitors/JoinGatherer.cs 2008-10-05 13:07:29 UTC (rev 3815) @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NHibernate.Engine; -using NHibernate.Mapping; -using NHibernate.Type; - -namespace NHibernate.Linq.Visitors -{ - public class SelectWhereJoinGatherer:NHibernateExpressionVisitor - { - public override System.Linq.Expressions.Expression Visit(System.Linq.Expressions.Expression exp) - { - return base.Visit(exp); - } - } -} Modified: trunk/nhibernate/src/NHibernate.Linq/Visitors/NHibernateExpressionVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Linq/Visitors/NHibernateExpressionVisitor.cs 2008-10-04 19:27:55 UTC (rev 3814) +++ trunk/nhibernate/src/NHibernate.Linq/Visitors/NHibernateExpressionVisitor.cs 2008-10-05 13:07:29 UTC (rev 3815) @@ -61,7 +61,7 @@ return new SimplePropertyExpression(property.Name, property.Column, property.Type, source, property.NHibernateType); return property; } - private Expression VisitComponentProperty(ComponentPropertyExpression property) + protected virtual Expression VisitComponentProperty(ComponentPropertyExpression property) { Expression source = Visit(property.Source); if (source != property.Source) @@ -69,18 +69,19 @@ return property; } - private Expression VisitOneToManyProperty(OneToManyPropertyExpression propertyExpression) + protected virtual Expression VisitOneToManyProperty(OneToManyPropertyExpression propertyExpression) { Expression source = Visit(propertyExpression.Source); + if (source != propertyExpression.Source) - return new OneToManyPropertyExpression(propertyExpression.Name, propertyExpression.Type, source, propertyExpression.NHibernateType); + return new OneToManyPropertyExpression(propertyExpression.Name, propertyExpression.Alias, propertyExpression.Type, source, propertyExpression.NHibernateType); return propertyExpression; } - private Expression VisitOneToOneProperty(OneToOnePropertyExpression propertyExpression) + protected virtual Expression VisitOneToOneProperty(OneToOnePropertyExpression propertyExpression) { Expression source = Visit(propertyExpression.Source); if (source != propertyExpression.Source) - return new OneToOnePropertyExpression(propertyExpression.Name, propertyExpression.Type, source, propertyExpression.NHibernateType); + return new OneToOnePropertyExpression(propertyExpression.Name, propertyExpression.Alias, propertyExpression.Type, source, propertyExpression.NHibernateType); return propertyExpression; } //TODO: modify Added: trunk/nhibernate/src/NHibernate.Linq/Visitors/SelectJoinGatherer.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Linq/Visitors/SelectJoinGatherer.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Linq/Visitors/SelectJoinGatherer.cs 2008-10-05 13:07:29 UTC (rev 3815) @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NHibernate.Engine; + +namespace NHibernate.Linq.Visitors +{ + public class SelectJoinGatherer:NHibernateExpressionVisitor + { + public SelectJoinGatherer(ISessionFactoryImplementor sessionFactory) + { + this.SessionFactory = sessionFactory; + this.JoinSequence=new JoinSequence(sessionFactory); + } + + public ISessionFactoryImplementor SessionFactory { get; protected set; } + public JoinSequence JoinSequence { get; protected set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Linq.Test/NHibernate.Linq.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Linq.Test/NHibernate.Linq.Test.csproj 2008-10-04 19:27:55 UTC (rev 3814) +++ trunk/nhibernate/src/NHibernate.Linq.Test/NHibernate.Linq.Test.csproj 2008-10-05 13:07:29 UTC (rev 3815) @@ -60,7 +60,7 @@ <Project>{3073F5DA-5D57-4E12-9F95-8516ED346E67}</Project> <Name>NHibernate.Linq</Name> </ProjectReference> - <ProjectReference Include="..\NHibernate\NHibernate-3.5.csproj"> + <ProjectReference Include="..\NHibernate\NHibernate.csproj"> <Project>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</Project> <Name>NHibernate-3.5</Name> </ProjectReference> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2008-10-04 19:28:01
|
Revision: 3814 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3814&view=rev Author: tehlike Date: 2008-10-04 19:27:55 +0000 (Sat, 04 Oct 2008) Log Message: ----------- Fix for NH-1505 by Jaroslav Mart?\195?\161sek Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs trunk/nhibernate/src/NHibernate/Criterion/LikeExpression.cs trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs Modified: trunk/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs 2008-10-04 19:20:12 UTC (rev 3813) +++ trunk/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs 2008-10-04 19:27:55 UTC (rev 3814) @@ -46,7 +46,7 @@ } } - private static SqlString[] GetColumnNamesUsingProjection(IProjection projection, ICriteriaQuery criteriaQuery, ICriteria criteria, + internal static SqlString[] GetColumnNamesUsingProjection(IProjection projection, ICriteriaQuery criteriaQuery, ICriteria criteria, IDictionary<string, IFilter> enabledFilters) { SqlString sqlString = projection.ToSqlString(criteria, Modified: trunk/nhibernate/src/NHibernate/Criterion/LikeExpression.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/LikeExpression.cs 2008-10-04 19:20:12 UTC (rev 3813) +++ trunk/nhibernate/src/NHibernate/Criterion/LikeExpression.cs 2008-10-04 19:27:55 UTC (rev 3814) @@ -17,15 +17,14 @@ [Serializable] public class LikeExpression : AbstractCriterion { - private readonly string propertyName; private readonly string value; private char? escapeChar; private readonly bool ignoreCase; - private readonly IProjection _projection; + private readonly IProjection projection; public LikeExpression(string propertyName, string value, char? escapeChar, bool ignoreCase) { - this.propertyName = propertyName; + this.projection = Projections.Property(propertyName); this.value = value; this.escapeChar = escapeChar; this.ignoreCase = ignoreCase; @@ -33,7 +32,7 @@ public LikeExpression(IProjection projection, string value, MatchMode matchMode) { - _projection = projection; + this.projection = projection; this.value = matchMode.ToMatchString(value); } @@ -57,21 +56,23 @@ public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters) { - string[] columns = criteriaQuery.GetColumnsUsingProjection(criteria, propertyName); + SqlString[] columns = CriterionUtil.GetColumnNamesUsingProjection(projection, criteriaQuery, criteria, enabledFilters); if (columns.Length != 1) - throw new HibernateException("Like may only be used with single-column properties"); + throw new HibernateException("Like may only be used with single-column properties / projections."); SqlStringBuilder lhs = new SqlStringBuilder(6); - if(ignoreCase) + if (ignoreCase) { Dialect.Dialect dialect = criteriaQuery.Factory.Dialect; - lhs.Add(dialect.LowercaseFunction).Add(StringHelper.OpenParen).Add(columns[0]).Add( - StringHelper.ClosedParen); + lhs.Add(dialect.LowercaseFunction) + .Add(StringHelper.OpenParen) + .Add(columns[0]) + .Add(StringHelper.ClosedParen); } - else + else lhs.Add(columns[0]); - + criteriaQuery.AddUsedTypedValues(GetTypedValues(criteria, criteriaQuery)); lhs.Add(" like ").AddParameter(); if (escapeChar.HasValue) @@ -81,23 +82,21 @@ public override TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery criteriaQuery) { - return new TypedValue[] {criteriaQuery.GetTypedValue(criteria, propertyName, ignoreCase ? value.ToLower() : value)}; + return new TypedValue[] { + new TypedValue(NHibernateUtil.String, value, EntityMode.Poco), + }; } public override IProjection[] GetProjections() { - if(_projection != null) - { - return new IProjection[] {_projection}; - } - return null; + return new IProjection[] { projection }; } #endregion public override string ToString() { - return (_projection != null ? _projection.ToString() : propertyName) + " like " + value; + return projection + " like " + value; } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs 2008-10-04 19:20:12 UTC (rev 3813) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs 2008-10-04 19:27:55 UTC (rev 3814) @@ -1655,8 +1655,8 @@ t.Commit(); } } - + [Test] public void TransformToRowCountTest() { @@ -1677,9 +1677,11 @@ } [Test] - public void OrderProjectionTest() { - using (ISession session = this.OpenSession()) { - ICriteria criteria = session.CreateCriteria(typeof (Student), "c"); + public void OrderProjectionTest() + { + using (ISession session = this.OpenSession()) + { + ICriteria criteria = session.CreateCriteria(typeof(Student), "c"); criteria .AddOrder(Order.Asc( @@ -1692,5 +1694,67 @@ criteria.List(); } } + + [Test] + public void LikeProjectionTest() + { + Student john = new Student { Name = "John" }; + using (ISession session = this.OpenSession()) + { + session.Save(john); + session.Flush(); + } + + + using (ISession session = this.OpenSession()) + { + ICriteria criteria = session.CreateCriteria(typeof(Student), "c"); + + criteria.Add(new LikeExpression(Projections.Property("Name"), "John", MatchMode.Anywhere)); + + Assert.AreEqual(1, criteria.List().Count); + } + + using (ISession session = this.OpenSession()) + { + ICriteria criteria = session.CreateCriteria(typeof(Student), "c"); + + criteria.Add(new LikeExpression("Name", "John")); + + Assert.AreEqual(1, criteria.List().Count); + } + + using (ISession session = this.OpenSession()) + { + session.Delete(john); + session.Flush(); + } + } + + [Test] + public void LikeProjectionUsingRestrictionsTest() + { + using (ISession session = this.OpenSession()) + { + ICriteria criteria = session.CreateCriteria(typeof(Student), "c"); + + criteria.Add(Restrictions.Like(Projections.Constant("Name"), "John", MatchMode.Anywhere)); + + criteria.List(); + } + } + + [Test] + public void InsensitiveLikeProjectionUsingRestrictionsTest() + { + using (ISession session = this.OpenSession()) + { + ICriteria criteria = session.CreateCriteria(typeof(Student), "c"); + + criteria.Add(Restrictions.InsensitiveLike(Projections.Constant("Name"), "John", MatchMode.Anywhere)); + + criteria.List(); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2008-10-04 19:20:24
|
Revision: 3813 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3813&view=rev Author: tehlike Date: 2008-10-04 19:20:12 +0000 (Sat, 04 Oct 2008) Log Message: ----------- Adding projection support to LikeExpression(Fix NH-1505) Modified Paths: -------------- branches/2.0.x/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs branches/2.0.x/nhibernate/src/NHibernate/Criterion/LikeExpression.cs branches/2.0.x/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs Modified: branches/2.0.x/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs 2008-10-04 19:09:32 UTC (rev 3812) +++ branches/2.0.x/nhibernate/src/NHibernate/Criterion/CriterionUtil.cs 2008-10-04 19:20:12 UTC (rev 3813) @@ -34,10 +34,10 @@ if (projection == null) { return GetColumnNamesUsingPropertyName( - criteriaQuery, - criteria, + criteriaQuery, + criteria, propertyName, - value, + value, criterion); } else @@ -46,12 +46,12 @@ } } - private static SqlString[] GetColumnNamesUsingProjection(IProjection projection, ICriteriaQuery criteriaQuery, ICriteria criteria, + internal static SqlString[] GetColumnNamesUsingProjection(IProjection projection, ICriteriaQuery criteriaQuery, ICriteria criteria, IDictionary<string, IFilter> enabledFilters) { - SqlString sqlString = projection.ToSqlString(criteria, + SqlString sqlString = projection.ToSqlString(criteria, criteriaQuery.GetIndexForAlias(), - criteriaQuery, + criteriaQuery, enabledFilters); return new SqlString[] { @@ -66,10 +66,10 @@ } private static SqlString[] GetColumnNamesUsingPropertyName( - ICriteriaQuery criteriaQuery, - ICriteria criteria, - string propertyName, - object value, + ICriteriaQuery criteriaQuery, + ICriteria criteria, + string propertyName, + object value, ICriterion critertion) { string[] columnNames = criteriaQuery.GetColumnsUsingProjection(criteria, propertyName); @@ -96,16 +96,16 @@ } public static TypedValue[] GetTypedValues(ICriteriaQuery criteriaQuery, ICriteria criteria, - IProjection projection, - string propertyName, - params object[] values) + IProjection projection, + string propertyName, + params object[] values) { List<TypedValue> types = new List<TypedValue>(); if (projection == null) { foreach (object value in values) { - TypedValue typedValue = criteriaQuery.GetTypedValue(criteria, propertyName, value); + TypedValue typedValue = criteriaQuery.GetTypedValue(criteria, propertyName, value); types.Add(typedValue); } } Modified: branches/2.0.x/nhibernate/src/NHibernate/Criterion/LikeExpression.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Criterion/LikeExpression.cs 2008-10-04 19:09:32 UTC (rev 3812) +++ branches/2.0.x/nhibernate/src/NHibernate/Criterion/LikeExpression.cs 2008-10-04 19:20:12 UTC (rev 3813) @@ -17,27 +17,29 @@ [Serializable] public class LikeExpression : AbstractCriterion { - private readonly string propertyName; private readonly string value; private char? escapeChar; private readonly bool ignoreCase; private readonly IProjection projection; public LikeExpression(string propertyName, string value, char? escapeChar, bool ignoreCase) + : this(Projections.Property(propertyName), value, MatchMode.Exact, escapeChar, ignoreCase) { - this.propertyName = propertyName; - this.value = value; - this.escapeChar = escapeChar; - this.ignoreCase = ignoreCase; } public LikeExpression(IProjection projection, string value, MatchMode matchMode) + : this(projection, value, MatchMode.Exact, null, false) { + + } + public LikeExpression(IProjection projection, string value, MatchMode matchMode, char? escapeChar, bool ignoreCase) + { this.projection = projection; this.value = matchMode.ToMatchString(value); + this.escapeChar = escapeChar; + this.ignoreCase = ignoreCase; } - public LikeExpression(string propertyName, string value) : this(propertyName, value, null, false) { @@ -57,19 +59,22 @@ public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters) { - string[] columns = criteriaQuery.GetColumnsUsingProjection(criteria, propertyName); + SqlString[] columns = CriterionUtil.GetColumnNamesUsingProjection(projection, criteriaQuery, criteria, enabledFilters); if (columns.Length != 1) - throw new HibernateException("Like may only be used with single-column properties"); + throw new HibernateException("Like may only be used with single-column properties / projections."); SqlStringBuilder lhs = new SqlStringBuilder(6); - if(ignoreCase) + if (ignoreCase) { Dialect.Dialect dialect = criteriaQuery.Factory.Dialect; - lhs.Add(dialect.LowercaseFunction).Add(StringHelper.OpenParen).Add(columns[0]).Add( - StringHelper.ClosedParen); + lhs + .Add(dialect.LowercaseFunction) + .Add(StringHelper.OpenParen) + .Add(columns[0]) + .Add(StringHelper.ClosedParen); } - else + else lhs.Add(columns[0]); lhs.Add(" like ").AddParameter(); if (escapeChar.HasValue) @@ -79,14 +84,17 @@ public override TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery criteriaQuery) { - return new TypedValue[] {criteriaQuery.GetTypedValue(criteria, propertyName, ignoreCase ? value.ToLower() : value)}; + return new TypedValue[] + { + new TypedValue(NHibernateUtil.String, value, EntityMode.Poco) + }; } #endregion public override string ToString() { - return (projection != null ? projection.ToString() : propertyName) + " like " + value; + return projection + " like " + value; } } } \ No newline at end of file Modified: branches/2.0.x/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs 2008-10-04 19:09:32 UTC (rev 3812) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs 2008-10-04 19:20:12 UTC (rev 3813) @@ -1654,6 +1654,70 @@ t.Commit(); } - } + } + + + [Test] + public void LikeProjectionTest() + { + Student john = new Student(); + john.Name = "John"; + using (ISession session = this.OpenSession()) + { + session.Save(john); + session.Flush(); + } + + + using (ISession session = this.OpenSession()) + { + ICriteria criteria = session.CreateCriteria(typeof(Student), "c"); + + criteria.Add(new LikeExpression(Projections.Property("Name"), "John", MatchMode.Anywhere)); + + Assert.AreEqual(1, criteria.List().Count); + } + + using (ISession session = this.OpenSession()) + { + ICriteria criteria = session.CreateCriteria(typeof(Student), "c"); + + criteria.Add(new LikeExpression("Name", "John")); + + Assert.AreEqual(1, criteria.List().Count); + } + + using (ISession session = this.OpenSession()) + { + session.Delete(john); + session.Flush(); + } + } + + [Test] + public void LikeProjectionUsingRestrictionsTest() + { + using (ISession session = this.OpenSession()) + { + ICriteria criteria = session.CreateCriteria(typeof(Student), "c"); + + criteria.Add(Restrictions.Like(Projections.Constant("Name"), "John", MatchMode.Anywhere)); + + criteria.List(); + } + } + + [Test] + public void InsensitiveLikeProjectionUsingRestrictionsTest() + { + using (ISession session = this.OpenSession()) + { + ICriteria criteria = session.CreateCriteria(typeof(Student), "c"); + + criteria.Add(Restrictions.InsensitiveLike(Projections.Constant("Name"), "John", MatchMode.Anywhere)); + + criteria.List(); + } + } } -} +} \ 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: <aye...@us...> - 2008-10-04 19:09:38
|
Revision: 3812 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3812&view=rev Author: ayenderahien Date: 2008-10-04 19:09:32 +0000 (Sat, 04 Oct 2008) Log Message: ----------- reverting r3798 - doesn't actually work Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Driver/SqlServerCeDriver.cs Modified: trunk/nhibernate/src/NHibernate/Driver/SqlServerCeDriver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Driver/SqlServerCeDriver.cs 2008-10-03 21:13:49 UTC (rev 3811) +++ trunk/nhibernate/src/NHibernate/Driver/SqlServerCeDriver.cs 2008-10-04 19:09:32 UTC (rev 3812) @@ -24,18 +24,11 @@ } private bool prepareSql; - private System.Reflection.PropertyInfo dbParamSqlDbTypeProperty; public override void Configure(IDictionary<string, string> settings) { base.Configure(settings); prepareSql = PropertiesHelper.GetBoolean(Environment.PrepareSql, settings, false); - - using (IDbCommand dbCmd = base.CreateCommand()) - { - IDbDataParameter dbParam = dbCmd.CreateParameter(); - dbParamSqlDbTypeProperty = dbParam.GetType().GetProperty( "SqlDbType" ); - } } /// <summary> @@ -101,24 +94,5 @@ { get { return true; } } - - protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) - { - base.InitializeParameter(dbParam, name, sqlType); - - AdjustDbParamTypeForLargeObjects( dbParam, sqlType ); - } - - private void AdjustDbParamTypeForLargeObjects(IDbDataParameter dbParam, SqlType sqlType) - { - if (sqlType is BinarySqlType) - { - dbParamSqlDbTypeProperty.SetValue(dbParam, SqlDbType.Image, null); - } - else if (sqlType is StringSqlType) - { - dbParamSqlDbTypeProperty.SetValue(dbParam, SqlDbType.NText, 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: <te...@us...> - 2008-10-03 21:13:55
|
Revision: 3811 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3811&view=rev Author: tehlike Date: 2008-10-03 21:13:49 +0000 (Fri, 03 Oct 2008) Log Message: ----------- Added throw NotSupportedException statement when ISQLQuery is added. This fix doesn't solve the issue NH-1508, just temporarily let the user know about situation. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Document.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Person.cs Modified: trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2008-10-03 21:11:48 UTC (rev 3810) +++ trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2008-10-03 21:13:49 UTC (rev 3811) @@ -797,12 +797,17 @@ private int AddQueryForLaterExecutionAndReturnIndexOfQuery(IQuery query) { + ThrowNotSupportedIfSqlQuery(query); ((AbstractQueryImpl)query).SetIgnoreUknownNamedParameters(true); queries.Add(query); return queries.Count - 1; } + protected void ThrowNotSupportedIfSqlQuery(IQuery query) + { + if (query is ISQLQuery) + throw new NotSupportedException("Sql queries in MultiQuery are currently not supported."); + } - #endregion } } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Document.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Document.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Document.cs 2008-10-03 21:13:49 UTC (rev 3811) @@ -0,0 +1,27 @@ +namespace NHibernate.Test.NHSpecificTest.NH1508 +{ + public class Document + { + private int id; + private Person person; + private string title; + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + public virtual string Title + { + get { return title; } + set { title = value; } + } + + public virtual Person Person + { + get { return person; } + set { person = value; } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs 2008-10-03 21:13:49 UTC (rev 3811) @@ -0,0 +1,92 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +using NHibernate.Criterion; + +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1508 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override void OnSetUp() + { + Person john = new Person(); + john.Name = "John"; + + Document doc1 = new Document(); + doc1.Person = john; + doc1.Title = "John's Doc"; + + Document doc2 = new Document(); + doc2.Title = "Spec"; + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + session.Save(john); + session.Save(doc1); + session.Save(doc2); + + tx.Commit(); + } + } + + protected override void OnTearDown() + { + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + session.Delete("from Person"); + session.Delete("from Document"); + tx.Commit(); + } + } + + [Test] + public void DoesntThrowExceptionWhenHqlQueryIsGiven() + { + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + IQuery sqlQuery = session.CreateQuery("from Document"); + IMultiQuery q = session + .CreateMultiQuery() + .Add(sqlQuery); + q.List(); + } + } + + [Test] + [ExpectedException(typeof(NotSupportedException))] + public void ThrowsExceptionWhenSqlQueryIsGiven() + { + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + ISQLQuery sqlQuery = session.CreateSQLQuery("select * from Document"); + IMultiQuery q = session + .CreateMultiQuery() + .Add(sqlQuery); + q.List(); + } + } + + [Test] + [ExpectedException(typeof(NotSupportedException))] + public void ThrowsExceptionWhenNamedSqlQueryIsGiven() + { + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + + IMultiQuery q = session + .CreateMultiQuery() + .AddNamedQuery("SampleSqlQuery"); + q.List(); + } + } + + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Mappings.hbm.xml 2008-10-03 21:13:49 UTC (rev 3811) @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1508"> + + <class name="Document"> + <id name="Id"> + <generator class="native"/> + </id> + <many-to-one name="Person" column="PersonID"/> + <property name="Title"/> + </class> + + <class name="Person"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name"/> + </class> + <sql-query name="SampleSqlQuery"> + <![CDATA[ + SELECT PersonId from Document + ]]> + </sql-query> + <query name="SampleHqlQuery"> + <![CDATA[ + from Document + ]]> + </query> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Person.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Person.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Person.cs 2008-10-03 21:13:49 UTC (rev 3811) @@ -0,0 +1,20 @@ +namespace NHibernate.Test.NHSpecificTest.NH1508 +{ + public class Person + { + private int id; + private string name; + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-03 21:11:48 UTC (rev 3810) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-10-03 21:13:49 UTC (rev 3811) @@ -495,6 +495,9 @@ <Compile Include="NHSpecificTest\NH1499\Person.cs" /> <Compile Include="NHSpecificTest\NH1502\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1502\Person.cs" /> + <Compile Include="NHSpecificTest\NH1508\Document.cs" /> + <Compile Include="NHSpecificTest\NH1508\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1508\Person.cs" /> <Compile Include="NHSpecificTest\NH280\Fixture.cs" /> <Compile Include="NHSpecificTest\NH280\Foo.cs" /> <Compile Include="NHSpecificTest\NH1018\Employee.cs" /> @@ -1481,6 +1484,7 @@ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1508\Mappings.hbm.xml" /> <EmbeddedResource Include="GenericTest\OrderedSetGeneric\OrderedSetFixture.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1293\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1490\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2008-10-03 21:11:54
|
Revision: 3810 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3810&view=rev Author: tehlike Date: 2008-10-03 21:11:48 +0000 (Fri, 03 Oct 2008) Log Message: ----------- Added throw NotSupportedException statement when ISQLQuery is added. This fix doesn't solve the issue NH-1508, just temporarily let the user know about situation. Modified Paths: -------------- branches/2.0.x/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj Added Paths: ----------- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Document.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Mappings.hbm.xml branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Person.cs Modified: branches/2.0.x/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2008-10-03 14:57:14 UTC (rev 3809) +++ branches/2.0.x/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2008-10-03 21:11:48 UTC (rev 3810) @@ -291,7 +291,8 @@ public IMultiQuery Add(IQuery query) { - ((AbstractQueryImpl)query).SetIgnoreUknownNamedParameters(true); + ThrowNotSupportedIfSqlQuery(query); + ((AbstractQueryImpl) query).SetIgnoreUknownNamedParameters(true); queries.Add(query); return this; } @@ -523,20 +524,28 @@ sqlString = new SqlString(); foreach (AbstractQueryImpl query in queries) { - QueryParameters queryParameters = query.GetQueryParameters(); - queryParameters.ValidateParameters(); - query.VerifyParameters(); - IQueryTranslator[] queryTranslators = - session.GetQueries(query.ExpandParameterLists(queryParameters.NamedParameters), false); - foreach (QueryTranslator translator in queryTranslators) + if (query is ISQLQuery) { - translators.Add(translator); - parameters.Add(queryParameters); - queryParameters = GetFilteredQueryParameters(queryParameters, translator); - SqlCommandInfo commandInfo = translator.GetQueryStringAndTypes(session, queryParameters); - sqlString = sqlString.Append(commandInfo.Text).Append(dialect.MultipleQueriesSeparator).Append(Environment.NewLine); - types.AddRange(commandInfo.ParameterTypes); + } + else + { + QueryParameters queryParameters = query.GetQueryParameters(); + queryParameters.ValidateParameters(); + query.VerifyParameters(); + IQueryTranslator[] queryTranslators = + session.GetQueries(query.ExpandParameterLists(queryParameters.NamedParameters), false); + foreach (QueryTranslator translator in queryTranslators) + { + translators.Add(translator); + parameters.Add(queryParameters); + queryParameters = GetFilteredQueryParameters(queryParameters, translator); + SqlCommandInfo commandInfo = translator.GetQueryStringAndTypes(session, queryParameters); + sqlString = sqlString.Append(commandInfo.Text).Append(dialect.MultipleQueriesSeparator).Append(Environment.NewLine); + types.AddRange(commandInfo.ParameterTypes); + } + } + } } @@ -733,7 +742,11 @@ } return false; } - + protected void ThrowNotSupportedIfSqlQuery(IQuery query) + { + if (query is ISQLQuery) + throw new NotSupportedException("Sql queries in MultiQuery is currently not supported."); + } #endregion } } Copied: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Document.cs (from rev 3807, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1499/Document.cs) =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Document.cs (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Document.cs 2008-10-03 21:11:48 UTC (rev 3810) @@ -0,0 +1,27 @@ +namespace NHibernate.Test.NHSpecificTest.NH1508 +{ + public class Document + { + private int id; + private Person person; + private string title; + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + public virtual string Title + { + get { return title; } + set { title = value; } + } + + public virtual Person Person + { + get { return person; } + set { person = value; } + } + } +} Property changes on: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Document.cs ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs (from rev 3807, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1499/Fixture.cs) =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs 2008-10-03 21:11:48 UTC (rev 3810) @@ -0,0 +1,92 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +using NHibernate.Criterion; + +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1508 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override void OnSetUp() + { + Person john = new Person(); + john.Name = "John"; + + Document doc1 = new Document(); + doc1.Person = john; + doc1.Title = "John's Doc"; + + Document doc2 = new Document(); + doc2.Title = "Spec"; + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + session.Save(john); + session.Save(doc1); + session.Save(doc2); + + tx.Commit(); + } + } + + protected override void OnTearDown() + { + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + session.Delete("from Person"); + session.Delete("from Document"); + tx.Commit(); + } + } + + [Test] + public void DoesntThrowExceptionWhenHqlQueryIsGiven() + { + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + IQuery sqlQuery = session.CreateQuery("from Document"); + IMultiQuery q = session + .CreateMultiQuery() + .Add(sqlQuery); + q.List(); + } + } + + [Test] + [ExpectedException(typeof(NotSupportedException))] + public void ThrowsExceptionWhenSqlQueryIsGiven() + { + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + ISQLQuery sqlQuery = session.CreateSQLQuery("select * from Document"); + IMultiQuery q = session + .CreateMultiQuery() + .Add(sqlQuery); + q.List(); + } + } + + [Test] + [ExpectedException(typeof(NotSupportedException))] + public void ThrowsExceptionWhenNamedSqlQueryIsGiven() + { + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + + IMultiQuery q = session + .CreateMultiQuery() + .AddNamedQuery("SampleSqlQuery"); + q.List(); + } + } + + } +} Property changes on: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Fixture.cs ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Mappings.hbm.xml (from rev 3807, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1499/Mappings.hbm.xml) =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Mappings.hbm.xml (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Mappings.hbm.xml 2008-10-03 21:11:48 UTC (rev 3810) @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1508"> + + <class name="Document"> + <id name="Id"> + <generator class="native"/> + </id> + <many-to-one name="Person" column="PersonID"/> + <property name="Title"/> + </class> + + <class name="Person"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name"/> + </class> + <sql-query name="SampleSqlQuery"> + <![CDATA[ + SELECT PersonId from Document + ]]> + </sql-query> + <query name="SampleHqlQuery"> + <![CDATA[ + from Document + ]]> + </query> +</hibernate-mapping> Property changes on: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Mappings.hbm.xml ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Person.cs (from rev 3807, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1499/Person.cs) =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Person.cs (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Person.cs 2008-10-03 21:11:48 UTC (rev 3810) @@ -0,0 +1,20 @@ +namespace NHibernate.Test.NHSpecificTest.NH1508 +{ + public class Person + { + private int id; + private string name; + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + } +} Property changes on: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1508/Person.cs ___________________________________________________________________ Added: svn:mergeinfo + Modified: branches/2.0.x/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-10-03 14:57:14 UTC (rev 3809) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-10-03 21:11:48 UTC (rev 3810) @@ -383,6 +383,9 @@ <Compile Include="NHSpecificTest\NH1499\Document.cs" /> <Compile Include="NHSpecificTest\NH1499\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1499\Person.cs" /> + <Compile Include="NHSpecificTest\NH1508\Document.cs" /> + <Compile Include="NHSpecificTest\NH1508\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1508\Person.cs" /> <Compile Include="NHSpecificTest\NH280\Fixture.cs" /> <Compile Include="NHSpecificTest\NH280\Foo.cs" /> <Compile Include="NHSpecificTest\NH1018\Employee.cs" /> @@ -1357,6 +1360,9 @@ <EmbeddedResource Include="NHSpecificTest\NH1293\Mappings.hbm.xml" /> </ItemGroup> <ItemGroup> + <EmbeddedResource Include="NHSpecificTest\NH1508\Mappings.hbm.xml" /> + </ItemGroup> + <ItemGroup> <Folder Include="Properties\" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2008-10-03 14:57:20
|
Revision: 3809 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3809&view=rev Author: tehlike Date: 2008-10-03 14:57:14 +0000 (Fri, 03 Oct 2008) Log Message: ----------- Spelling correction (Fix 1511) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Mapping/Property.cs trunk/nhibernate/src/NHibernate/Properties/BackrefPropertyAccessor.cs trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs trunk/nhibernate/src/NHibernate/Properties/ChainedPropertyAccessor.cs trunk/nhibernate/src/NHibernate/Properties/EmbeddedPropertyAccessor.cs trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs trunk/nhibernate/src/NHibernate/Properties/IPropertyAccessor.cs trunk/nhibernate/src/NHibernate/Properties/IndexPropertyAccessor.cs trunk/nhibernate/src/NHibernate/Properties/MapAccessor.cs trunk/nhibernate/src/NHibernate/Properties/NoSetterAccessor.cs trunk/nhibernate/src/NHibernate/Properties/NoopAccessor.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH251/CustomAccessDO.cs Modified: trunk/nhibernate/src/NHibernate/Mapping/Property.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2008-10-03 14:50:43 UTC (rev 3808) +++ trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2008-10-03 14:57:14 UTC (rev 3809) @@ -189,8 +189,8 @@ public virtual bool IsBasicPropertyAccessor { - // NH Different behavior : see IPropertyAccessor.CanAccessTroughReflectionOptimizer (ref. NH-1304) - get { return PropertyAccessor.CanAccessTroughReflectionOptimizer; } + // NH Different behavior : see IPropertyAccessor.CanAccessThroughReflectionOptimizer (ref. NH-1304) + get { return PropertyAccessor.CanAccessThroughReflectionOptimizer; } } public IDictionary<string, MetaAttribute> MetaAttributes Modified: trunk/nhibernate/src/NHibernate/Properties/BackrefPropertyAccessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Properties/BackrefPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) +++ trunk/nhibernate/src/NHibernate/Properties/BackrefPropertyAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809) @@ -30,7 +30,7 @@ return new BackrefSetter(); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } Modified: trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) +++ trunk/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809) @@ -60,7 +60,7 @@ return result; } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return true; } } Modified: trunk/nhibernate/src/NHibernate/Properties/ChainedPropertyAccessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Properties/ChainedPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) +++ trunk/nhibernate/src/NHibernate/Properties/ChainedPropertyAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809) @@ -48,7 +48,7 @@ throw new PropertyNotFoundException(theClass, propertyName, "setter"); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } Modified: trunk/nhibernate/src/NHibernate/Properties/EmbeddedPropertyAccessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Properties/EmbeddedPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) +++ trunk/nhibernate/src/NHibernate/Properties/EmbeddedPropertyAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809) @@ -19,7 +19,7 @@ return new EmbeddedSetter(theClass); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } Modified: trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) +++ trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809) @@ -86,7 +86,7 @@ return new FieldSetter(GetField(theClass, fieldName), theClass, fieldName); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return true; } } Modified: trunk/nhibernate/src/NHibernate/Properties/IPropertyAccessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Properties/IPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) +++ trunk/nhibernate/src/NHibernate/Properties/IPropertyAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809) @@ -39,7 +39,7 @@ /// <summary> /// Allow embedded and custom accessors to define if the ReflectionOptimizer can be used. /// </summary> - bool CanAccessTroughReflectionOptimizer { get;} + bool CanAccessThroughReflectionOptimizer { get;} #endregion } } Modified: trunk/nhibernate/src/NHibernate/Properties/IndexPropertyAccessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Properties/IndexPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) +++ trunk/nhibernate/src/NHibernate/Properties/IndexPropertyAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809) @@ -32,7 +32,7 @@ throw new NotImplementedException(); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } Modified: trunk/nhibernate/src/NHibernate/Properties/MapAccessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Properties/MapAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) +++ trunk/nhibernate/src/NHibernate/Properties/MapAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809) @@ -18,7 +18,7 @@ return new MapSetter(propertyName); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } Modified: trunk/nhibernate/src/NHibernate/Properties/NoSetterAccessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Properties/NoSetterAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) +++ trunk/nhibernate/src/NHibernate/Properties/NoSetterAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809) @@ -66,7 +66,7 @@ return new FieldAccessor.FieldSetter(FieldAccessor.GetField(type, fieldName), type, fieldName); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return true; } } Modified: trunk/nhibernate/src/NHibernate/Properties/NoopAccessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Properties/NoopAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) +++ trunk/nhibernate/src/NHibernate/Properties/NoopAccessor.cs 2008-10-03 14:57:14 UTC (rev 3809) @@ -19,7 +19,7 @@ return new NoopSetter(); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH251/CustomAccessDO.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH251/CustomAccessDO.cs 2008-10-03 14:50:43 UTC (rev 3808) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH251/CustomAccessDO.cs 2008-10-03 14:57:14 UTC (rev 3809) @@ -53,7 +53,7 @@ return new CustomSetter(propertyName); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2008-10-03 14:50:53
|
Revision: 3808 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3808&view=rev Author: tehlike Date: 2008-10-03 14:50:43 +0000 (Fri, 03 Oct 2008) Log Message: ----------- Spelling correction(fix 1511) Modified Paths: -------------- branches/2.0.x/nhibernate/src/NHibernate/Mapping/Property.cs branches/2.0.x/nhibernate/src/NHibernate/Properties/BackrefPropertyAccessor.cs branches/2.0.x/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs branches/2.0.x/nhibernate/src/NHibernate/Properties/ChainedPropertyAccessor.cs branches/2.0.x/nhibernate/src/NHibernate/Properties/EmbeddedPropertyAccessor.cs branches/2.0.x/nhibernate/src/NHibernate/Properties/FieldAccessor.cs branches/2.0.x/nhibernate/src/NHibernate/Properties/IPropertyAccessor.cs branches/2.0.x/nhibernate/src/NHibernate/Properties/IndexPropertyAccessor.cs branches/2.0.x/nhibernate/src/NHibernate/Properties/MapAccessor.cs branches/2.0.x/nhibernate/src/NHibernate/Properties/NoSetterAccessor.cs branches/2.0.x/nhibernate/src/NHibernate/Properties/NoopAccessor.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH251/CustomAccessDO.cs Modified: branches/2.0.x/nhibernate/src/NHibernate/Mapping/Property.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Mapping/Property.cs 2008-09-29 22:46:17 UTC (rev 3807) +++ branches/2.0.x/nhibernate/src/NHibernate/Mapping/Property.cs 2008-10-03 14:50:43 UTC (rev 3808) @@ -189,8 +189,8 @@ public virtual bool IsBasicPropertyAccessor { - // NH Different behavior : see IPropertyAccessor.CanAccessTroughReflectionOptimizer (ref. NH-1304) - get { return PropertyAccessor.CanAccessTroughReflectionOptimizer; } + // NH Different behavior : see IPropertyAccessor.CanAccessThroughReflectionOptimizer (ref. NH-1304) + get { return PropertyAccessor.CanAccessThroughReflectionOptimizer; } } public IDictionary<string, MetaAttribute> MetaAttributes Modified: branches/2.0.x/nhibernate/src/NHibernate/Properties/BackrefPropertyAccessor.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Properties/BackrefPropertyAccessor.cs 2008-09-29 22:46:17 UTC (rev 3807) +++ branches/2.0.x/nhibernate/src/NHibernate/Properties/BackrefPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) @@ -30,7 +30,7 @@ return new BackrefSetter(); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } Modified: branches/2.0.x/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs 2008-09-29 22:46:17 UTC (rev 3807) +++ branches/2.0.x/nhibernate/src/NHibernate/Properties/BasicPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) @@ -60,7 +60,7 @@ return result; } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return true; } } Modified: branches/2.0.x/nhibernate/src/NHibernate/Properties/ChainedPropertyAccessor.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Properties/ChainedPropertyAccessor.cs 2008-09-29 22:46:17 UTC (rev 3807) +++ branches/2.0.x/nhibernate/src/NHibernate/Properties/ChainedPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) @@ -48,7 +48,7 @@ throw new PropertyNotFoundException(theClass, propertyName, "setter"); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } Modified: branches/2.0.x/nhibernate/src/NHibernate/Properties/EmbeddedPropertyAccessor.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Properties/EmbeddedPropertyAccessor.cs 2008-09-29 22:46:17 UTC (rev 3807) +++ branches/2.0.x/nhibernate/src/NHibernate/Properties/EmbeddedPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) @@ -19,7 +19,7 @@ return new EmbeddedSetter(theClass); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } Modified: branches/2.0.x/nhibernate/src/NHibernate/Properties/FieldAccessor.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Properties/FieldAccessor.cs 2008-09-29 22:46:17 UTC (rev 3807) +++ branches/2.0.x/nhibernate/src/NHibernate/Properties/FieldAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) @@ -86,7 +86,7 @@ return new FieldSetter(GetField(theClass, fieldName), theClass, fieldName); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return true; } } Modified: branches/2.0.x/nhibernate/src/NHibernate/Properties/IPropertyAccessor.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Properties/IPropertyAccessor.cs 2008-09-29 22:46:17 UTC (rev 3807) +++ branches/2.0.x/nhibernate/src/NHibernate/Properties/IPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) @@ -39,7 +39,7 @@ /// <summary> /// Allow embedded and custom accessors to define if the ReflectionOptimizer can be used. /// </summary> - bool CanAccessTroughReflectionOptimizer { get;} + bool CanAccessThroughReflectionOptimizer { get;} #endregion } } \ No newline at end of file Modified: branches/2.0.x/nhibernate/src/NHibernate/Properties/IndexPropertyAccessor.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Properties/IndexPropertyAccessor.cs 2008-09-29 22:46:17 UTC (rev 3807) +++ branches/2.0.x/nhibernate/src/NHibernate/Properties/IndexPropertyAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) @@ -32,7 +32,7 @@ throw new NotImplementedException(); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } Modified: branches/2.0.x/nhibernate/src/NHibernate/Properties/MapAccessor.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Properties/MapAccessor.cs 2008-09-29 22:46:17 UTC (rev 3807) +++ branches/2.0.x/nhibernate/src/NHibernate/Properties/MapAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) @@ -18,7 +18,7 @@ return new MapSetter(propertyName); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } Modified: branches/2.0.x/nhibernate/src/NHibernate/Properties/NoSetterAccessor.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Properties/NoSetterAccessor.cs 2008-09-29 22:46:17 UTC (rev 3807) +++ branches/2.0.x/nhibernate/src/NHibernate/Properties/NoSetterAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) @@ -66,7 +66,7 @@ return new FieldAccessor.FieldSetter(FieldAccessor.GetField(type, fieldName), type, fieldName); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return true; } } Modified: branches/2.0.x/nhibernate/src/NHibernate/Properties/NoopAccessor.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Properties/NoopAccessor.cs 2008-09-29 22:46:17 UTC (rev 3807) +++ branches/2.0.x/nhibernate/src/NHibernate/Properties/NoopAccessor.cs 2008-10-03 14:50:43 UTC (rev 3808) @@ -19,7 +19,7 @@ return new NoopSetter(); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } Modified: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH251/CustomAccessDO.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH251/CustomAccessDO.cs 2008-09-29 22:46:17 UTC (rev 3807) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH251/CustomAccessDO.cs 2008-10-03 14:50:43 UTC (rev 3808) @@ -51,7 +51,7 @@ return new CustomSetter(propertyName); } - public bool CanAccessTroughReflectionOptimizer + public bool CanAccessThroughReflectionOptimizer { get { return false; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-09-29 22:46:41
|
Revision: 3807 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3807&view=rev Author: fabiomaulo Date: 2008-09-29 22:46:17 +0000 (Mon, 29 Sep 2008) Log Message: ----------- Fix NH-1173 new feature Generic Ordered Set support (by Sean Carpenter) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Mapping/Set.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Type/GenericOrderedSetType.cs trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/ trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/A.cs trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/B.cs trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.cs trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Mapping/Set.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/Set.cs 2008-09-29 22:14:24 UTC (rev 3806) +++ trunk/nhibernate/src/NHibernate/Mapping/Set.cs 2008-09-29 22:46:17 UTC (rev 3807) @@ -34,8 +34,7 @@ } else if (HasOrder) { - throw new MappingException( - "Cannot use order-by with generic set, no appropriate collection implementation is available"); + return TypeFactory.GenericOrderedSet(Role, ReferencedPropertyName, this.GenericArguments[0]); } else { Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-09-29 22:14:24 UTC (rev 3806) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-09-29 22:46:17 UTC (rev 3807) @@ -1062,6 +1062,7 @@ <Compile Include="Type\CollectionType.cs" /> <Compile Include="Type\CustomCollectionType.cs" /> <Compile Include="Type\EmbeddedComponentType.cs" /> + <Compile Include="Type\GenericOrderedSetType.cs" /> <Compile Include="Type\ICacheAssembler.cs" /> <Compile Include="Type\OrderedSetType.cs" /> <Compile Include="Type\OrderedMapType.cs" /> Added: trunk/nhibernate/src/NHibernate/Type/GenericOrderedSetType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/GenericOrderedSetType.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Type/GenericOrderedSetType.cs 2008-09-29 22:46:17 UTC (rev 3807) @@ -0,0 +1,31 @@ +using System; +using Iesi.Collections.Generic; + +namespace NHibernate.Type +{ + /// <summary> + /// An <see cref="IType"/> that maps a sorted <see cref="ISet{T}"/> collection + /// to the database. + /// </summary> + [Serializable] + public class GenericOrderedSetType<T> : GenericSetType<T> + { + /// <summary> + /// Initializes a new instance of a <see cref="GenericOrderedSetType{T}"/> class for + /// a specific role. + /// </summary> + /// <param name="role">The role the persistent collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + public GenericOrderedSetType(string role, string propertyRef) + : base(role, propertyRef) + { + } + + public override object Instantiate(int anticipatedSize) + { + return new OrderedSet<T>(); + } + } +} Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2008-09-29 22:14:24 UTC (rev 3806) +++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2008-09-29 22:46:17 UTC (rev 3807) @@ -33,8 +33,8 @@ PrecisionScale } - private static readonly char[] precisionScaleSplit = new char[] {'(', ')', ','}; - private static readonly char[] lengthSplit = new char[] {'(', ')'}; + private static readonly char[] precisionScaleSplit = new char[] { '(', ')', ',' }; + private static readonly char[] lengthSplit = new char[] { '(', ')' }; /* * Maps the string representation of the type to the IType. The string @@ -59,7 +59,7 @@ private static readonly IDictionary<string, IType> typeByTypeOfName = new ThreadSafeDictionary<string, IType>(new Dictionary<string, IType>()); - private static readonly IDictionary<string, GetNullableTypeWithLength> getTypeDelegatesWithLength = + private static readonly IDictionary<string, GetNullableTypeWithLength> getTypeDelegatesWithLength = new ThreadSafeDictionary<string, GetNullableTypeWithLength>(new Dictionary<string, GetNullableTypeWithLength>()); private static readonly IDictionary<string, GetNullableTypeWithPrecision> getTypeDelegatesWithPrecision = @@ -241,7 +241,7 @@ // Use the basic name (such as String or String(255)) to get the // instance of the IType object. IType returnType; - if (typeByTypeOfName.TryGetValue(name,out returnType)) + if (typeByTypeOfName.TryGetValue(name, out returnType)) { return returnType; } @@ -259,7 +259,7 @@ if (parsedName.Length < 4) { throw new ArgumentOutOfRangeException("TypeClassification.PrecisionScale", name, - "It is not a valid Precision/Scale name"); + "It is not a valid Precision/Scale name"); } typeName = parsedName[0].Trim(); @@ -372,8 +372,8 @@ { parsedTypeName = typeName.Split(lengthSplit); } - else - parsedTypeName = typeClassification == TypeClassification.PrecisionScale ? typeName.Split(precisionScaleSplit) : new string[] {typeName}; + else + parsedTypeName = typeClassification == TypeClassification.PrecisionScale ? typeName.Split(precisionScaleSplit) : new string[] { typeName }; System.Type typeClass; @@ -392,7 +392,7 @@ { try { - type = (IType) Activator.CreateInstance(typeClass); + type = (IType)Activator.CreateInstance(typeClass); } catch (Exception e) { @@ -439,11 +439,11 @@ private static Boolean IsNullableEnum(System.Type typeClass) { if (!typeClass.IsGenericType) return false; - System.Type nullable = typeof (Nullable<>); + System.Type nullable = typeof(Nullable<>); if (!nullable.Equals(typeClass.GetGenericTypeDefinition())) return false; System.Type genericClass = typeClass.GetGenericArguments()[0]; - return genericClass.IsSubclassOf(typeof (Enum)); + return genericClass.IsSubclassOf(typeof(Enum)); } @@ -604,12 +604,12 @@ /// <summary> /// A one-to-one association type for the given class and cascade style. /// </summary> - public static EntityType OneToOne(string persistentClass, ForeignKeyDirection foreignKeyType, string uniqueKeyPropertyName, + public static EntityType OneToOne(string persistentClass, ForeignKeyDirection foreignKeyType, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, bool isEmbeddedInXML, string entityName, string propertyName) { return new OneToOneType(persistentClass, foreignKeyType, uniqueKeyPropertyName, lazy, unwrapProxy, isEmbeddedInXML, - entityName, propertyName); + entityName, propertyName); } /// <summary> @@ -633,7 +633,7 @@ /// <summary> /// A many-to-one association type for the given class and cascade style. /// </summary> - public static EntityType ManyToOne(string persistentClass, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, + public static EntityType ManyToOne(string persistentClass, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, bool isEmbeddedInXML, bool ignoreNotFound) { return new ManyToOneType(persistentClass, uniqueKeyPropertyName, lazy, unwrapProxy, isEmbeddedInXML, ignoreNotFound); @@ -796,15 +796,17 @@ return new OrderedSetType(role, propertyRef, embedded); } + + private static CollectionType CreateCollectionType( System.Type genericCollectionType, string role, string propertyRef, params System.Type[] typeArguments) { - return (CollectionType) Activator.CreateInstance( - genericCollectionType.MakeGenericType(typeArguments), - role, propertyRef); + return (CollectionType)Activator.CreateInstance( + genericCollectionType.MakeGenericType(typeArguments), + role, propertyRef); } private static CollectionType CreateSortedCollectionType( @@ -814,11 +816,20 @@ object comparer, params System.Type[] typeArguments) { - return (CollectionType) Activator.CreateInstance( - genericCollectionType.MakeGenericType(typeArguments), - role, propertyRef, comparer); + return (CollectionType)Activator.CreateInstance( + genericCollectionType.MakeGenericType(typeArguments), + role, propertyRef, comparer); } + private static CollectionType CreateOrderedCollectionType(System.Type genericCollectionType, + string role, + string propertyRef, + params System.Type[] typeArguments) + { + return + (CollectionType)Activator.CreateInstance(genericCollectionType.MakeGenericType(typeArguments), role, propertyRef); + } + /// <summary> /// Creates a new <see cref="CollectionType"/> for an /// <see cref="System.Collections.Generic.IList{T}"/> with bag semantics. @@ -901,24 +912,24 @@ /// A <see cref="MapType"/> for the specified role. /// </returns> public static CollectionType GenericMap(string role, string propertyRef, System.Type indexClass, - System.Type elementClass) + System.Type elementClass) { return CreateCollectionType(typeof(GenericMapType<,>), role, propertyRef, indexClass, elementClass); } public static CollectionType GenericSortedList(string role, string propertyRef, object comparer, - System.Type indexClass, System.Type elementClass) + System.Type indexClass, System.Type elementClass) { return CreateSortedCollectionType(typeof(GenericSortedListType<,>), role, propertyRef, comparer, indexClass, elementClass); } public static CollectionType GenericSortedDictionary(string role, string propertyRef, object comparer, - System.Type indexClass, System.Type elementClass) + System.Type indexClass, System.Type elementClass) { return CreateSortedCollectionType(typeof(GenericSortedDictionaryType<,>), role, propertyRef, comparer, indexClass, - elementClass); + elementClass); } /// <summary> @@ -946,11 +957,26 @@ /// <param name="elementType">The type of the elements in the set.</param> /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> public static CollectionType GenericSortedSet(string role, string propertyRef, object comparer, - System.Type elementType) + System.Type elementType) { return CreateSortedCollectionType(typeof(GenericSortedSetType<>), role, propertyRef, comparer, elementType); } + /// <summary> + /// Creates a new <see cref="CollectionType"/> for an ordered <see cref="Iesi.Collections.Generic.ISet{T}" />. + /// </summary> + /// <param name="role">The role the collection is in.</param> + /// <param name="propertyRef">The name of the property in the + /// owner object containing the collection ID, or <see langword="null" /> if it is + /// the primary key.</param> + /// <param name="elementType">The type of the elements in the set.</param> + /// <returns>A <see cref="GenericSetType{T}" /> for the specified role.</returns> + public static CollectionType GenericOrderedSet(string role, string propertyRef, + System.Type elementType) + { + return CreateOrderedCollectionType(typeof(GenericOrderedSetType<>), role, propertyRef, elementType); + } + /// <summary> Deep copy a series of values from one array to another... </summary> /// <param name="values">The values to copy (the source) </param> /// <param name="types">The value types </param> @@ -1137,7 +1163,7 @@ /// <param name="copiedAlready">Represent a cache of already replaced state </param> /// <returns> The replaced state </returns> public static object[] Replace(object[] original, object[] target, IType[] types, ISessionImplementor session, - object owner, IDictionary copiedAlready) + object owner, IDictionary copiedAlready) { object[] copied = new object[original.Length]; for (int i = 0; i < original.Length; i++) @@ -1159,7 +1185,7 @@ /// <param name="copyCache">A map representing a cache of already replaced state </param> /// <param name="foreignKeyDirection">FK directionality to be applied to the replacement </param> /// <returns> The replaced state </returns> - public static object[] Replace(object[] original, object[] target, IType[] types, + public static object[] Replace(object[] original, object[] target, IType[] types, ISessionImplementor session, object owner, IDictionary copyCache, ForeignKeyDirection foreignKeyDirection) { object[] copied = new object[original.Length]; @@ -1192,7 +1218,7 @@ /// If the corresponding type is a component type, then apply <see cref="ReplaceAssociations"/> /// across the component subtypes but do not replace the component value itself. /// </remarks> - public static object[] ReplaceAssociations(object[] original, object[] target, IType[] types, + public static object[] ReplaceAssociations(object[] original, object[] target, IType[] types, ISessionImplementor session, object owner, IDictionary copyCache, ForeignKeyDirection foreignKeyDirection) { object[] copied = new object[original.Length]; @@ -1205,14 +1231,14 @@ else if (types[i].IsComponentType) { // need to extract the component values and check for subtype replacements... - IAbstractComponentType componentType = (IAbstractComponentType) types[i]; + IAbstractComponentType componentType = (IAbstractComponentType)types[i]; IType[] subtypes = componentType.Subtypes; object[] origComponentValues = original[i] == null - ? new object[subtypes.Length] - : componentType.GetPropertyValues(original[i], session); + ? new object[subtypes.Length] + : componentType.GetPropertyValues(original[i], session); object[] targetComponentValues = componentType.GetPropertyValues(target[i], session); ReplaceAssociations(origComponentValues, targetComponentValues, subtypes, session, null, copyCache, - foreignKeyDirection); + foreignKeyDirection); copied[i] = target[i]; } else if (!types[i].IsAssociationType) @@ -1242,7 +1268,7 @@ CustomCollectionType result = new CustomCollectionType(typeClass, role, propertyRef, embedded); if (typeParameters != null) { - InjectParameters(result.UserType, (IDictionary) typeParameters); + InjectParameters(result.UserType, (IDictionary)typeParameters); } return result; } @@ -1251,7 +1277,7 @@ { if (type is IParameterizedType) { - ((IParameterizedType) type).SetParameterValues(parameters); + ((IParameterizedType)type).SetParameterValues(parameters); } else if (parameters != null && !(parameters.Count == 0)) { Added: trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/A.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/A.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/A.cs 2008-09-29 22:46:17 UTC (rev 3807) @@ -0,0 +1,19 @@ +using Iesi.Collections.Generic; + +namespace NHibernate.Test.GenericTest.OrderedSetGeneric +{ + public class A + { + private ISet<B> _items = new OrderedSet<B>(); + + public int Id { get; set; } + + public string Name { get; set; } + + public virtual ISet<B> Items + { + get { return _items; } + set { _items = value; } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/B.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/B.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/B.cs 2008-09-29 22:46:17 UTC (rev 3807) @@ -0,0 +1,13 @@ +namespace NHibernate.Test.GenericTest.OrderedSetGeneric +{ + public class B + { + public virtual int Id { get; set; } + + public virtual int OrderBy { get; set; } + + public virtual string Name { get; set; } + + public virtual int AId { get; set; } + } +} Property changes on: trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/B.cs ___________________________________________________________________ Added: svn:mergeinfo + Added: trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.cs 2008-09-29 22:46:17 UTC (rev 3807) @@ -0,0 +1,64 @@ +using System.Collections; +using NUnit.Framework; + +namespace NHibernate.Test.GenericTest.OrderedSetGeneric +{ + [TestFixture] + public class OrderedSetFixture : TestCase + { + protected override IList Mappings + { + get { return new[] {"GenericTest.OrderedSetGeneric.OrderedSetFixture.hbm.xml"}; } + } + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override void OnTearDown() + { + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from B"); + s.Delete("from A"); + tx.Commit(); + } + } + } + + [Test] + public void OrderedSetIsInOrder() + { + var names = new[] {"First B", "Second B"}; + const int TheId = 100; + + var a = new A {Name = "First", Id = TheId}; + + var b = new B {Name = names[1], OrderBy = 3, AId = TheId}; + a.Items.Add(b); + + var b2 = new B {Name = names[0], OrderBy = 1, AId = TheId}; + a.Items.Add(b2); + + ISession s = OpenSession(); + s.Save(a); + s.Flush(); + s.Close(); + + s = OpenSession(); + var newA = s.Get<A>(a.Id); + + Assert.AreEqual(2, newA.Items.Count); + int counter = 0; + foreach (B item in newA.Items) + { + Assert.AreEqual(names[counter], item.Name); + counter++; + } + s.Close(); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/GenericTest/OrderedSetGeneric/OrderedSetFixture.hbm.xml 2008-09-29 22:46:17 UTC (rev 3807) @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.GenericTest.OrderedSetGeneric"> + + <class name="A" table="a" lazy="false"> + <id name="Id" column="id"> + <generator class="assigned" /> + </id> + <property name="Name" column="aname" /> + <set name="Items" cascade="save-update" order-by="OrderBy ASC"> + <key column="aid"/> + <one-to-many class="B"/> + </set> + </class> + + <class name="B" table="b"> + <id name="Id" column="id"> + <generator class="native" /> + </id> + <property name="AId" column="aid" /> + <property name="OrderBy" column="orderby" /> + <property name="Name" column="aname" /> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-09-29 22:14:24 UTC (rev 3806) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-09-29 22:46:17 UTC (rev 3807) @@ -257,6 +257,9 @@ <Compile Include="GenericTest\MapGeneric\B.cs" /> <Compile Include="GenericTest\MapGeneric\MapGenericFixture.cs" /> <Compile Include="GenericTest\Methods\Fixture.cs" /> + <Compile Include="GenericTest\OrderedSetGeneric\A.cs" /> + <Compile Include="GenericTest\OrderedSetGeneric\B.cs" /> + <Compile Include="GenericTest\OrderedSetGeneric\OrderedSetFixture.cs" /> <Compile Include="GenericTest\Overall\A.cs" /> <Compile Include="GenericTest\Overall\Fixture.cs" /> <Compile Include="GenericTest\SetGeneric\A.cs" /> @@ -1478,6 +1481,7 @@ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="GenericTest\OrderedSetGeneric\OrderedSetFixture.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1293\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1490\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1492\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-09-29 22:14:40
|
Revision: 3806 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3806&view=rev Author: fabiomaulo Date: 2008-09-29 22:14:24 +0000 (Mon, 29 Sep 2008) Log Message: ----------- Minor set of solution Modified Paths: -------------- trunk/nhibernate/src/Iesi.Collections.sln Modified: trunk/nhibernate/src/Iesi.Collections.sln =================================================================== --- trunk/nhibernate/src/Iesi.Collections.sln 2008-09-29 22:13:11 UTC (rev 3805) +++ trunk/nhibernate/src/Iesi.Collections.sln 2008-09-29 22:14:24 UTC (rev 3806) @@ -17,7 +17,6 @@ {58CE4584-31B9-4E74-A7FB-5D40BFAD0876}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {58CE4584-31B9-4E74-A7FB-5D40BFAD0876}.Debug|Any CPU.Build.0 = Debug|Any CPU {58CE4584-31B9-4E74-A7FB-5D40BFAD0876}.Release|Any CPU.ActiveCfg = Release|Any CPU - {58CE4584-31B9-4E74-A7FB-5D40BFAD0876}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-09-29 22:13:40
|
Revision: 3805 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3805&view=rev Author: fabiomaulo Date: 2008-09-29 22:13:11 +0000 (Mon, 29 Sep 2008) Log Message: ----------- Actualization of lib for NH core Modified Paths: -------------- trunk/nhibernate/lib/net/2.0/Iesi.Collections.dll This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-09-29 21:54:06
|
Revision: 3804 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3804&view=rev Author: fabiomaulo Date: 2008-09-29 21:53:41 +0000 (Mon, 29 Sep 2008) Log Message: ----------- Start fixing NH-1173 (by Sean Carpenter) Modified Paths: -------------- trunk/nhibernate/src/Iesi.Collections/Iesi.Collections.csproj trunk/nhibernate/src/Iesi.Collections.Test/Generic/HashedSetFixture.cs trunk/nhibernate/src/Iesi.Collections.Test/Generic/ImmutableSetFixture.cs trunk/nhibernate/src/Iesi.Collections.Test/Generic/SetFixture.cs trunk/nhibernate/src/Iesi.Collections.Test/Generic/SortedSetFixture.cs trunk/nhibernate/src/Iesi.Collections.Test/Iesi.Collections.Test.csproj Added Paths: ----------- trunk/nhibernate/src/Iesi.Collections/Generic/OrderedSet.cs trunk/nhibernate/src/Iesi.Collections.Test/Generic/OrderedSetFixture.cs Added: trunk/nhibernate/src/Iesi.Collections/Generic/OrderedSet.cs =================================================================== --- trunk/nhibernate/src/Iesi.Collections/Generic/OrderedSet.cs (rev 0) +++ trunk/nhibernate/src/Iesi.Collections/Generic/OrderedSet.cs 2008-09-29 21:53:41 UTC (rev 3804) @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; + +namespace Iesi.Collections.Generic +{ + /// <summary> + /// Implements an ordered <c>Set</c> based on a dictionary. + /// </summary> + [Serializable] + public class OrderedSet<T> : DictionarySet<T> + { + /// <summary> + /// Initializes a new instance of the <see cref="OrderedSet{T}" /> class. + /// </summary> + public OrderedSet() + { + InternalDictionary = new Dictionary<T, object>(); + } + + /// <summary> + /// Initializes a new instance of the <see cref="OrderedSet{T}"/> class. + /// </summary> + /// <param name="initialValues">A collection of elements that defines the initial set contents.</param> + public OrderedSet(ICollection<T> initialValues) + : this() + { + AddAll(initialValues); + } + } +} Modified: trunk/nhibernate/src/Iesi.Collections/Iesi.Collections.csproj =================================================================== --- trunk/nhibernate/src/Iesi.Collections/Iesi.Collections.csproj 2008-09-29 21:27:32 UTC (rev 3803) +++ trunk/nhibernate/src/Iesi.Collections/Iesi.Collections.csproj 2008-09-29 21:53:41 UTC (rev 3804) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{4C251E3E-6EA1-4A51-BBCB-F9C42AE55344}</ProjectGuid> <OutputType>Library</OutputType> @@ -48,6 +48,7 @@ <Compile Include="Generic\HashedSet.cs" /> <Compile Include="Generic\ImmutableSet.cs" /> <Compile Include="Generic\ISet.cs" /> + <Compile Include="Generic\OrderedSet.cs" /> <Compile Include="Generic\Set.cs" /> <Compile Include="Generic\SortedSet.cs" /> <Compile Include="Generic\SynchronizedSet.cs" /> Modified: trunk/nhibernate/src/Iesi.Collections.Test/Generic/HashedSetFixture.cs =================================================================== --- trunk/nhibernate/src/Iesi.Collections.Test/Generic/HashedSetFixture.cs 2008-09-29 21:27:32 UTC (rev 3803) +++ trunk/nhibernate/src/Iesi.Collections.Test/Generic/HashedSetFixture.cs 2008-09-29 21:53:41 UTC (rev 3804) @@ -3,10 +3,10 @@ using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; - +using Iesi.Collections.Generic; using NUnit.Framework; -namespace Iesi.Collections.Generic.Test +namespace Iesi.Collections.Test.Generic { /// <summary> /// Summary description for HashedSetFixture. @@ -47,4 +47,4 @@ Assert.IsTrue(desSet.Contains(three), "should contain three"); } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/Iesi.Collections.Test/Generic/ImmutableSetFixture.cs =================================================================== --- trunk/nhibernate/src/Iesi.Collections.Test/Generic/ImmutableSetFixture.cs 2008-09-29 21:27:32 UTC (rev 3803) +++ trunk/nhibernate/src/Iesi.Collections.Test/Generic/ImmutableSetFixture.cs 2008-09-29 21:53:41 UTC (rev 3804) @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; - +using Iesi.Collections.Generic; using NUnit.Framework; -namespace Iesi.Collections.Generic.Test +namespace Iesi.Collections.Test.Generic { /// <summary> /// Summary description for HashedSetFixture. @@ -26,4 +26,4 @@ get { return typeof(ImmutableSet<string>); } } } -} +} \ No newline at end of file Added: trunk/nhibernate/src/Iesi.Collections.Test/Generic/OrderedSetFixture.cs =================================================================== --- trunk/nhibernate/src/Iesi.Collections.Test/Generic/OrderedSetFixture.cs (rev 0) +++ trunk/nhibernate/src/Iesi.Collections.Test/Generic/OrderedSetFixture.cs 2008-09-29 21:53:41 UTC (rev 3804) @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using Iesi.Collections.Generic; +using NUnit.Framework; + +namespace Iesi.Collections.Test.Generic +{ + /// <summary> + /// Summary description for OrderedSetFixture. + /// </summary> + [TestFixture] + public class OrderedSetFixture : GenericSetFixture + { + protected override ISet<string> CreateInstance() + { + return new OrderedSet<string>(); + } + + protected override ISet<string> CreateInstance(ICollection<string> init) + { + return new OrderedSet<string>(init); + } + + protected override Type ExpectedType + { + get { return typeof(OrderedSet<string>); } + } + + [Test] + public void OrderedEnumeration() + { + List<string> expectedOrder = new List<string>(3) {one, two, three}; + + int index = 0; + foreach (string str in _set) + { + Assert.AreEqual(str, expectedOrder[index], index + " did not have same value"); + index++; + } + } + } +} Modified: trunk/nhibernate/src/Iesi.Collections.Test/Generic/SetFixture.cs =================================================================== --- trunk/nhibernate/src/Iesi.Collections.Test/Generic/SetFixture.cs 2008-09-29 21:27:32 UTC (rev 3803) +++ trunk/nhibernate/src/Iesi.Collections.Test/Generic/SetFixture.cs 2008-09-29 21:53:41 UTC (rev 3804) @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; - +using Iesi.Collections.Generic; using NUnit.Framework; -namespace Iesi.Collections.Generic.Test +namespace Iesi.Collections.Test.Generic { /// <summary> /// Summary description for SetFixture. @@ -460,4 +460,4 @@ protected abstract Type ExpectedType { get; } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/Iesi.Collections.Test/Generic/SortedSetFixture.cs =================================================================== --- trunk/nhibernate/src/Iesi.Collections.Test/Generic/SortedSetFixture.cs 2008-09-29 21:27:32 UTC (rev 3803) +++ trunk/nhibernate/src/Iesi.Collections.Test/Generic/SortedSetFixture.cs 2008-09-29 21:53:41 UTC (rev 3804) @@ -1,10 +1,10 @@ using System; using System.Collections; using System.Collections.Generic; - +using Iesi.Collections.Generic; using NUnit.Framework; -namespace Iesi.Collections.Generic.Test +namespace Iesi.Collections.Test.Generic { /// <summary> /// Summary description for SortedSetFixture. @@ -66,4 +66,4 @@ } } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/Iesi.Collections.Test/Iesi.Collections.Test.csproj =================================================================== --- trunk/nhibernate/src/Iesi.Collections.Test/Iesi.Collections.Test.csproj 2008-09-29 21:27:32 UTC (rev 3803) +++ trunk/nhibernate/src/Iesi.Collections.Test/Iesi.Collections.Test.csproj 2008-09-29 21:53:41 UTC (rev 3804) @@ -49,6 +49,7 @@ <Compile Include="AssemblyInfo.cs" /> <Compile Include="Generic\HashedSetFixture.cs" /> <Compile Include="Generic\ImmutableSetFixture.cs" /> + <Compile Include="Generic\OrderedSetFixture.cs" /> <Compile Include="Generic\SetFixture.cs" /> <Compile Include="Generic\SortedSetFixture.cs" /> <Compile Include="HashedSetFixture.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-09-29 21:27:54
|
Revision: 3803 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3803&view=rev Author: fabiomaulo Date: 2008-09-29 21:27:32 +0000 (Mon, 29 Sep 2008) Log Message: ----------- Minor Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Transform/DistinctRootEntityResultTransformer.cs Modified: trunk/nhibernate/src/NHibernate/Transform/DistinctRootEntityResultTransformer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Transform/DistinctRootEntityResultTransformer.cs 2008-09-29 20:49:37 UTC (rev 3802) +++ trunk/nhibernate/src/NHibernate/Transform/DistinctRootEntityResultTransformer.cs 2008-09-29 21:27:32 UTC (rev 3803) @@ -1,7 +1,8 @@ using System; using System.Collections; -using Iesi.Collections; +using System.Runtime.CompilerServices; using log4net; +using Iesi.Collections.Generic; namespace NHibernate.Transform { @@ -9,7 +10,6 @@ public class DistinctRootEntityResultTransformer : IResultTransformer { private static readonly ILog log = LogManager.GetLogger(typeof(DistinctRootEntityResultTransformer)); - private static readonly IEqualityComparer identityEqualityComparer = new IdentityEqualityComparer(); internal sealed class Identity { @@ -23,12 +23,12 @@ public override bool Equals(object other) { Identity that = (Identity) other; - return identityEqualityComparer.Equals(entity, that.entity); + return ReferenceEquals(entity, that.entity); } public override int GetHashCode() { - return identityEqualityComparer.GetHashCode(entity); + return RuntimeHelpers.GetHashCode(entity); } } @@ -40,7 +40,7 @@ public IList TransformList(IList list) { IList result = new ArrayList(); - ISet distinct = new HashedSet(); + ISet<Identity> distinct = new HashedSet<Identity>(); for (int i = 0; i < list.Count; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-09-29 20:49:54
|
Revision: 3802 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3802&view=rev Author: fabiomaulo Date: 2008-09-29 20:49:37 +0000 (Mon, 29 Sep 2008) Log Message: ----------- Minor Modified Paths: -------------- trunk/nhibernate/src/NHibernate/IdentityEqualityComparer.cs Modified: trunk/nhibernate/src/NHibernate/IdentityEqualityComparer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IdentityEqualityComparer.cs 2008-09-29 20:26:50 UTC (rev 3801) +++ trunk/nhibernate/src/NHibernate/IdentityEqualityComparer.cs 2008-09-29 20:49:37 UTC (rev 3802) @@ -23,7 +23,7 @@ /// true if x is the same instance as y or if both are null references; otherwise, false. ///</returns> /// <remarks> - /// This is Lazy collection safe since it uses <see cref="M:Object.ReferenceEquals"/>, + /// This is Lazy collection safe since it uses <see cref="Object.ReferenceEquals"/>, /// unlike <c>Object.Equals()</c> which currently causes NHibernate to load up the collection. /// This behaivior of Collections is likely to change because Java's collections override Equals() and /// .net's collections don't. So in .net there is no need to override Equals() and @@ -31,7 +31,7 @@ /// </remarks> public new bool Equals(object x, object y) { - return object.ReferenceEquals(x, y); + return ReferenceEquals(x, y); } #endregion This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-09-29 20:27:13
|
Revision: 3801 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3801&view=rev Author: fabiomaulo Date: 2008-09-29 20:26:50 +0000 (Mon, 29 Sep 2008) Log Message: ----------- Fix NH-1503 (Sybase.AdoNet2 Dialect&Drire by Nathan Blair) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Dialect/SybaseAdoNet12Dialect.cs trunk/nhibernate/src/NHibernate/Driver/SybaseAdoNet12ClientDriver.cs Added: trunk/nhibernate/src/NHibernate/Dialect/SybaseAdoNet12Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/SybaseAdoNet12Dialect.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Dialect/SybaseAdoNet12Dialect.cs 2008-09-29 20:26:50 UTC (rev 3801) @@ -0,0 +1,99 @@ +using NHibernate.Cfg; + +namespace NHibernate.Dialect +{ + /// <summary> + /// An SQL dialect compatible with Sybase. + /// </summary> + /// <remarks> + /// <p> + /// This dialect probably will not work with schema-export. If anyone out there + /// can fill in the ctor with DbTypes to Strings that would be helpful. + /// </p> + /// The SybaseDialect defaults the following configuration properties: + /// <list type="table"> + /// <listheader> + /// <term>Property</term> + /// <description>Default Value</description> + /// </listheader> + /// <item> + /// <term>use_outer_join</term> + /// <description><see langword="true" /></description> + /// </item> + /// <item> + /// <term>connection.driver_class</term> + /// <description><see cref="NHibernate.Driver.SybaseClientDriver" /></description> + /// </item> + /// <item> + /// <term>prepare_sql</term> + /// <description><see langword="false" /></description> + /// </item> + /// </list> + /// </remarks> + public class SybaseAdoNet12Dialect : Dialect + { + /// <summary></summary> + public SybaseAdoNet12Dialect() + { + DefaultProperties[Environment.ConnectionDriver] = "NHibernate.Driver.SybaseAdoNet12ClientDriver"; + DefaultProperties[Environment.PrepareSql] = "true"; + } + + /// <summary></summary> + public override string AddColumnString + { + get { return "add"; } + } + + /// <summary></summary> + public override string NullColumnString + { + get { return " null"; } + } + + /// <summary></summary> + public override bool QualifyIndexName + { + get { return false; } + } + + /// <summary></summary> + public override string ForUpdateString + { + get { return string.Empty; } + } + + /// <summary></summary> + public override bool SupportsIdentityColumns + { + get { return true; } + } + + /// <summary></summary> + public override string IdentitySelectString + { + get { return "select @@identity"; } + } + + /// <summary></summary> + public override string IdentityColumnString + { + get { return "IDENTITY NOT NULL"; } + } + + /// <summary></summary> + public override string NoColumnsInsertString + { + get { return "DEFAULT VALUES"; } + } + + /// <remarks> + /// Sybase does not support quoted aliases, this function thus returns + /// <c>aliasName</c> as is. + /// </remarks> + public override string QuoteForAliasName(string aliasName) + { + return aliasName; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Driver/SybaseAdoNet12ClientDriver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Driver/SybaseAdoNet12ClientDriver.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Driver/SybaseAdoNet12ClientDriver.cs 2008-09-29 20:26:50 UTC (rev 3801) @@ -0,0 +1,49 @@ +namespace NHibernate.Driver +{ + /// <summary> + /// The SybaseClientDriver Driver provides a database driver for Sybase. + /// </summary> + /// <remarks> + /// It has been reported to work with the <see cref="Dialect.MsSql2000Dialect"/>. + /// </remarks> + public class SybaseAdoNet12ClientDriver : ReflectionBasedDriver + { + /// <summary> + /// Initializes a new instance of the <see cref="SybaseClientDriver"/> class. + /// </summary> + /// <exception cref="HibernateException"> + /// Thrown when the Sybase.Data.AseClient assembly can not be loaded. + /// </exception> + public SybaseAdoNet12ClientDriver() + : base( + "Sybase.AdoNet2.AseClient", + "Sybase.Data.AseClient.AseConnection", + "Sybase.Data.AseClient.AseCommand") + { + } + + /// <summary> + /// Sybase.Data.AseClient uses named parameters in the sql. + /// </summary> + /// <value><see langword="true" /> - Sybase uses <c>@</c> in the sql.</value> + public override bool UseNamedPrefixInSql + { + get { return true; } + } + + /// <summary></summary> + public override bool UseNamedPrefixInParameter + { + get { return true; } + } + + /// <summary> + /// Sybase.Data.AseClient use the <c>@</c> to locate parameters in sql. + /// </summary> + /// <value><c>@</c> is used to locate parameters in sql.</value> + public override string NamedPrefix + { + get { return "@"; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-09-29 20:10:50 UTC (rev 3800) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-09-29 20:26:50 UTC (rev 3801) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</ProjectGuid> <OutputType>Library</OutputType> @@ -598,10 +598,12 @@ <Compile Include="Dialect\Schema\MsSqlMetaData.cs" /> <Compile Include="Dialect\Schema\OracleMetaData.cs" /> <Compile Include="Dialect\Sybase11Dialect.cs" /> + <Compile Include="Dialect\SybaseAdoNet12Dialect.cs" /> <Compile Include="Driver\ASA10ClientDriver.cs" /> <Compile Include="Driver\ISqlParameterFormatter.cs" /> <Compile Include="Driver\SqlStringFormatter.cs" /> <Compile Include="Criterion\SubqueryProjection.cs" /> + <Compile Include="Driver\SybaseAdoNet12ClientDriver.cs" /> <Compile Include="EmptyInterceptor.cs" /> <Compile Include="Engine\ActionQueue.cs" /> <Compile Include="Engine\AssociationKey.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-09-29 20:11:18
|
Revision: 3800 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3800&view=rev Author: fabiomaulo Date: 2008-09-29 20:10:50 +0000 (Mon, 29 Sep 2008) Log Message: ----------- Fix NH-1468 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/SqlCommand/InFragment.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/InFragmentFixture.cs Modified: trunk/nhibernate/src/NHibernate/SqlCommand/InFragment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/InFragment.cs 2008-09-29 19:43:50 UTC (rev 3799) +++ trunk/nhibernate/src/NHibernate/SqlCommand/InFragment.cs 2008-09-29 20:10:50 UTC (rev 3800) @@ -1,4 +1,3 @@ - using System; using System.Collections; using NHibernate.Util; @@ -10,11 +9,11 @@ /// </summary> public class InFragment { - public static readonly string Null = "null"; public static readonly string NotNull = "not null"; + public static readonly string Null = "null"; + private readonly ArrayList values = new ArrayList(); private string columnName; - private ArrayList values = new ArrayList(); /// <summary> /// Add a value to the value list. Value may be a string, @@ -27,39 +26,27 @@ return this; } - /// <summary> - /// - /// </summary> - /// <param name="columnName"></param> - /// <returns></returns> - public InFragment SetColumn(string columnName) + public InFragment SetColumn(string colName) { - this.columnName = columnName; + columnName = colName; return this; } - /// <summary> - /// - /// </summary> - /// <param name="alias"></param> - /// <param name="columnName"></param> - /// <returns></returns> - public InFragment SetColumn(string alias, string columnName) + public InFragment SetColumn(string alias, string colName) { - this.columnName = alias + StringHelper.Dot + columnName; - return SetColumn(this.columnName); + columnName = alias + StringHelper.Dot + colName; + return SetColumn(columnName); } public InFragment SetFormula(string alias, string formulaTemplate) { - this.columnName = StringHelper.Replace(formulaTemplate, Template.Placeholder, alias); - return SetColumn(this.columnName); + columnName = StringHelper.Replace(formulaTemplate, Template.Placeholder, alias); + return SetColumn(columnName); } - /// <summary></summary> public SqlString ToFragmentString() { - SqlStringBuilder buf = new SqlStringBuilder(values.Count * 5); + var buf = new SqlStringBuilder(values.Count * 5); buf.Add(columnName); if (values.Count > 1) @@ -82,7 +69,7 @@ } else if (NotNull.Equals(value)) { - throw new ArgumentOutOfRangeException("not null makes no sense for in expression"); + throw new NotSupportedException(string.Format("not null makes no sense for in expression (column:{0})",columnName)); } else { @@ -112,16 +99,15 @@ // SqlString "is null or [column] (" + [rest of sqlstring here] + ")" if (allowNull) { - buf.Insert(0, " is null or ") - .Insert(0, columnName) - .Insert(0, StringHelper.OpenParen) - .Add(StringHelper.ClosedParen); + buf.Insert(0, " is null or ").Insert(0, columnName).Insert(0, StringHelper.OpenParen).Add(StringHelper.ClosedParen); } } else { - if(values.Count == 0) - throw new ArgumentOutOfRangeException("Attempting to parse a null value into an sql string."); + if (values.Count == 0) + { + throw new NotSupportedException(string.Format("Attempting to parse a null value into an sql string (column:{0}).", columnName)); + } object value = values[0]; if (Null.Equals(value)) { @@ -139,4 +125,4 @@ return buf.ToSqlString(); } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-09-29 19:43:50 UTC (rev 3799) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-09-29 20:10:50 UTC (rev 3800) @@ -783,7 +783,6 @@ <Compile Include="Assertions\HaveSerializableAttributeAsserter.cs" /> <Compile Include="SessionCacheTest.cs" /> <Compile Include="SqlLogSpy.cs" /> - <Compile Include="SqlCommandTest\InFragmentFixture.cs" /> <Compile Include="SqlCommandTest\SqlDeleteBuilderFixture.cs" /> <Compile Include="SqlCommandTest\SqlInsertBuilderFixture.cs" /> <Compile Include="SqlCommandTest\SqlSelectBuilderFixture.cs" /> Deleted: trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/InFragmentFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/InFragmentFixture.cs 2008-09-29 19:43:50 UTC (rev 3799) +++ trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/InFragmentFixture.cs 2008-09-29 20:10:50 UTC (rev 3800) @@ -1,17 +0,0 @@ -using System; - -namespace NHibernate.Test.SqlCommandTest -{ - /// <summary> - /// Summary description for InFragmentFixture. - /// </summary> - public class InFragmentFixture - { - public InFragmentFixture() - { - // - // TODO: Add constructor logic here - // - } - } -} \ 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...> - 2008-09-29 19:44:12
|
Revision: 3799 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3799&view=rev Author: fabiomaulo Date: 2008-09-29 19:43:50 +0000 (Mon, 29 Sep 2008) Log Message: ----------- Fix NH-1446 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs trunk/nhibernate/src/NHibernate.Test/HQLFunctionTest/HQLFunctions.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs 2008-09-29 17:25:31 UTC (rev 3798) +++ trunk/nhibernate/src/NHibernate/Dialect/Function/CastFunction.cs 2008-09-29 19:43:50 UTC (rev 3799) @@ -12,10 +12,6 @@ /// </summary> public class CastFunction : ISQLFunction, IFunctionGrammar { - public CastFunction() - { - } - #region ISQLFunction Members public IType ReturnType(IType columnType, IMapping mapping) @@ -42,7 +38,7 @@ throw new QueryException("cast() requires two arguments"); } string typeName = args[1].ToString(); - string sqlType = string.Empty; + string sqlType; IType hqlType = TypeFactory.HeuristicType(typeName); if (hqlType != null) { @@ -86,7 +82,7 @@ bool IFunctionGrammar.IsSeparator(string token) { - return "as".Equals(token); + return "as".Equals(token, StringComparison.InvariantCultureIgnoreCase); } bool IFunctionGrammar.IsKnownArgument(string token) Modified: trunk/nhibernate/src/NHibernate.Test/HQLFunctionTest/HQLFunctions.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQLFunctionTest/HQLFunctions.cs 2008-09-29 17:25:31 UTC (rev 3798) +++ trunk/nhibernate/src/NHibernate.Test/HQLFunctionTest/HQLFunctions.cs 2008-09-29 19:43:50 UTC (rev 3799) @@ -667,6 +667,27 @@ } [Test] + public void CastNH1446() + { + IgnoreIfNotSupported("cast"); + using (ISession s = OpenSession()) + { + Animal a1 = new Animal("abcdef", 1.3f); + s.Save(a1); + s.Flush(); + } + using (ISession s = OpenSession()) + { + // Rendered in SELECT using a property + string hql = "select cast(a.BodyWeight As Double) from Animal a"; + IList l = s.CreateQuery(hql).List(); + Assert.AreEqual(1, l.Count); + Assert.AreEqual(1.3f, l[0]); + } + } + + + [Test] public void Current_TimeStamp() { IgnoreIfNotSupported("current_timestamp"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2008-09-29 17:25:43
|
Revision: 3798 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3798&view=rev Author: ayenderahien Date: 2008-09-29 17:25:31 +0000 (Mon, 29 Sep 2008) Log Message: ----------- Applying patch from Artur Dorochowicz, better parameter handling for Clob and Image columns on SQL CE Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Driver/SqlServerCeDriver.cs Modified: trunk/nhibernate/src/NHibernate/Driver/SqlServerCeDriver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Driver/SqlServerCeDriver.cs 2008-09-29 13:40:17 UTC (rev 3797) +++ trunk/nhibernate/src/NHibernate/Driver/SqlServerCeDriver.cs 2008-09-29 17:25:31 UTC (rev 3798) @@ -24,11 +24,18 @@ } private bool prepareSql; + private System.Reflection.PropertyInfo dbParamSqlDbTypeProperty; public override void Configure(IDictionary<string, string> settings) { base.Configure(settings); prepareSql = PropertiesHelper.GetBoolean(Environment.PrepareSql, settings, false); + + using (IDbCommand dbCmd = base.CreateCommand()) + { + IDbDataParameter dbParam = dbCmd.CreateParameter(); + dbParamSqlDbTypeProperty = dbParam.GetType().GetProperty( "SqlDbType" ); + } } /// <summary> @@ -94,5 +101,24 @@ { get { return true; } } + + protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) + { + base.InitializeParameter(dbParam, name, sqlType); + + AdjustDbParamTypeForLargeObjects( dbParam, sqlType ); + } + + private void AdjustDbParamTypeForLargeObjects(IDbDataParameter dbParam, SqlType sqlType) + { + if (sqlType is BinarySqlType) + { + dbParamSqlDbTypeProperty.SetValue(dbParam, SqlDbType.Image, null); + } + else if (sqlType is StringSqlType) + { + dbParamSqlDbTypeProperty.SetValue(dbParam, SqlDbType.NText, 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...> - 2008-09-29 13:40:28
|
Revision: 3797 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3797&view=rev Author: fabiomaulo Date: 2008-09-29 13:40:17 +0000 (Mon, 29 Sep 2008) Log Message: ----------- Preparing release NH2.0.1GA Modified Paths: -------------- branches/2.0.x/nhibernate/build-common/common.xml branches/2.0.x/nhibernate/releasenotes.txt Modified: branches/2.0.x/nhibernate/build-common/common.xml =================================================================== --- branches/2.0.x/nhibernate/build-common/common.xml 2008-09-29 12:20:13 UTC (rev 3796) +++ branches/2.0.x/nhibernate/build-common/common.xml 2008-09-29 13:40:17 UTC (rev 3797) @@ -76,7 +76,7 @@ effectively SP0). --> - <property name="project.version" value="2.0.0.SP1" overwrite="false" /> + <property name="project.version" value="2.0.1.GA" overwrite="false" /> <!-- Compute short project version (major.minor) using a regex --> <regex input="${project.version}" pattern="^(?'shortversion'\d+\.\d+)" /> Modified: branches/2.0.x/nhibernate/releasenotes.txt =================================================================== --- branches/2.0.x/nhibernate/releasenotes.txt 2008-09-29 12:20:13 UTC (rev 3796) +++ branches/2.0.x/nhibernate/releasenotes.txt 2008-09-29 13:40:17 UTC (rev 3797) @@ -1,3 +1,34 @@ +Build 2.0.1.GA +======================== +** Bug + * [NH-1293] - Changed behavior of Filters for many-to-one associations brings up possible bug when used with outer joins. + * [NH-1464] - C++ and Dispose method + * [NH-1466] - current_session_context_class = thread_static doesn't work + * [NH-1473] - IsEqual and Compare broken in EntityType + * [NH-1481] - Named Hql queries w/ Named Parameters broken after upgrade to 2.0 from 1.2.1 + * [NH-1483] - Subclass Not Loaded From Cache as Baseclass + * [NH-1488] - Table per class hierarchy and OUTER JOIN + * [NH-1490] - Wrong order of parameters in query when session uses IFilter + * [NH-1492] - Parameter mismatch enabling filters + * [NH-1499] - NullReferenceException construting Criteria query + +** Improvement + * [NH-1484] - first chance exception 'NHibernate.MappingException' when starting a webapplication + * [NH-1496] - Configuration.AddAssembly(Assembly) should do some logging if no mapping files where found + * [NH-1500] - Spelling error of NHibernate.Cfg.ConfigurationSchema.ParseColectionsCache + + +** Patch + * [NH-1034] - HQL functions - parameters support + * [NH-1434] - Some unit test supplies non-character value to LIKE: not portable across every RDBMS + * [NH-1435] - Explicitly order query in NH-1179 to ensure reliable results + * [NH-1436] - Mapping of NH-1250 not portable across every RDBMS + * [NH-1437] - Mapping of NH-1408 not portable across every RDBMS + * [NH-1438] - Some queries from FooBarTest fixture are not portable across every RDBMS + * [NH-1439] - Handle Dialect.GetIdentityColumnString(DbType type) + * [NH-1459] - Sybase dialect + * [NH-1462] - StringHelper.GetFullClassname fails to parse generic types + Build 2.0.0.GA ======================== ** BREAKING CHANGES from NH1.2.1GA to NH2.0.0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-09-29 12:20:32
|
Revision: 3796 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3796&view=rev Author: fabiomaulo Date: 2008-09-29 12:20:13 +0000 (Mon, 29 Sep 2008) Log Message: ----------- Merge r3795 (revert NH-1179; fix NH-1293, NH-1488, NH-1490, NH-1488) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs 2008-09-28 22:40:10 UTC (rev 3795) +++ trunk/nhibernate/src/NHibernate/Engine/JoinSequence.cs 2008-09-29 12:20:13 UTC (rev 3796) @@ -185,11 +185,11 @@ condition = on; } //Start NH1179 ************ - if (string.IsNullOrEmpty(condition)) - { - string filterCondition = join.Joinable.FilterFragment(join.Alias, enabledFilters); - joinFragment.HasFilterCondition = joinFragment.AddCondition(filterCondition); - } + //if (string.IsNullOrEmpty(condition)) + //{ + // string filterCondition = join.Joinable.FilterFragment(join.Alias, enabledFilters); + // joinFragment.HasFilterCondition = joinFragment.AddCondition(filterCondition); + //} //End NH1179 ************ if (withClauseFragment != null) Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs 2008-09-28 22:40:10 UTC (rev 3795) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs 2008-09-29 12:20:13 UTC (rev 3796) @@ -11,9 +11,11 @@ get { return "NH1179"; } } - [Test] + [Test, Ignore("Not supported.")] public void ApplyFilterExplicitJoin() { + // Note: if we fix this we must fix it for Criteria too (NH-1293) + RelatedClass rc1 = new RelatedClass(1); RelatedClass rc2 = new RelatedClass(2); RelatedClass rc11 = new RelatedClass(1); Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs 2008-09-29 12:20:13 UTC (rev 3796) @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1293 +{ + public class Customer + { + private int id; + private string name; + private Category category; + private bool isActive; + public Customer() {} + public Customer(string name) + { + this.name = name; + } + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual Category Category + { + get { return category; } + set { category = value; } + } + + public virtual bool IsActive + { + get { return isActive; } + set { isActive = value; } + } + } + + public class Category + { + private int id; + private string name; + private bool isActive; + public Category() {} + public Category(string name) + { + this.name = name; + } + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual bool IsActive + { + get { return isActive; } + set { isActive = value; } + } + } +} Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs 2008-09-29 12:20:13 UTC (rev 3796) @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using NHibernate.Criterion; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1293 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void Criteria_Does_Not_Equal_To_HQL() + { + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + Customer c = new Customer("Somebody"); + c.Category = new Category("User"); + s.Save(c.Category); + c.IsActive = true; + c.Category.IsActive = false; // this cause diff in query results + s.Save(c); + tx.Commit(); + } + } + + using (ISession s = OpenSession()) + { + s.DisableFilter("onlyActive"); + IFilter fltr = s.EnableFilter("onlyActive"); + fltr.SetParameter("activeFlag", 1); + + // with HQL, Category.IsActive=true filter applied, result count=2 + IQuery hqlQuery = s.CreateQuery("from Customer c where c.Category.Name = ?"); + hqlQuery.SetParameter(0, "User"); // note using positional parameters because of NH-1490 + IList<Customer> hqlResult = hqlQuery.List<Customer>(); + Console.WriteLine(hqlResult.Count); + + // with ICriteria, no Category.IsActive filter applied, result count=1 + ICriteria criteria = s.CreateCriteria(typeof (Customer), "cust").CreateCriteria("Category", "cat"); + criteria.Add(Restrictions.Eq("cat.Name", "User")); + IList<Customer> criteriaResult = criteria.List<Customer>(); + + Console.WriteLine(criteriaResult.Count); + + Assert.That(hqlResult.Count == criteriaResult.Count); + } + + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from Customer"); + s.Delete("from Category"); + tx.Commit(); + } + } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml 2008-09-29 12:20:13 UTC (rev 3796) @@ -0,0 +1,28 @@ +<?xml version="1.0"?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1293"> + <class name="Customer" table="Customer"> + <id name="Id" column="Id"> + <generator class="native" /> + </id> + <property name="Name" not-null="true" /> + <property name="IsActive" not-null="true" /> + <many-to-one name="Category" lazy="false" column="Category_Id" /> + + <filter name="onlyActive" condition=":activeFlag = IsActive" /> + </class> + + <class name="Category" table="Category" mutable="true"> + <id name="Id" column="Id"> + <generator class="native" /> + </id> + <property name="Name" not-null="true" /> + <property name="IsActive" not-null="true" /> + + <filter name="onlyActive" condition=":activeFlag = IsActive" /> + </class> + + <filter-def name="onlyActive"> + <filter-param name="activeFlag" type="int"/> + </filter-def> + +</hibernate-mapping> \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml ___________________________________________________________________ Added: svn:mergeinfo + Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs 2008-09-28 22:40:10 UTC (rev 3795) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs 2008-09-29 12:20:13 UTC (rev 3796) @@ -37,8 +37,8 @@ } } - [Test, Ignore("Not supported.")] - public void PerhapsBug() + [Test] + public void Bug() { using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) @@ -66,4 +66,4 @@ } } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Mappings.hbm.xml 2008-09-28 22:40:10 UTC (rev 3795) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Mappings.hbm.xml 2008-09-29 12:20:13 UTC (rev 3796) @@ -3,7 +3,7 @@ assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1488"> - <class name="Category" table="Category" abstract="true"> + <class name="Category" table="Category" mutable="true" abstract="true"> <id name="Id" column="Id"> <generator class="native" /> </id> @@ -17,9 +17,9 @@ <generator class="native" /> </id> <property name="Name" not-null="true" /> - <many-to-one name="Category" lazy="false" column="Category_Id"/> + <many-to-one name="Category" lazy="false" class="CustomerCategory" column="Category_Id" /> </class> - + <class name="CustomerNoSmart" table="CustomerNoSmart"> <id name="Id" column="Id"> <generator class="native" /> @@ -27,4 +27,4 @@ <property name="Name" not-null="true" /> <many-to-one name="Category" lazy="false" column="Category_Id"/> </class> -</hibernate-mapping> +</hibernate-mapping> \ No newline at end of file Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs 2008-09-29 12:20:13 UTC (rev 3796) @@ -0,0 +1,69 @@ +namespace NHibernate.Test.NHSpecificTest.NH1490 +{ + public class Customer + { + private int id; + private string name; + private Category category; + private bool isActive; + public Customer() {} + public Customer(string name) + { + this.name = name; + } + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual Category Category + { + get { return category; } + set { category = value; } + } + + public virtual bool IsActive + { + get { return isActive; } + set { isActive = value; } + } + } + + public class Category + { + private int id; + private string name; + private bool isActive; + public Category() {} + public Category(string name) + { + this.name = name; + } + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual bool IsActive + { + get { return isActive; } + set { isActive = value; } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs 2008-09-29 12:20:13 UTC (rev 3796) @@ -0,0 +1,119 @@ +using System.Collections.Generic; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; + +namespace NHibernate.Test.NHSpecificTest.NH1490 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void Can_Translate_Correctly_Without_Filter() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + Customer c = new Customer("Somebody"); + c.Category = new Category("User"); + c.IsActive = true; + c.Category.IsActive = true; + s.Save(c.Category); + s.Save(c); + tx.Commit(); + } + + using (ISession s = OpenSession()) + { + IQuery query = s.CreateQuery("from Customer c where c.Category.Name = :catName"); + query.SetParameter("catName", "User"); + IList<Customer> customers = query.List<Customer>(); + + Assert.That(customers.Count, Is.EqualTo(1), "Can apply condition on Customer without IFilter"); + } + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from Customer"); + s.Delete("from Category"); + tx.Commit(); + } + } + + [Test] + public void Also_Works_With_Filter() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + Customer c = new Customer("Somebody"); + c.Category = new Category("User"); + s.Save(c.Category); + c.IsActive = true; + c.Category.IsActive = true; + s.Save(c); + tx.Commit(); + } + + using (ISession s = OpenSession()) + { + s.DisableFilter("onlyActive"); + IFilter fltr = s.EnableFilter("onlyActive"); + fltr.SetParameter("activeFlag", 1); + + // Customer is parametrized + IQuery query = s.CreateQuery("from Customer c where c.Name = :customerName"); + query.SetParameter("customerName", "Somebody"); + IList<Customer> customers = query.List<Customer>(); + + Assert.That(customers.Count, Is.EqualTo(1), "IFilter applied and Customer parametrized on Name also works"); + } + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from Customer"); + s.Delete("from Category"); + tx.Commit(); + } + } + + [Test] + public void Incorrect_SQL_Translated_Params_Bug() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + Customer c = new Customer("Somebody"); + c.Category = new Category("User"); + s.Save(c.Category); + c.IsActive = true; + c.Category.IsActive = true; + s.Save(c); + tx.Commit(); + } + + using (ISession s = OpenSession()) + { + s.DisableFilter("onlyActive"); + IFilter fltr = s.EnableFilter("onlyActive"); + fltr.SetParameter("activeFlag", 1); + // related entity Customer.Category is parametrized + IQuery query = s.CreateQuery("from Customer c where c.Category.Name = :catName"); + query.SetParameter("catName", "User"); + + IList<Customer> customers = query.List<Customer>(); + + Assert.That(customers.Count, Is.EqualTo(1), "IFIlter applied and Customer parametrized on Category.Name DOES NOT work"); + } + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from Customer"); + s.Delete("from Category"); + tx.Commit(); + } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml 2008-09-29 12:20:13 UTC (rev 3796) @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1490"> + + <class name="Customer" table="Customer"> + <id name="Id" column="Id"> + <generator class="native" /> + </id> + <property name="Name" not-null="true" /> + <property name="IsActive" not-null="true" /> + <many-to-one name="Category" lazy="false" column="Category_Id" /> + + <filter name="onlyActive" condition=":activeFlag = IsActive" /> + </class> + + <class name="Category" table="Category" mutable="true"> + <id name="Id" column="Id"> + <generator class="native" /> + </id> + <property name="Name" not-null="true" /> + <property name="IsActive" not-null="true" /> + + <filter name="onlyActive" condition=":activeFlag = IsActive" /> + </class> + + <filter-def name="onlyActive"> + <filter-param name="activeFlag" type="int"/> + </filter-def> +</hibernate-mapping> \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs 2008-09-29 12:20:13 UTC (rev 3796) @@ -0,0 +1,38 @@ +namespace NHibernate.Test.NHSpecificTest.NH1492 +{ + public class ChildEntity + { + private string _description; + private int _id; + private Entity _parent; + public ChildEntity() {} + + public ChildEntity(Entity parent, string description) + { + _description = description; + if (parent != null) + { + _parent = parent; + _parent.Childs.Add(this); + } + } + + public virtual int Id + { + get { return _id; } + set { _id = value; } + } + + public virtual string Description + { + get { return _description; } + set { _description = value; } + } + + public virtual Entity Parent + { + get { return _parent; } + set { _parent = value; } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs 2008-09-29 12:20:13 UTC (rev 3796) @@ -0,0 +1,50 @@ +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1492 +{ + public class Entity + { + private IList<ChildEntity> _childs = new List<ChildEntity>(); + private int _code; + private string _deleted; + private string _description; + private int _id; + public Entity() {} + + public Entity(int code, string description) + { + _code = code; + _description = description; + } + + public virtual int Id + { + get { return _id; } + set { _id = value; } + } + + public virtual int Code + { + get { return _code; } + set { _code = value; } + } + + public virtual string Description + { + get { return _description; } + set { _description = value; } + } + + public virtual string Deleted + { + get { return _deleted; } + set { _deleted = value; } + } + + public virtual IList<ChildEntity> Childs + { + get { return _childs; } + set { _childs = value; } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs 2008-09-29 12:20:13 UTC (rev 3796) @@ -0,0 +1,46 @@ +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1492 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void RetrieveEntities() + { + Entity eDel = new Entity(1, "DeletedEntity"); + eDel.Deleted = "Y"; + + Entity eGood = new Entity(2, "GoodEntity"); + eGood.Childs.Add(new ChildEntity(eGood, "GoodEntityChild")); + + // Make "Deleted" entity persistent + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(eDel); + s.Save(eGood); + t.Commit(); + } + + // Retrive (check if the entity was well persisted) + IList<ChildEntity> childs; + using (ISession s = OpenSession()) + { + s.EnableFilter("excludeDeletedRows").SetParameter("deleted", "Y"); + + IQuery q = s.CreateQuery("FROM ChildEntity c WHERE c.Parent.Code = :parentCode").SetParameter("parentCode", 2); + childs= q.List<ChildEntity>(); + } + Assert.AreEqual(1, childs.Count); + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Delete("from Entity"); + t.Commit(); + } + } + } +} \ No newline at end of file Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml (from rev 3795, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml 2008-09-29 12:20:13 UTC (rev 3796) @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8" ?> + +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1492" + default-access="field.camelcase-underscore"> + + <class name="Entity" table="EntityTable"> + <id name="Id" column="EntityID"> + <generator class="native" /> + </id> + + <property name="Code" column="Code" /> + <property name="Description" column="Description" /> + <property name="Deleted" column="Deleted" /> + + <bag name="Childs" lazy="true" table="ChildsTable" generic="true" inverse="true" cascade="all-delete-orphan"> + <key column="ParentID" /> + <one-to-many class="ChildEntity" /> + </bag> + + <filter name="excludeDeletedRows" condition="(Deleted IS NULL OR Deleted != :deleted)"/> + </class> + + <class name="ChildEntity" table="ChildEntityTable"> + <id name="Id" column="ChildEntityID"> + <generator class="native" /> + </id> + + <property name="Description" column="Description" /> + + <many-to-one name="Parent" column="ParentID" class="Entity" /> + + </class> + + <filter-def name="excludeDeletedRows"> + <filter-param name="deleted" type="String"/> + </filter-def> + +</hibernate-mapping> Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml ___________________________________________________________________ Added: svn:mergeinfo + Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-09-28 22:40:10 UTC (rev 3795) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-09-29 12:20:13 UTC (rev 3796) @@ -430,6 +430,8 @@ <Compile Include="NHSpecificTest\NH1291AnonExample\Home.cs" /> <Compile Include="NHSpecificTest\NH1291AnonExample\NH1291AnonExampleFixture.cs" /> <Compile Include="NHSpecificTest\NH1291AnonExample\Person.cs" /> + <Compile Include="NHSpecificTest\NH1293\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1293\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1297\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1297\Model.cs" /> <Compile Include="NHSpecificTest\NH1301\Domain.cs"> @@ -480,6 +482,11 @@ <Compile Include="NHSpecificTest\NH1483\SubClass.cs" /> <Compile Include="NHSpecificTest\NH1488\Domain.cs" /> <Compile Include="NHSpecificTest\NH1488\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1490\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1490\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1492\ChildEntity.cs" /> + <Compile Include="NHSpecificTest\NH1492\Entity.cs" /> + <Compile Include="NHSpecificTest\NH1492\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1499\Document.cs" /> <Compile Include="NHSpecificTest\NH1499\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1499\Person.cs" /> @@ -1472,6 +1479,9 @@ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1293\Mappings.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1490\Mappings.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1492\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1499\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1502\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1488\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2008-09-28 22:40:21
|
Revision: 3795 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3795&view=rev Author: fabiomaulo Date: 2008-09-28 22:40:10 +0000 (Sun, 28 Sep 2008) Log Message: ----------- - Revert patch for NH-1179 (possible breaking change, hope refix it in NH2.1) - Fix NH-1293, NH-1488, NH-1490, NH-1488 Modified Paths: -------------- branches/2.0.x/nhibernate/src/NHibernate/Engine/JoinSequence.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Mappings.hbm.xml branches/2.0.x/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj Added Paths: ----------- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml Modified: branches/2.0.x/nhibernate/src/NHibernate/Engine/JoinSequence.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Engine/JoinSequence.cs 2008-09-28 16:54:05 UTC (rev 3794) +++ branches/2.0.x/nhibernate/src/NHibernate/Engine/JoinSequence.cs 2008-09-28 22:40:10 UTC (rev 3795) @@ -185,11 +185,12 @@ condition = on; } //Start NH1179 ************ - if (string.IsNullOrEmpty(condition)) - { - string filterCondition = join.Joinable.FilterFragment(join.Alias, enabledFilters); - joinFragment.HasFilterCondition = joinFragment.AddCondition(filterCondition); - } + //Patch reverted after NH2.0.0GA to fix some other bugs. + //if (string.IsNullOrEmpty(condition)) + //{ + // string filterCondition = join.Joinable.FilterFragment(join.Alias, enabledFilters); + // joinFragment.HasFilterCondition = joinFragment.AddCondition(filterCondition); + //} //End NH1179 ************ if (withClauseFragment != null) Modified: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs 2008-09-28 16:54:05 UTC (rev 3794) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1179/Fixture.cs 2008-09-28 22:40:10 UTC (rev 3795) @@ -11,9 +11,11 @@ get { return "NH1179"; } } - [Test] + [Test, Ignore("Not supported.")] public void ApplyFilterExplicitJoin() { + // Note: if we fix this we must fix it for Criteria too (NH-1293) + RelatedClass rc1 = new RelatedClass(1); RelatedClass rc2 = new RelatedClass(2); RelatedClass rc11 = new RelatedClass(1); Added: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Domain.cs 2008-09-28 22:40:10 UTC (rev 3795) @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1293 +{ + public class Customer + { + private int id; + private string name; + private Category category; + private bool isActive; + public Customer() {} + public Customer(string name) + { + this.name = name; + } + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual Category Category + { + get { return category; } + set { category = value; } + } + + public virtual bool IsActive + { + get { return isActive; } + set { isActive = value; } + } + } + + public class Category + { + private int id; + private string name; + private bool isActive; + public Category() {} + public Category(string name) + { + this.name = name; + } + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual bool IsActive + { + get { return isActive; } + set { isActive = value; } + } + } +} Added: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs 2008-09-28 22:40:10 UTC (rev 3795) @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using NHibernate.Criterion; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1293 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void Criteria_Does_Not_Equal_To_HQL() + { + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + Customer c = new Customer("Somebody"); + c.Category = new Category("User"); + s.Save(c.Category); + c.IsActive = true; + c.Category.IsActive = false; // this cause diff in query results + s.Save(c); + tx.Commit(); + } + } + + using (ISession s = OpenSession()) + { + s.DisableFilter("onlyActive"); + IFilter fltr = s.EnableFilter("onlyActive"); + fltr.SetParameter("activeFlag", 1); + + // with HQL, Category.IsActive=true filter applied, result count=2 + IQuery hqlQuery = s.CreateQuery("from Customer c where c.Category.Name = ?"); + hqlQuery.SetParameter(0, "User"); // note using positional parameters because of NH-1490 + IList<Customer> hqlResult = hqlQuery.List<Customer>(); + Console.WriteLine(hqlResult.Count); + + // with ICriteria, no Category.IsActive filter applied, result count=1 + ICriteria criteria = s.CreateCriteria(typeof (Customer), "cust").CreateCriteria("Category", "cat"); + criteria.Add(Restrictions.Eq("cat.Name", "User")); + IList<Customer> criteriaResult = criteria.List<Customer>(); + + Console.WriteLine(criteriaResult.Count); + + Assert.That(hqlResult.Count == criteriaResult.Count); + } + + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from Customer"); + s.Delete("from Category"); + tx.Commit(); + } + } + } + } +} \ No newline at end of file Added: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml 2008-09-28 22:40:10 UTC (rev 3795) @@ -0,0 +1,28 @@ +<?xml version="1.0"?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1293"> + <class name="Customer" table="Customer"> + <id name="Id" column="Id"> + <generator class="native" /> + </id> + <property name="Name" not-null="true" /> + <property name="IsActive" not-null="true" /> + <many-to-one name="Category" lazy="false" column="Category_Id" /> + + <filter name="onlyActive" condition=":activeFlag = IsActive" /> + </class> + + <class name="Category" table="Category" mutable="true"> + <id name="Id" column="Id"> + <generator class="native" /> + </id> + <property name="Name" not-null="true" /> + <property name="IsActive" not-null="true" /> + + <filter name="onlyActive" condition=":activeFlag = IsActive" /> + </class> + + <filter-def name="onlyActive"> + <filter-param name="activeFlag" type="int"/> + </filter-def> + +</hibernate-mapping> \ No newline at end of file Modified: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs 2008-09-28 16:54:05 UTC (rev 3794) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Fixture.cs 2008-09-28 22:40:10 UTC (rev 3795) @@ -37,8 +37,8 @@ } } - [Test, Ignore("Not supported.")] - public void PerhapsBug() + [Test] + public void Bug() { using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) Modified: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Mappings.hbm.xml =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Mappings.hbm.xml 2008-09-28 16:54:05 UTC (rev 3794) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1488/Mappings.hbm.xml 2008-09-28 22:40:10 UTC (rev 3795) @@ -3,7 +3,7 @@ assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1488"> - <class name="Category" table="Category" abstract="true"> + <class name="Category" table="Category" mutable="true" abstract="true"> <id name="Id" column="Id"> <generator class="native" /> </id> @@ -11,13 +11,13 @@ <property name="Name" not-null="true" /> <subclass name="CustomerCategory" discriminator-value="C"/> </class> - + <class name="Customer" table="Customer"> <id name="Id" column="Id"> <generator class="native" /> </id> <property name="Name" not-null="true" /> - <many-to-one name="Category" lazy="false" column="Category_Id"/> + <many-to-one name="Category" lazy="false" class="CustomerCategory" column="Category_Id" /> </class> <class name="CustomerNoSmart" table="CustomerNoSmart"> Added: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Domain.cs 2008-09-28 22:40:10 UTC (rev 3795) @@ -0,0 +1,69 @@ +namespace NHibernate.Test.NHSpecificTest.NH1490 +{ + public class Customer + { + private int id; + private string name; + private Category category; + private bool isActive; + public Customer() {} + public Customer(string name) + { + this.name = name; + } + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual Category Category + { + get { return category; } + set { category = value; } + } + + public virtual bool IsActive + { + get { return isActive; } + set { isActive = value; } + } + } + + public class Category + { + private int id; + private string name; + private bool isActive; + public Category() {} + public Category(string name) + { + this.name = name; + } + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual bool IsActive + { + get { return isActive; } + set { isActive = value; } + } + } +} \ No newline at end of file Added: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs 2008-09-28 22:40:10 UTC (rev 3795) @@ -0,0 +1,119 @@ +using System.Collections.Generic; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; + +namespace NHibernate.Test.NHSpecificTest.NH1490 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void Can_Translate_Correctly_Without_Filter() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + Customer c = new Customer("Somebody"); + c.Category = new Category("User"); + c.IsActive = true; + c.Category.IsActive = true; + s.Save(c.Category); + s.Save(c); + tx.Commit(); + } + + using (ISession s = OpenSession()) + { + IQuery query = s.CreateQuery("from Customer c where c.Category.Name = :catName"); + query.SetParameter("catName", "User"); + IList<Customer> customers = query.List<Customer>(); + + Assert.That(customers.Count, Is.EqualTo(1), "Can apply condition on Customer without IFilter"); + } + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from Customer"); + s.Delete("from Category"); + tx.Commit(); + } + } + + [Test] + public void Also_Works_With_Filter() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + Customer c = new Customer("Somebody"); + c.Category = new Category("User"); + s.Save(c.Category); + c.IsActive = true; + c.Category.IsActive = true; + s.Save(c); + tx.Commit(); + } + + using (ISession s = OpenSession()) + { + s.DisableFilter("onlyActive"); + IFilter fltr = s.EnableFilter("onlyActive"); + fltr.SetParameter("activeFlag", 1); + + // Customer is parametrized + IQuery query = s.CreateQuery("from Customer c where c.Name = :customerName"); + query.SetParameter("customerName", "Somebody"); + IList<Customer> customers = query.List<Customer>(); + + Assert.That(customers.Count, Is.EqualTo(1), "IFilter applied and Customer parametrized on Name also works"); + } + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from Customer"); + s.Delete("from Category"); + tx.Commit(); + } + } + + [Test] + public void Incorrect_SQL_Translated_Params_Bug() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + Customer c = new Customer("Somebody"); + c.Category = new Category("User"); + s.Save(c.Category); + c.IsActive = true; + c.Category.IsActive = true; + s.Save(c); + tx.Commit(); + } + + using (ISession s = OpenSession()) + { + s.DisableFilter("onlyActive"); + IFilter fltr = s.EnableFilter("onlyActive"); + fltr.SetParameter("activeFlag", 1); + // related entity Customer.Category is parametrized + IQuery query = s.CreateQuery("from Customer c where c.Category.Name = :catName"); + query.SetParameter("catName", "User"); + + IList<Customer> customers = query.List<Customer>(); + + Assert.That(customers.Count, Is.EqualTo(1), "IFIlter applied and Customer parametrized on Category.Name DOES NOT work"); + } + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from Customer"); + s.Delete("from Category"); + tx.Commit(); + } + } + } +} \ No newline at end of file Added: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml 2008-09-28 22:40:10 UTC (rev 3795) @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1490"> + + <class name="Customer" table="Customer"> + <id name="Id" column="Id"> + <generator class="native" /> + </id> + <property name="Name" not-null="true" /> + <property name="IsActive" not-null="true" /> + <many-to-one name="Category" lazy="false" column="Category_Id" /> + + <filter name="onlyActive" condition=":activeFlag = IsActive" /> + </class> + + <class name="Category" table="Category" mutable="true"> + <id name="Id" column="Id"> + <generator class="native" /> + </id> + <property name="Name" not-null="true" /> + <property name="IsActive" not-null="true" /> + + <filter name="onlyActive" condition=":activeFlag = IsActive" /> + </class> + + <filter-def name="onlyActive"> + <filter-param name="activeFlag" type="int"/> + </filter-def> +</hibernate-mapping> \ No newline at end of file Added: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/ChildEntity.cs 2008-09-28 22:40:10 UTC (rev 3795) @@ -0,0 +1,38 @@ +namespace NHibernate.Test.NHSpecificTest.NH1492 +{ + public class ChildEntity + { + private string _description; + private int _id; + private Entity _parent; + public ChildEntity() {} + + public ChildEntity(Entity parent, string description) + { + _description = description; + if (parent != null) + { + _parent = parent; + _parent.Childs.Add(this); + } + } + + public virtual int Id + { + get { return _id; } + set { _id = value; } + } + + public virtual string Description + { + get { return _description; } + set { _description = value; } + } + + public virtual Entity Parent + { + get { return _parent; } + set { _parent = value; } + } + } +} \ No newline at end of file Added: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Entity.cs 2008-09-28 22:40:10 UTC (rev 3795) @@ -0,0 +1,50 @@ +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1492 +{ + public class Entity + { + private IList<ChildEntity> _childs = new List<ChildEntity>(); + private int _code; + private string _deleted; + private string _description; + private int _id; + public Entity() {} + + public Entity(int code, string description) + { + _code = code; + _description = description; + } + + public virtual int Id + { + get { return _id; } + set { _id = value; } + } + + public virtual int Code + { + get { return _code; } + set { _code = value; } + } + + public virtual string Description + { + get { return _description; } + set { _description = value; } + } + + public virtual string Deleted + { + get { return _deleted; } + set { _deleted = value; } + } + + public virtual IList<ChildEntity> Childs + { + get { return _childs; } + set { _childs = value; } + } + } +} \ No newline at end of file Added: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Fixture.cs 2008-09-28 22:40:10 UTC (rev 3795) @@ -0,0 +1,46 @@ +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1492 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void RetrieveEntities() + { + Entity eDel = new Entity(1, "DeletedEntity"); + eDel.Deleted = "Y"; + + Entity eGood = new Entity(2, "GoodEntity"); + eGood.Childs.Add(new ChildEntity(eGood, "GoodEntityChild")); + + // Make "Deleted" entity persistent + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(eDel); + s.Save(eGood); + t.Commit(); + } + + // Retrive (check if the entity was well persisted) + IList<ChildEntity> childs; + using (ISession s = OpenSession()) + { + s.EnableFilter("excludeDeletedRows").SetParameter("deleted", "Y"); + + IQuery q = s.CreateQuery("FROM ChildEntity c WHERE c.Parent.Code = :parentCode").SetParameter("parentCode", 2); + childs= q.List<ChildEntity>(); + } + Assert.AreEqual(1, childs.Count); + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Delete("from Entity"); + t.Commit(); + } + } + } +} \ No newline at end of file Added: branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml (rev 0) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1492/Mappings.hbm.xml 2008-09-28 22:40:10 UTC (rev 3795) @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8" ?> + +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1492" + default-access="field.camelcase-underscore"> + + <class name="Entity" table="EntityTable"> + <id name="Id" column="EntityID"> + <generator class="native" /> + </id> + + <property name="Code" column="Code" /> + <property name="Description" column="Description" /> + <property name="Deleted" column="Deleted" /> + + <bag name="Childs" lazy="true" table="ChildsTable" generic="true" inverse="true" cascade="all-delete-orphan"> + <key column="ParentID" /> + <one-to-many class="ChildEntity" /> + </bag> + + <filter name="excludeDeletedRows" condition="(Deleted IS NULL OR Deleted != :deleted)"/> + </class> + + <class name="ChildEntity" table="ChildEntityTable"> + <id name="Id" column="ChildEntityID"> + <generator class="native" /> + </id> + + <property name="Description" column="Description" /> + + <many-to-one name="Parent" column="ParentID" class="Entity" /> + + </class> + + <filter-def name="excludeDeletedRows"> + <filter-param name="deleted" type="String"/> + </filter-def> + +</hibernate-mapping> Modified: branches/2.0.x/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-09-28 16:54:05 UTC (rev 3794) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-09-28 22:40:10 UTC (rev 3795) @@ -327,6 +327,8 @@ <Compile Include="NHSpecificTest\NH1275\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1290\AuxType.cs" /> <Compile Include="NHSpecificTest\NH1290\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1293\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1293\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1300\Domain.cs" /> <Compile Include="NHSpecificTest\NH1300\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1301\Domain.cs" /> @@ -373,6 +375,11 @@ <Compile Include="NHSpecificTest\NH1483\SubClass.cs" /> <Compile Include="NHSpecificTest\NH1488\Domain.cs" /> <Compile Include="NHSpecificTest\NH1488\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1490\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1490\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1492\ChildEntity.cs" /> + <Compile Include="NHSpecificTest\NH1492\Entity.cs" /> + <Compile Include="NHSpecificTest\NH1492\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1499\Document.cs" /> <Compile Include="NHSpecificTest\NH1499\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1499\Person.cs" /> @@ -1343,6 +1350,13 @@ <EmbeddedResource Include="NHSpecificTest\NH1499\Mappings.hbm.xml" /> </ItemGroup> <ItemGroup> + <EmbeddedResource Include="NHSpecificTest\NH1490\Mappings.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1492\Mappings.hbm.xml" /> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="NHSpecificTest\NH1293\Mappings.hbm.xml" /> + </ItemGroup> + <ItemGroup> <Folder Include="Properties\" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |