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...> - 2009-02-03 13:55:22
|
Revision: 4019 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4019&view=rev Author: fabiomaulo Date: 2009-02-03 13:55:19 +0000 (Tue, 03 Feb 2009) Log Message: ----------- Increase Oracle code-coverage Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/GeneratedTest/ComponentOwner.hbm.xml trunk/nhibernate/src/NHibernate.Test/GeneratedTest/GeneratedPropertyEntity.hbm.xml trunk/nhibernate/src/NHibernate.Test/GeneratedTest/PartiallyGeneratedComponentTest.cs trunk/nhibernate/src/NHibernate.Test/GeneratedTest/TriggerGeneratedValuesWithCachingTest.cs trunk/nhibernate/src/NHibernate.Test/GeneratedTest/TriggerGeneratedValuesWithoutCachingTest.cs Modified: trunk/nhibernate/src/NHibernate.Test/GeneratedTest/ComponentOwner.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GeneratedTest/ComponentOwner.hbm.xml 2009-02-03 13:35:19 UTC (rev 4018) +++ trunk/nhibernate/src/NHibernate.Test/GeneratedTest/ComponentOwner.hbm.xml 2009-02-03 13:55:19 UTC (rev 4019) @@ -29,7 +29,10 @@ </drop> <dialect-scope name="NHibernate.Dialect.Oracle9Dialect"/> <dialect-scope name="NHibernate.Dialect.OracleDialect"/> - </database-object> + <dialect-scope name="NHibernate.Dialect.Oracle8iDialect"/> + <dialect-scope name="NHibernate.Dialect.Oracle9iDialect"/> + <dialect-scope name="NHibernate.Dialect.Oracle10gDialect"/> + </database-object> <database-object> <create> Modified: trunk/nhibernate/src/NHibernate.Test/GeneratedTest/GeneratedPropertyEntity.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GeneratedTest/GeneratedPropertyEntity.hbm.xml 2009-02-03 13:35:19 UTC (rev 4018) +++ trunk/nhibernate/src/NHibernate.Test/GeneratedTest/GeneratedPropertyEntity.hbm.xml 2009-02-03 13:55:19 UTC (rev 4019) @@ -31,9 +31,12 @@ <drop> <![CDATA[DROP TRIGGER t_iu_gen_prop]]> </drop> - <dialect-scope name="NHibernate.Dialect.Oracle9Dialect"/> - <dialect-scope name="NHibernate.Dialect.OracleDialect"/> - </database-object> + <dialect-scope name="NHibernate.Dialect.Oracle9Dialect"/> + <dialect-scope name="NHibernate.Dialect.OracleDialect"/> + <dialect-scope name="NHibernate.Dialect.Oracle8iDialect"/> + <dialect-scope name="NHibernate.Dialect.Oracle9iDialect"/> + <dialect-scope name="NHibernate.Dialect.Oracle10gDialect"/> + </database-object> <database-object> <create> Modified: trunk/nhibernate/src/NHibernate.Test/GeneratedTest/PartiallyGeneratedComponentTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GeneratedTest/PartiallyGeneratedComponentTest.cs 2009-02-03 13:35:19 UTC (rev 4018) +++ trunk/nhibernate/src/NHibernate.Test/GeneratedTest/PartiallyGeneratedComponentTest.cs 2009-02-03 13:55:19 UTC (rev 4019) @@ -21,7 +21,8 @@ protected override bool AppliesTo(Dialect.Dialect dialect) { - return dialect is MsSql2000Dialect || dialect is FirebirdDialect || dialect is Oracle9Dialect; + return dialect is MsSql2000Dialect || dialect is FirebirdDialect || dialect is Oracle9Dialect + || dialect is Oracle8iDialect; } [Test] Modified: trunk/nhibernate/src/NHibernate.Test/GeneratedTest/TriggerGeneratedValuesWithCachingTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GeneratedTest/TriggerGeneratedValuesWithCachingTest.cs 2009-02-03 13:35:19 UTC (rev 4018) +++ trunk/nhibernate/src/NHibernate.Test/GeneratedTest/TriggerGeneratedValuesWithCachingTest.cs 2009-02-03 13:55:19 UTC (rev 4019) @@ -17,7 +17,7 @@ protected override bool AppliesTo(Dialect.Dialect dialect) { - return dialect is MsSql2000Dialect || dialect is Oracle9Dialect; + return dialect is MsSql2000Dialect || dialect is Oracle9Dialect || dialect is Oracle8iDialect; } } } Modified: trunk/nhibernate/src/NHibernate.Test/GeneratedTest/TriggerGeneratedValuesWithoutCachingTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GeneratedTest/TriggerGeneratedValuesWithoutCachingTest.cs 2009-02-03 13:35:19 UTC (rev 4018) +++ trunk/nhibernate/src/NHibernate.Test/GeneratedTest/TriggerGeneratedValuesWithoutCachingTest.cs 2009-02-03 13:55:19 UTC (rev 4019) @@ -17,7 +17,7 @@ protected override bool AppliesTo(Dialect.Dialect dialect) { - return dialect is MsSql2000Dialect || dialect is Oracle9Dialect; + return dialect is MsSql2000Dialect || dialect is Oracle9Dialect || dialect is Oracle8iDialect; } protected override string CacheConcurrencyStrategy This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-02-03 13:35:21
|
Revision: 4018 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4018&view=rev Author: fabiomaulo Date: 2009-02-03 13:35:19 +0000 (Tue, 03 Feb 2009) Log Message: ----------- Ignore some "cast" test for Oracle Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-03 12:45:32 UTC (rev 4017) +++ trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-03 13:35:19 UTC (rev 4018) @@ -590,17 +590,23 @@ Assert.AreEqual(7f + 123f - 5f * 1.3f, l[0]); // Rendered in SELECT using a property and nested functions - hql = "select cast(cast(a.BodyWeight as string) as Double) from Animal a"; - l = s.CreateQuery(hql).List(); - Assert.AreEqual(1, l.Count); - Assert.AreEqual(1.3F, l[0]); + if (!(Dialect is Oracle8iDialect)) + { + hql = "select cast(cast(a.BodyWeight as string) as Double) from Animal a"; + l = s.CreateQuery(hql).List(); + Assert.AreEqual(1, l.Count); + Assert.AreEqual(1.3F, l[0]); + } // TODO: Rendered in SELECT using string costant assigned with critic chars (separators) // Rendered in WHERE using a property - hql = "from Animal a where cast(a.BodyWeight as string) like '1.%'"; - result = (Animal)s.CreateQuery(hql).UniqueResult(); - Assert.AreEqual("abcdef", result.Description); + if (!(Dialect is Oracle8iDialect)) + { + hql = "from Animal a where cast(a.BodyWeight as string) like '1.%'"; + result = (Animal) s.CreateQuery(hql).UniqueResult(); + Assert.AreEqual("abcdef", result.Description); + } // Rendered in WHERE using a property in an operation with costants hql = "from Animal a where cast(7+123-2*a.BodyWeight as Double)>0"; @@ -615,9 +621,12 @@ Assert.AreEqual("abcdef", result.Description); // Rendered in WHERE using a property and nested functions - hql = "from Animal a where cast(cast(cast(a.BodyWeight as string) as double) as int) = 1"; - result = (Animal)s.CreateQuery(hql).UniqueResult(); - Assert.AreEqual("abcdef", result.Description); + if (!(Dialect is Oracle8iDialect)) + { + hql = "from Animal a where cast(cast(cast(a.BodyWeight as string) as double) as int) = 1"; + result = (Animal) s.CreateQuery(hql).UniqueResult(); + Assert.AreEqual("abcdef", result.Description); + } // Rendered in GROUP BY using a property hql = "select cast(a.BodyWeight as Double) from Animal a group by cast(a.BodyWeight as Double)"; @@ -632,10 +641,14 @@ Assert.AreEqual(7f + 123f - 5f * 1.3f, l[0]); // Rendered in GROUP BY using a property and nested functions - hql = "select cast(cast(a.BodyWeight as string) as Double) from Animal a group by cast(cast(a.BodyWeight as string) as Double)"; - l = s.CreateQuery(hql).List(); - Assert.AreEqual(1, l.Count); - Assert.AreEqual(1.3F, l[0]); + if (!(Dialect is Oracle8iDialect)) + { + hql = + "select cast(cast(a.BodyWeight as string) as Double) from Animal a group by cast(cast(a.BodyWeight as string) as Double)"; + l = s.CreateQuery(hql).List(); + Assert.AreEqual(1, l.Count); + Assert.AreEqual(1.3F, l[0]); + } // Rendered in HAVING using a property hql = "select cast(a.BodyWeight as Double) from Animal a group by cast(a.BodyWeight as Double) having cast(a.BodyWeight as Double)>0"; @@ -664,21 +677,32 @@ } catch (ADOException ex) { - // This test raises an exception in SQL Server because named - // parameters internally are always positional (@p0, @p1, etc.) - // and named differently hence they mismatch between GROUP BY and HAVING clauses. - if (!ex.InnerException.Message.Equals( - "Column 'Animal.BodyWeight' is invalid in the HAVING clause " + - "because it is not contained in either an aggregate function or the GROUP BY clause.")) - throw; + if (Dialect is Oracle8iDialect) + { + if (!ex.InnerException.Message.StartsWith("ORA-00979")) + throw; + } + else + { + string msgToCheck = + "Column 'Animal.BodyWeight' is invalid in the HAVING clause because it is not contained in either an aggregate function or the GROUP BY clause."; + // This test raises an exception in SQL Server because named + // parameters internally are always positional (@p0, @p1, etc.) + // and named differently hence they mismatch between GROUP BY and HAVING clauses. + if (!ex.InnerException.Message.Equals(msgToCheck)) + throw; + } } // Rendered in HAVING using a property and nested functions - string castExpr = "cast(cast(cast(a.BodyWeight as string) as double) as int)"; - hql = string.Format("select {0} from Animal a group by {0} having {0} = 1", castExpr); - l = s.CreateQuery(hql).List(); - Assert.AreEqual(1, l.Count); - Assert.AreEqual(1, l[0]); + if (!(Dialect is Oracle8iDialect)) + { + string castExpr = "cast(cast(cast(a.BodyWeight as string) as double) as int)"; + hql = string.Format("select {0} from Animal a group by {0} having {0} = 1", castExpr); + l = s.CreateQuery(hql).List(); + Assert.AreEqual(1, l.Count); + Assert.AreEqual(1, l[0]); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-02-03 12:45:35
|
Revision: 4017 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4017&view=rev Author: fabiomaulo Date: 2009-02-03 12:45:32 +0000 (Tue, 03 Feb 2009) Log Message: ----------- Example of OracleClientExceptionConverterExample Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/OracleClientExceptionConverterExample.cs Added: trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/OracleClientExceptionConverterExample.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/OracleClientExceptionConverterExample.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/OracleClientExceptionConverterExample.cs 2009-02-03 12:45:32 UTC (rev 4017) @@ -0,0 +1,31 @@ +using System; +using System.Data.OracleClient; +using NHibernate.Exceptions; +using NHibernate.SqlCommand; + +namespace NHibernate.Test.ExceptionsTest +{ + public class OracleClientExceptionConverterExample : ISQLExceptionConverter + { + #region ISQLExceptionConverter Members + + public ADOException Convert(Exception sqlException, string message, SqlString sql) + { + var sqle = ADOExceptionHelper.ExtractDbException(sqlException) as OracleException; + if (sqle != null) + { + if (sqle.Code == 1036) + { + return new ConstraintViolationException(message, sqle.InnerException, sql, null); + } + if (sqle.Code == 942) + { + return new SQLGrammarException(message, sqle.InnerException, sql); + } + } + return SQLStateConverter.HandledNonSpecificException(sqlException, message, sql); + } + + #endregion + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs 2009-02-03 04:21:15 UTC (rev 4016) +++ trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs 2009-02-03 12:45:32 UTC (rev 4017) @@ -18,16 +18,21 @@ protected override IList Mappings { - get { return new string[] { "ExceptionsTest.User.hbm.xml", "ExceptionsTest.Group.hbm.xml" }; } + get { return new[] { "ExceptionsTest.User.hbm.xml", "ExceptionsTest.Group.hbm.xml" }; } } protected override void Configure(Cfg.Configuration configuration) { if(Dialect is MsSql2000Dialect) { - configuration.SetProperty(NHibernate.Cfg.Environment.SqlExceptionConverter, + configuration.SetProperty(Cfg.Environment.SqlExceptionConverter, typeof (MSSQLExceptionConverterExample).AssemblyQualifiedName); } + if (Dialect is Oracle8iDialect) + { + configuration.SetProperty(Cfg.Environment.SqlExceptionConverter, + typeof(OracleClientExceptionConverterExample).AssemblyQualifiedName); + } } [Test] Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-03 04:21:15 UTC (rev 4016) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-03 12:45:32 UTC (rev 4017) @@ -65,6 +65,7 @@ <Reference Include="System" /> <Reference Include="System.configuration" /> <Reference Include="System.Data" /> + <Reference Include="System.Data.OracleClient" /> <Reference Include="System.Transactions" /> <Reference Include="System.Xml" /> </ItemGroup> @@ -197,6 +198,7 @@ <Compile Include="Events\Collections\Values\ValuesBagCollectionEventFixture.cs" /> <Compile Include="ExceptionsTest\Group.cs" /> <Compile Include="ExceptionsTest\MSSQLExceptionConverterExample.cs" /> + <Compile Include="ExceptionsTest\OracleClientExceptionConverterExample.cs" /> <Compile Include="ExceptionsTest\PropertyAccessExceptionFixture.cs" /> <Compile Include="ExceptionsTest\SQLExceptionConversionTest.cs" /> <Compile Include="ExceptionsTest\User.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-02-03 04:21:18
|
Revision: 4016 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4016&view=rev Author: fabiomaulo Date: 2009-02-03 04:21:15 +0000 (Tue, 03 Feb 2009) Log Message: ----------- Fix NH-1582 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs 2009-02-03 03:50:06 UTC (rev 4015) +++ trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs 2009-02-03 04:21:15 UTC (rev 4016) @@ -41,6 +41,7 @@ RegisterColumnType(DbType.AnsiStringFixedLength, "TEXT"); RegisterColumnType(DbType.StringFixedLength, "TEXT"); + RegisterColumnType(DbType.Date, "DATETIME"); RegisterColumnType(DbType.DateTime, "DATETIME"); RegisterColumnType(DbType.Time, "DATETIME"); RegisterColumnType(DbType.Boolean, "INTEGER"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-02-03 03:50:09
|
Revision: 4015 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4015&view=rev Author: fabiomaulo Date: 2009-02-03 03:50:06 +0000 (Tue, 03 Feb 2009) Log Message: ----------- Minor Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs 2009-02-02 22:17:07 UTC (rev 4014) +++ trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs 2009-02-03 03:50:06 UTC (rev 4015) @@ -214,7 +214,8 @@ protected internal virtual void RegisterDefaultProperties() { DefaultProperties[Environment.PrepareSql] = "false"; - DefaultProperties[Environment.DefaultBatchFetchSize] = DefaultBatchSize; + //DefaultProperties[Environment.DefaultBatchFetchSize] = DefaultBatchSize; It can break some test and it is a user matter + // Oracle driver reports to support GetGeneratedKeys(), but they only // support the version taking an array of the names of the columns to // be returned (via its RETURNING clause). No other driver seems to This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-02-02 22:57:46
|
Revision: 4014 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4014&view=rev Author: fabiomaulo Date: 2009-02-02 22:17:07 +0000 (Mon, 02 Feb 2009) Log Message: ----------- Hql changed in nullif function for Oracle dialects Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-02 21:33:58 UTC (rev 4013) +++ trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-02 22:17:07 UTC (rev 4014) @@ -18,13 +18,20 @@ static HQLFunctions() { notSupportedStandardFunction.Add("locate", - new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) ,typeof(FirebirdDialect), typeof(PostgreSQLDialect) }); + new[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) ,typeof(FirebirdDialect), typeof(PostgreSQLDialect) }); notSupportedStandardFunction.Add("bit_length", - new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect), typeof(Oracle9Dialect), typeof(OracleDialect), typeof(Oracle8iDialect), typeof(Oracle9iDialect), typeof(Oracle10gDialect) }); + new[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect), typeof(Oracle9Dialect), typeof(OracleDialect), typeof(Oracle8iDialect), typeof(Oracle9iDialect), typeof(Oracle10gDialect) }); notSupportedStandardFunction.Add("extract", - new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) }); + new[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) }); + notSupportedStandardFunction.Add("nullif", + new[] { typeof(OracleDialect), typeof(Oracle8iDialect)}); } + private bool IsOracleDialect() + { + return typeof (Oracle8iDialect).IsInstanceOfType(Dialect); + } + private void IgnoreIfNotSupported(string functionName) { if (notSupportedStandardFunction.ContainsKey(functionName)) @@ -402,14 +409,23 @@ public void Nullif() { IgnoreIfNotSupported("nullif"); + string hql1, hql2; + if(!IsOracleDialect()) + { + hql1 = "select nullif(h.NickName, '1e1') from Human h"; + hql2 = "from Human h where nullif(h.NickName, '1e1') not is null"; + } + else + { + // Oracle need same specific types + hql1 = "select nullif(str(h.NickName), '1e1') from Human h"; + hql2 = "from Human h where nullif(str(h.NickName), '1e1') not is null"; + } // test only the parser and render using (ISession s = OpenSession()) { - string hql = "select nullif(h.NickName, '1e1') from Human h"; - IList result = s.CreateQuery(hql).List(); - - hql = "from Human h where nullif(h.NickName, '1e1') not is null"; - result = s.CreateQuery(hql).List(); + IList result = s.CreateQuery(hql1).List(); + result = s.CreateQuery(hql2).List(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-02-02 22:16:29
|
Revision: 4013 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4013&view=rev Author: fabiomaulo Date: 2009-02-02 21:33:58 +0000 (Mon, 02 Feb 2009) Log Message: ----------- - New Oracle dialects - Updated ignore list in some tests NOTE : Old Oracle dialects will be removed in a future NH version. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs trunk/nhibernate/src/NHibernate/Dialect/OracleDialect.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/Cascade/RefreshFixture.cs trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs trunk/nhibernate/src/NHibernate.Test/TypesTest/BinaryTypeFixture.cs trunk/nhibernate/src/NHibernate.Test/TypesTest/DoubleTypeFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/Dialect/Oracle10gDialect.cs trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs trunk/nhibernate/src/NHibernate/Dialect/Oracle9iDialect.cs Added: trunk/nhibernate/src/NHibernate/Dialect/Oracle10gDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Oracle10gDialect.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Dialect/Oracle10gDialect.cs 2009-02-02 21:33:58 UTC (rev 4013) @@ -0,0 +1,19 @@ +using NHibernate.SqlCommand; + +namespace NHibernate.Dialect +{ + /// <summary> + /// A dialect specifically for use with Oracle 10g. + /// </summary> + /// <remarks> + /// The main difference between this dialect and <see cref="Oracle9iDialect"/> + /// is the use of "ANSI join syntax" here... + /// </remarks> + public class Oracle10gDialect : Oracle9iDialect + { + public override JoinFragment CreateOuterJoinFragment() + { + return new ANSIJoinFragment(); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Dialect/Oracle8iDialect.cs 2009-02-02 21:33:58 UTC (rev 4013) @@ -0,0 +1,487 @@ +using System; +using System.Collections; +using System.Data; +using NHibernate.Dialect.Function; +using NHibernate.Engine; +using NHibernate.SqlCommand; +using NHibernate.SqlTypes; +using NHibernate.Type; +using Environment=NHibernate.Cfg.Environment; + +namespace NHibernate.Dialect +{ + /// <summary> + /// A dialect for Oracle 8i. + /// </summary> + public class Oracle8iDialect : Dialect + { + public override string CurrentTimestampSelectString + { + get { return "select sysdate from dual"; } + } + + public override string CurrentTimestampSQLFunctionName + { + get { return "sysdate"; } + } + + public override string AddColumnString + { + get { return "add"; } + } + + public override string CascadeConstraintsString + { + get { return " cascade constraints"; } + } + + public override string QuerySequencesString + { + get { return "select sequence_name from user_sequences"; } + } + + public override string SelectGUIDString + { + get { return "select rawtohex(sys_guid()) from dual"; } + } + + public override string CreateTemporaryTableString + { + get { return "create global temporary table"; } + } + + public override string CreateTemporaryTablePostfix + { + get { return "on commit delete rows"; } + } + + public override bool IsCurrentTimestampSelectStringCallable + { + get { return false; } + } + + public Oracle8iDialect() + { + RegisterCharacterTypeMappings(); + RegisterNumericTypeMappings(); + RegisterDateTimeTypeMappings(); + RegisterLargeObjectTypeMappings(); + + RegisterReverseHibernateTypeMappings(); + + RegisterFunctions(); + + RegisterDefaultProperties(); + } + + protected virtual void RegisterCharacterTypeMappings() + { + RegisterColumnType(DbType.AnsiStringFixedLength, "CHAR(255)"); + RegisterColumnType(DbType.AnsiStringFixedLength, 2000, "CHAR($l)"); + RegisterColumnType(DbType.AnsiString, "VARCHAR2(255)"); + RegisterColumnType(DbType.AnsiString, 4000, "VARCHAR2($l)"); + RegisterColumnType(DbType.StringFixedLength, "NCHAR(255)"); + RegisterColumnType(DbType.StringFixedLength, 2000, "NCHAR($l)"); + RegisterColumnType(DbType.String, "NVARCHAR2(255)"); + RegisterColumnType(DbType.String, 4000, "NVARCHAR2($l)"); + } + + protected virtual void RegisterNumericTypeMappings() + { + RegisterColumnType(DbType.Boolean, "NUMBER(1,0)"); + RegisterColumnType(DbType.Byte, "NUMBER(3,0)"); + RegisterColumnType(DbType.Int16, "NUMBER(5,0)"); + RegisterColumnType(DbType.Int32, "NUMBER(10,0)"); + RegisterColumnType(DbType.Int64, "NUMBER(20,0)"); + RegisterColumnType(DbType.UInt16, "NUMBER(5,0)"); + RegisterColumnType(DbType.UInt32, "NUMBER(10,0)"); + RegisterColumnType(DbType.UInt64, "NUMBER(20,0)"); + + RegisterColumnType(DbType.Currency, "NUMBER(20,2)"); + RegisterColumnType(DbType.Currency, "NUMBER($p,$s)"); + RegisterColumnType(DbType.Single, "FLOAT(24)"); + RegisterColumnType(DbType.Double, "DOUBLE PRECISION"); + RegisterColumnType(DbType.Double, 19, "NUMBER($p,$s)"); + RegisterColumnType(DbType.Double, 19, "NUMBER(19, $l)"); + RegisterColumnType(DbType.Decimal, "NUMBER(19,5)"); + RegisterColumnType(DbType.Decimal, 19, "NUMBER(19, $l)"); + RegisterColumnType(DbType.Decimal, 19, "NUMBER($p,$s)"); + } + + protected virtual void RegisterDateTimeTypeMappings() + { + RegisterColumnType(DbType.Date, "DATE"); + RegisterColumnType(DbType.DateTime, "DATE"); + RegisterColumnType(DbType.Time, "DATE"); + } + + protected virtual void RegisterLargeObjectTypeMappings() + { + RegisterColumnType(DbType.Binary, "RAW(2000)"); + RegisterColumnType(DbType.Binary, 2000, "RAW($l)"); + RegisterColumnType(DbType.Binary, 2147483647, "BLOB"); + RegisterColumnType(DbType.AnsiString, 2147483647, "CLOB"); // should use the IType.ClobType + RegisterColumnType(DbType.String, 1073741823, "NCLOB"); + } + + protected virtual void RegisterReverseHibernateTypeMappings() {} + + protected virtual void RegisterFunctions() + { + RegisterFunction("abs", new StandardSQLFunction("abs")); + RegisterFunction("sign", new StandardSQLFunction("sign", NHibernateUtil.Int32)); + + RegisterFunction("acos", new StandardSQLFunction("acos", NHibernateUtil.Double)); + RegisterFunction("asin", new StandardSQLFunction("asin", NHibernateUtil.Double)); + RegisterFunction("atan", new StandardSQLFunction("atan", NHibernateUtil.Double)); + RegisterFunction("cos", new StandardSQLFunction("cos", NHibernateUtil.Double)); + RegisterFunction("cosh", new StandardSQLFunction("cosh", NHibernateUtil.Double)); + RegisterFunction("exp", new StandardSQLFunction("exp", NHibernateUtil.Double)); + RegisterFunction("ln", new StandardSQLFunction("ln", NHibernateUtil.Double)); + RegisterFunction("sin", new StandardSQLFunction("sin", NHibernateUtil.Double)); + RegisterFunction("sinh", new StandardSQLFunction("sinh", NHibernateUtil.Double)); + RegisterFunction("stddev", new StandardSQLFunction("stddev", NHibernateUtil.Double)); + RegisterFunction("sqrt", new StandardSQLFunction("sqrt", NHibernateUtil.Double)); + RegisterFunction("tan", new StandardSQLFunction("tan", NHibernateUtil.Double)); + RegisterFunction("tanh", new StandardSQLFunction("tanh", NHibernateUtil.Double)); + RegisterFunction("variance", new StandardSQLFunction("variance", NHibernateUtil.Double)); + + RegisterFunction("round", new StandardSQLFunction("round")); + RegisterFunction("trunc", new StandardSQLFunction("trunc")); + RegisterFunction("ceil", new StandardSQLFunction("ceil")); + RegisterFunction("floor", new StandardSQLFunction("floor")); + + RegisterFunction("chr", new StandardSQLFunction("chr", NHibernateUtil.Character)); + RegisterFunction("initcap", new StandardSQLFunction("initcap")); + RegisterFunction("lower", new StandardSQLFunction("lower")); + RegisterFunction("ltrim", new StandardSQLFunction("ltrim")); + RegisterFunction("rtrim", new StandardSQLFunction("rtrim")); + RegisterFunction("soundex", new StandardSQLFunction("soundex")); + RegisterFunction("upper", new StandardSQLFunction("upper")); + RegisterFunction("ascii", new StandardSQLFunction("ascii", NHibernateUtil.Int32)); + RegisterFunction("length", new StandardSQLFunction("length", NHibernateUtil.Int64)); + RegisterFunction("left", new SQLFunctionTemplate(NHibernateUtil.String, "substr(?1, 1, ?2)")); + RegisterFunction("right", new SQLFunctionTemplate(NHibernateUtil.String, "substr(?1, -?2)")); + + RegisterFunction("to_char", new StandardSQLFunction("to_char", NHibernateUtil.String)); + RegisterFunction("to_date", new StandardSQLFunction("to_date", NHibernateUtil.Timestamp)); + + RegisterFunction("current_date", new NoArgSQLFunction("current_date", NHibernateUtil.Date, false)); + RegisterFunction("current_time", new NoArgSQLFunction("current_timestamp", NHibernateUtil.Time, false)); + RegisterFunction("current_timestamp", new CurrentTimeStamp()); + + RegisterFunction("last_day", new StandardSQLFunction("last_day", NHibernateUtil.Date)); + RegisterFunction("sysdate", new NoArgSQLFunction("sysdate", NHibernateUtil.Date, false)); + RegisterFunction("systimestamp", new NoArgSQLFunction("systimestamp", NHibernateUtil.Timestamp, false)); + RegisterFunction("uid", new NoArgSQLFunction("uid", NHibernateUtil.Int32, false)); + RegisterFunction("user", new NoArgSQLFunction("user", NHibernateUtil.String, false)); + + RegisterFunction("rowid", new NoArgSQLFunction("rowid", NHibernateUtil.Int64, false)); + RegisterFunction("rownum", new NoArgSQLFunction("rownum", NHibernateUtil.Int64, false)); + + // Multi-param string dialect functions... + RegisterFunction("instr", new StandardSQLFunction("instr", NHibernateUtil.Int32)); + RegisterFunction("instrb", new StandardSQLFunction("instrb", NHibernateUtil.Int32)); + RegisterFunction("lpad", new StandardSQLFunction("lpad", NHibernateUtil.String)); + RegisterFunction("replace", new StandardSQLFunction("replace", NHibernateUtil.String)); + RegisterFunction("rpad", new StandardSQLFunction("rpad", NHibernateUtil.String)); + RegisterFunction("substr", new StandardSQLFunction("substr", NHibernateUtil.String)); + RegisterFunction("substrb", new StandardSQLFunction("substrb", NHibernateUtil.String)); + RegisterFunction("translate", new StandardSQLFunction("translate", NHibernateUtil.String)); + + RegisterFunction("locate", new LocateFunction()); + RegisterFunction("substring", new StandardSQLFunction("substr", NHibernateUtil.String)); + RegisterFunction("locate", new SQLFunctionTemplate(NHibernateUtil.Int32, "instr(?2,?1)")); + RegisterFunction("bit_length", new SQLFunctionTemplate(NHibernateUtil.Int32, "vsize(?1)*8")); + RegisterFunction("coalesce", new NvlFunction()); + + // Multi-param numeric dialect functions... + RegisterFunction("atan2", new StandardSQLFunction("atan2", NHibernateUtil.Single)); + RegisterFunction("log", new StandardSQLFunction("log", NHibernateUtil.Int32)); + RegisterFunction("mod", new StandardSQLFunction("mod", NHibernateUtil.Int32)); + RegisterFunction("nvl", new StandardSQLFunction("nvl")); + RegisterFunction("nvl2", new StandardSQLFunction("nvl2")); + RegisterFunction("power", new StandardSQLFunction("power", NHibernateUtil.Single)); + + // Multi-param date dialect functions... + RegisterFunction("add_months", new StandardSQLFunction("add_months", NHibernateUtil.Date)); + RegisterFunction("months_between", new StandardSQLFunction("months_between", NHibernateUtil.Single)); + RegisterFunction("next_day", new StandardSQLFunction("next_day", NHibernateUtil.Date)); + + RegisterFunction("str", new StandardSQLFunction("to_char", NHibernateUtil.String)); + } + + protected internal virtual void RegisterDefaultProperties() + { + DefaultProperties[Environment.PrepareSql] = "false"; + DefaultProperties[Environment.DefaultBatchFetchSize] = DefaultBatchSize; + // Oracle driver reports to support GetGeneratedKeys(), but they only + // support the version taking an array of the names of the columns to + // be returned (via its RETURNING clause). No other driver seems to + // support this overloaded version. + DefaultProperties[Environment.UseGetGeneratedKeys] = "false"; + } + + // features which change between 8i, 9i, and 10g ~~~~~~~~~~~~~~~~~~~~~~~~~~ + + /// <summary> + /// Support for the oracle proprietary join syntax... + /// </summary> + /// <returns> The orqacle join fragment </returns> + public override JoinFragment CreateOuterJoinFragment() + { + return new OracleJoinFragment(); + } + + /// <summary> + /// Map case support to the Oracle DECODE function. Oracle did not + /// add support for CASE until 9i. + /// </summary> + /// <returns> The oracle CASE -> DECODE fragment </returns> + public override CaseFragment CreateCaseFragment() + { + return new DecodeCaseFragment(this); + } + + public override SqlString GetLimitString(SqlString sql, bool hasOffset) + { + sql = sql.Trim(); + bool isForUpdate = false; + if (sql.EndsWithCaseInsensitive(" for update")) + { + sql = sql.Substring(0, sql.Length - 11); + isForUpdate = true; + } + + var pagingSelect = new SqlStringBuilder(sql.Parts.Count + 10); + if (hasOffset) + { + pagingSelect.Add("select * from ( select row_.*, rownum rownum_ from ( "); + } + else + { + pagingSelect.Add("select * from ( "); + } + pagingSelect.Add(sql); + if (hasOffset) + { + pagingSelect.Add(" ) row_ where rownum <=").AddParameter().Add(") where rownum_ >").AddParameter(); + } + else + { + pagingSelect.Add(" ) where rownum <=").AddParameter(); + } + + if (isForUpdate) + { + pagingSelect.Add(" for update"); + } + + return pagingSelect.ToSqlString(); + } + + /// <summary> + /// Allows access to the basic <see cref="Dialect.GetSelectClauseNullString"/> + /// implementation... + /// </summary> + /// <param name="sqlType">The <see cref="SqlType"/> mapping type</param> + /// <returns> The appropriate select cluse fragment </returns> + public virtual string GetBasicSelectClauseNullString(SqlType sqlType) + { + return base.GetSelectClauseNullString(sqlType); + } + + public override string GetSelectClauseNullString(SqlType sqlType) + { + switch (sqlType.DbType) + { + case DbType.String: + case DbType.AnsiString: + case DbType.StringFixedLength: + case DbType.AnsiStringFixedLength: + return "to_char(null)"; + + case DbType.Date: + case DbType.DateTime: + case DbType.Time: + return "to_date(null)"; + + default: + return "to_number(null)"; + } + } + + public override string GetSequenceNextValString(string sequenceName) + { + return "select " + GetSelectSequenceNextValString(sequenceName) + " from dual"; + } + + public override string GetSelectSequenceNextValString(string sequenceName) + { + return sequenceName + ".nextval"; + } + + public override string GetCreateSequenceString(string sequenceName) + { + return "create sequence " + sequenceName; //starts with 1, implicitly + } + + public override string GetDropSequenceString(string sequenceName) + { + return "drop sequence " + sequenceName; + } + + public override bool DropConstraints + { + get { return false; } + } + + public override string ForUpdateNowaitString + { + get { return " for update nowait"; } + } + + public override bool SupportsSequences + { + get { return true; } + } + + public override bool SupportsPooledSequences + { + get { return true; } + } + + public override bool SupportsLimit + { + get { return true; } + } + + public override string GetForUpdateString(string aliases) + { + return ForUpdateString + " of " + aliases; + } + + public override string GetForUpdateNowaitString(string aliases) + { + return ForUpdateString + " of " + aliases + " nowait"; + } + + public override bool BindLimitParametersInReverseOrder + { + get { return true; } + } + + public override bool UseMaxForLimit + { + get { return true; } + } + + public override bool ForUpdateOfColumns + { + get { return true; } + } + + public override bool SupportsUnionAll + { + get { return true; } + } + + public override bool SupportsCommentOn + { + get { return true; } + } + + public override bool SupportsTemporaryTables + { + get { return true; } + } + + public override string GenerateTemporaryTableName(String baseTableName) + { + string name = base.GenerateTemporaryTableName(baseTableName); + return name.Length > 30 ? name.Substring(1, (30) - (1)) : name; + } + + public override bool DropTemporaryTableAfterUse() + { + return false; + } + + public override bool SupportsCurrentTimestampSelection + { + get { return true; } + } + + #region Overridden informational metadata + + public override bool SupportsEmptyInList + { + get { return false; } + } + + public override bool SupportsExistsInSelect + { + get { return false; } + } + + #endregion + + #region Functions + + private class CurrentTimeStamp : NoArgSQLFunction + { + public CurrentTimeStamp() : base("current_timestamp", NHibernateUtil.DateTime, true) {} + + public override SqlString Render(IList args, ISessionFactoryImplementor factory) + { + return new SqlString(Name); + } + } + + private class LocateFunction : ISQLFunction + { + private static readonly ISQLFunction LocateWith2Params = new SQLFunctionTemplate(NHibernateUtil.Int32, + "instr(?2, ?1)"); + + private static readonly ISQLFunction LocateWith3Params = new SQLFunctionTemplate(NHibernateUtil.Int32, + "instr(?2, ?1, ?3)"); + + #region Implementation of ISQLFunction + + public IType ReturnType(IType columnType, IMapping mapping) + { + return NHibernateUtil.Int32; + } + + public bool HasArguments + { + get { return true; } + } + + public bool HasParenthesesIfNoArguments + { + get { return true; } + } + + public SqlString Render(IList args, ISessionFactoryImplementor factory) + { + if (args.Count != 2 && args.Count != 3) + { + throw new QueryException("'locate' function takes 2 or 3 arguments"); + } + if (args.Count == 2) + { + return LocateWith2Params.Render(args, factory); + } + else + { + return LocateWith3Params.Render(args, factory); + } + } + + #endregion + } + + #endregion + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs 2009-02-02 20:48:55 UTC (rev 4012) +++ trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs 2009-02-02 21:33:58 UTC (rev 4013) @@ -1,3 +1,4 @@ +using System; using System.Collections; using System.Data; using NHibernate.Dialect.Function; @@ -30,6 +31,7 @@ /// </item> /// </list> /// </remarks> + [Obsolete("This dialect will be removed in the next NHibernate version; Use Oracle9iDialect")] public class Oracle9Dialect : Dialect { /// <summary></summary> Added: trunk/nhibernate/src/NHibernate/Dialect/Oracle9iDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Oracle9iDialect.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Dialect/Oracle9iDialect.cs 2009-02-02 21:33:58 UTC (rev 4013) @@ -0,0 +1,40 @@ +using System.Data; +using NHibernate.SqlCommand; +using NHibernate.SqlTypes; + +namespace NHibernate.Dialect +{ + public class Oracle9iDialect : Oracle8iDialect + { + public override string CurrentTimestampSelectString + { + get { return "select systimestamp from dual"; } + } + + public override string CurrentTimestampSQLFunctionName + { + get + { + // the standard SQL function name is current_timestamp... + return "current_timestamp"; + } + } + + protected override void RegisterDateTimeTypeMappings() + { + RegisterColumnType(DbType.Date, "DATE"); + RegisterColumnType(DbType.DateTime, "TIMESTAMP(4)"); + RegisterColumnType(DbType.Time, "TIMESTAMP(4)"); + } + public override string GetSelectClauseNullString(SqlType sqlType) + { + return GetBasicSelectClauseNullString(sqlType); + } + + public override CaseFragment CreateCaseFragment() + { + // Oracle did add support for ANSI CASE statements in 9i + return new ANSICaseFragment(this); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Dialect/OracleDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/OracleDialect.cs 2009-02-02 20:48:55 UTC (rev 4012) +++ trunk/nhibernate/src/NHibernate/Dialect/OracleDialect.cs 2009-02-02 21:33:58 UTC (rev 4013) @@ -1,3 +1,4 @@ +using System; using System.Data; using NHibernate.SqlCommand; @@ -6,6 +7,7 @@ /// <summary> /// An SQL dialect for Oracle, compatible with Oracle 8. /// </summary> + [Obsolete("This dialect will be removed in the next NHibernate version; Use Oracle8iDialect")] public class OracleDialect : Oracle9Dialect { public OracleDialect() Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-02 20:48:55 UTC (rev 4012) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-02 21:33:58 UTC (rev 4013) @@ -450,6 +450,9 @@ <Compile Include="Dialect\MsSql2008Dialect.cs" /> <Compile Include="Dialect\InformixDialect0940.cs" /> <Compile Include="Dialect\InformixDialect1000.cs" /> + <Compile Include="Dialect\Oracle10gDialect.cs" /> + <Compile Include="Dialect\Oracle8iDialect.cs" /> + <Compile Include="Dialect\Oracle9iDialect.cs" /> <Compile Include="Dialect\OracleLiteDialect.cs" /> <Compile Include="Dialect\Schema\SQLiteMetaData.cs" /> <Compile Include="Dialect\Schema\SybaseAnywhereMetaData.cs" /> Modified: trunk/nhibernate/src/NHibernate.Test/Cascade/RefreshFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Cascade/RefreshFixture.cs 2009-02-02 20:48:55 UTC (rev 4012) +++ trunk/nhibernate/src/NHibernate.Test/Cascade/RefreshFixture.cs 2009-02-02 21:33:58 UTC (rev 4013) @@ -22,30 +22,32 @@ [Test] public void RefreshCascade() { - ISession session = OpenSession(); - ITransaction txn = session.BeginTransaction(); + using(ISession session = OpenSession()) + { + using (ITransaction txn = session.BeginTransaction()) + { + JobBatch batch = new JobBatch(DateTime.Now); + batch.CreateJob().ProcessingInstructions = "Just do it!"; + batch.CreateJob().ProcessingInstructions = "I know you can do it!"; - JobBatch batch = new JobBatch(DateTime.Now); - batch.CreateJob().ProcessingInstructions = "Just do it!"; - batch.CreateJob().ProcessingInstructions = "I know you can do it!"; + // write the stuff to the database; at this stage all job.status values are zero + session.Persist(batch); + session.Flush(); - // write the stuff to the database; at this stage all job.status values are zero - session.Persist(batch); - session.Flush(); + // behind the session's back, let's modify the statuses + UpdateStatuses(session); - // behind the session's back, let's modify the statuses - UpdateStatuses(session); + // Now lets refresh the persistent batch, and see if the refresh cascaded to the jobs collection elements + session.Refresh(batch); - // Now lets refresh the persistent batch, and see if the refresh cascaded to the jobs collection elements - session.Refresh(batch); + foreach (Job job in batch.Jobs) + { + Assert.That(job.Status, Is.EqualTo(1), "Jobs not refreshed!"); + } - foreach (Job job in batch.Jobs) - { - Assert.That(job.Status, Is.EqualTo(1), "Jobs not refreshed!"); + txn.Rollback(); + } } - - txn.Rollback(); - session.Close(); } private void UpdateStatuses(ISession session) @@ -62,33 +64,38 @@ public void RefreshIgnoringTransient() { // No exception expected - ISession session = OpenSession(); - ITransaction txn = session.BeginTransaction(); + using (ISession session = OpenSession()) + { + using (ITransaction txn = session.BeginTransaction()) + { + var batch = new JobBatch(DateTime.Now); + session.Refresh(batch); - var batch = new JobBatch(DateTime.Now); - session.Refresh(batch); - - txn.Rollback(); - session.Close(); + txn.Rollback(); + } + } } [Test] public void RefreshIgnoringTransientInCollection() { - ISession session = OpenSession(); - ITransaction txn = session.BeginTransaction(); + using (ISession session = OpenSession()) + { + using (ITransaction txn = session.BeginTransaction()) + { - var batch = new JobBatch(DateTime.Now); - batch.CreateJob().ProcessingInstructions = "Just do it!"; - session.Persist(batch); - session.Flush(); + var batch = new JobBatch(DateTime.Now); + batch.CreateJob().ProcessingInstructions = "Just do it!"; + session.Persist(batch); + session.Flush(); - batch.CreateJob().ProcessingInstructions = "I know you can do it!"; - session.Refresh(batch); - Assert.That(batch.Jobs.Count == 1); + batch.CreateJob().ProcessingInstructions = "I know you can do it!"; + session.Refresh(batch); + Assert.That(batch.Jobs.Count == 1); - txn.Rollback(); - session.Close(); + txn.Rollback(); + } + } } [Test] Modified: trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-02 20:48:55 UTC (rev 4012) +++ trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-02 21:33:58 UTC (rev 4013) @@ -20,7 +20,7 @@ notSupportedStandardFunction.Add("locate", new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) ,typeof(FirebirdDialect), typeof(PostgreSQLDialect) }); notSupportedStandardFunction.Add("bit_length", - new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) }); + new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect), typeof(Oracle9Dialect), typeof(OracleDialect), typeof(Oracle8iDialect), typeof(Oracle9iDialect), typeof(Oracle10gDialect) }); notSupportedStandardFunction.Add("extract", new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) }); } Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs 2009-02-02 20:48:55 UTC (rev 4012) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs 2009-02-02 21:33:58 UTC (rev 4013) @@ -1,5 +1,6 @@ using System.Text; using NHibernate.Cfg; +using NHibernate.Dialect; using NHibernate.Tool.hbm2ddl; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; @@ -9,6 +10,12 @@ [TestFixture] public class Fixture { + private static void CheckDialect(Configuration configuration) + { + if (!configuration.Properties[Environment.Dialect].Contains("MsSql")) + Assert.Ignore("Specific test for MsSQL dialects"); + } + private static void AssertThatCheckOnTableExistenceIsCorrect(Configuration configuration) { var su = new SchemaExport(configuration); @@ -22,6 +29,7 @@ public void TestForClassWithDefaultSchema() { Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); + CheckDialect(cfg); cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1521.AclassWithNothing.hbm.xml", GetType().Assembly); cfg.SetProperty(Environment.DefaultCatalog, "nhibernate"); cfg.SetProperty(Environment.DefaultSchema, "dbo"); @@ -32,6 +40,7 @@ public void WithDefaultValuesInMapping() { Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); + CheckDialect(cfg); cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1521.AclassWithDefault.hbm.xml", GetType().Assembly); AssertThatCheckOnTableExistenceIsCorrect(cfg); } @@ -40,6 +49,7 @@ public void WithSpecificValuesInMapping() { Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); + CheckDialect(cfg); cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1521.AclassWithSpecific.hbm.xml", GetType().Assembly); AssertThatCheckOnTableExistenceIsCorrect(cfg); } @@ -48,6 +58,7 @@ public void WithDefaultValuesInConfigurationPriorityToMapping() { Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); + CheckDialect(cfg); cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1521.AclassWithDefault.hbm.xml", GetType().Assembly); cfg.SetProperty(Environment.DefaultCatalog, "somethingDifferent"); cfg.SetProperty(Environment.DefaultSchema, "somethingDifferent"); Modified: trunk/nhibernate/src/NHibernate.Test/TypesTest/BinaryTypeFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypesTest/BinaryTypeFixture.cs 2009-02-02 20:48:55 UTC (rev 4012) +++ trunk/nhibernate/src/NHibernate.Test/TypesTest/BinaryTypeFixture.cs 2009-02-02 21:33:58 UTC (rev 4013) @@ -77,9 +77,9 @@ [Test] public void InsertZeroLength() { - if (typeof(Oracle9Dialect).IsInstanceOfType(Dialect)) + if (Dialect is Oracle9Dialect || Dialect is Oracle8iDialect) { - return; + Assert.Ignore("Certain drivers (ie - Oralce) don't handle writing and reading byte[0]"); } BinaryClass bcBinary = new BinaryClass(); bcBinary.Id = 1; Modified: trunk/nhibernate/src/NHibernate.Test/TypesTest/DoubleTypeFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypesTest/DoubleTypeFixture.cs 2009-02-02 20:48:55 UTC (rev 4012) +++ trunk/nhibernate/src/NHibernate.Test/TypesTest/DoubleTypeFixture.cs 2009-02-02 21:33:58 UTC (rev 4013) @@ -21,7 +21,7 @@ protected override void OnSetUp() { base.OnSetUp(); - if (Dialect is Oracle9Dialect) + if (Dialect is Oracle9Dialect || Dialect is Oracle8iDialect) { _values[0] = 1.5e20; _values[1] = 1.2e-20; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-02-02 20:48:58
|
Revision: 4012 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4012&view=rev Author: fabiomaulo Date: 2009-02-02 20:48:55 +0000 (Mon, 02 Feb 2009) Log Message: ----------- revert r4010 (each one should write his own hibernate.cfg.xml without change the app.config) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/App.config Modified: trunk/nhibernate/src/NHibernate.Test/App.config =================================================================== --- trunk/nhibernate/src/NHibernate.Test/App.config 2009-02-02 20:28:46 UTC (rev 4011) +++ trunk/nhibernate/src/NHibernate.Test/App.config 2009-02-02 20:48:55 UTC (rev 4012) @@ -57,20 +57,16 @@ <!-- This is the System.Data.dll provider for MSSQL Server --> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> - <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> - <property name="connection.connection_string">Server=(local);initial catalog=nhibernate;Integrated Security=SSPI</property> + <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> + <property name="connection.connection_string">Server=(local);initial catalog=nhibernate;Integrated Security=SSPI</property> - <!-- This is for running the tests with a MySQL database --> - <!--<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property> - <property name="dialect">NHibernate.Dialect.MySQL5Dialect</property> - <property name="connection.connection_string">Server=localhost;Database=nhibernate;User ID=nhibernate;Password=nhibernate</property>--> - <property name="show_sql">false</property> + <property name="show_sql">false</property> <property name="use_outer_join">true</property> <property name="command_timeout">444</property> <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property> <property name="adonet.wrap_result_sets">false</property> - + <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property> </session-factory> </hibernate-configuration> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-02-02 20:29:16
|
Revision: 4011 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4011&view=rev Author: darioquintana Date: 2009-02-02 20:28:46 +0000 (Mon, 02 Feb 2009) Log Message: ----------- - MsSql2008Dialect added to support DateTime2 and DateTimeOffSet - Changes in tests to support the new dialect and make them pass. - Test for DateTime2 and DateTimeOffSet (all tests green against MsSql2005 and MsSql2008) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate/NHibernateUtil.cs trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs trunk/nhibernate/src/NHibernate.Test/GeneratedTest/ComponentOwner.hbm.xml trunk/nhibernate/src/NHibernate.Test/GeneratedTest/GeneratedPropertyEntity.hbm.xml trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs trunk/nhibernate/src/NHibernate/Type/DateTimeOffSetType.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/TypesTest/Decima2lTypeFixture.cs Added: trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2008Dialect.cs 2009-02-02 20:28:46 UTC (rev 4011) @@ -0,0 +1,13 @@ +using System.Data; + +namespace NHibernate.Dialect +{ + public class MsSql2008Dialect : MsSql2005Dialect + { + public MsSql2008Dialect() + { + RegisterColumnType(DbType.DateTime2, "DATETIME2"); + RegisterColumnType(DbType.DateTimeOffset, "DATETIMEOFFSET"); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-01 20:55:26 UTC (rev 4010) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-02-02 20:28:46 UTC (rev 4011) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.21022</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</ProjectGuid> <OutputType>Library</OutputType> @@ -14,6 +14,7 @@ <OldToolsVersion>2.0</OldToolsVersion> <UpgradeBackupLocation> </UpgradeBackupLocation> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -50,6 +51,9 @@ </Reference> <Reference Include="System" /> <Reference Include="System.configuration" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> <Reference Include="System.Data" /> <Reference Include="System.Data.OracleClient" /> <Reference Include="System.Transactions" /> @@ -443,6 +447,7 @@ <Compile Include="Bytecode\HibernateByteCodeException.cs" /> <Compile Include="Bytecode\ProxyFactoryFactoryNotConfiguredException.cs" /> <Compile Include="Bytecode\UnableToLoadProxyFactoryFactoryException.cs" /> + <Compile Include="Dialect\MsSql2008Dialect.cs" /> <Compile Include="Dialect\InformixDialect0940.cs" /> <Compile Include="Dialect\InformixDialect1000.cs" /> <Compile Include="Dialect\OracleLiteDialect.cs" /> @@ -1074,9 +1079,11 @@ <Compile Include="Type\AnsiCharType.cs" /> <Compile Include="Type\AnyType.cs" /> <Compile Include="Type\AbstractCharType.cs" /> + <Compile Include="Type\DateTime2Type.cs" /> <Compile Include="Type\ClassMetaType.cs" /> <Compile Include="Type\CollectionType.cs" /> <Compile Include="Type\CustomCollectionType.cs" /> + <Compile Include="Type\DateTimeOffSetType.cs" /> <Compile Include="Type\EmbeddedComponentType.cs" /> <Compile Include="Type\EnumCharType.cs" /> <Compile Include="Type\GenericOrderedSetType.cs" /> Modified: trunk/nhibernate/src/NHibernate/NHibernateUtil.cs =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernateUtil.cs 2009-02-01 20:55:26 UTC (rev 4010) +++ trunk/nhibernate/src/NHibernate/NHibernateUtil.cs 2009-02-02 20:28:46 UTC (rev 4011) @@ -115,6 +115,16 @@ /// </summary> public static readonly NullableType DateTime = new DateTimeType(); + /// <summary> + /// NHibernate date type + /// </summary> + public static readonly NullableType DateTime2 = new DateTime2Type(); + + /// <summary> + /// NHibernate date type + /// </summary> + public static readonly NullableType DateTimeOffset = new DateTimeOffsetType(); + /// <summary> /// NHibernate date type /// </summary> Modified: trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-02-01 20:55:26 UTC (rev 4010) +++ trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-02-02 20:28:46 UTC (rev 4011) @@ -25,6 +25,8 @@ public static readonly SqlType Currency = new SqlType(DbType.Currency); public static readonly SqlType Date = new SqlType(DbType.Date); public static readonly SqlType DateTime = new SqlType(DbType.DateTime); + public static readonly SqlType DateTime2 = new SqlType(DbType.DateTime2); + public static readonly SqlType DateTimeOffSet = new SqlType(DbType.DateTimeOffset); public static readonly SqlType Decimal = new SqlType(DbType.Decimal); public static readonly SqlType Double = new SqlType(DbType.Double); public static readonly SqlType Int16 = new SqlType(DbType.Int16); Added: trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Type/DateTime2Type.cs 2009-02-02 20:28:46 UTC (rev 4011) @@ -0,0 +1,23 @@ +using System; +using System.Data; +using NHibernate.SqlTypes; + +namespace NHibernate.Type +{ + /// <summary> + /// Maps a <see cref="System.DateTime" /> Property to a <see cref="DbType.DateTime"/> + /// </summary> + [Serializable] + public class DateTime2Type : DateTimeType + { + /// <summary></summary> + internal DateTime2Type() : base(SqlTypeFactory.DateTime2) + { + } + + public override string Name + { + get { return "DateTime2"; } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Type/DateTimeOffSetType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/DateTimeOffSetType.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Type/DateTimeOffSetType.cs 2009-02-02 20:28:46 UTC (rev 4011) @@ -0,0 +1,124 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using NHibernate.SqlTypes; + +namespace NHibernate.Type +{ + /// <summary> + /// Maps a <see cref="System.DateTimeOffset" /> Property to a <see cref="DbType.DateTimeOffset"/> + /// </summary> + [Serializable] + public class DateTimeOffsetType : DateTimeType + { + /// <summary></summary> + public DateTimeOffsetType() + : base(SqlTypeFactory.DateTimeOffSet) + { + } + + public override string Name + { + get { return "DateTimeOffset"; } + } + + public override System.Type ReturnedClass + { + get + { + return typeof(DateTimeOffset); + } + } + + public override System.Type PrimitiveClass + { + get { return typeof(DateTimeOffset); } + } + + public override void Set(IDbCommand st, object value, int index) + { + DateTimeOffset dateValue = (DateTimeOffset)value; + ((IDataParameter) st.Parameters[index]).Value = + new DateTimeOffset(dateValue.Year, dateValue.Month, dateValue.Day, dateValue.Hour, dateValue.Minute, dateValue.Second,dateValue.Offset); + } + + public override object Get(IDataReader rs, int index) + { + try + { + DateTimeOffset dbValue = (DateTimeOffset)rs[index];; + return new DateTimeOffset(dbValue.Year, dbValue.Month, dbValue.Day, dbValue.Hour, dbValue.Minute, dbValue.Second,dbValue.Offset); + } + catch (Exception ex) + { + throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[index]), ex); + } + } + + public override IComparer Comparator + { + get { return Comparer<DateTimeOffset>.Default; } + } + + public override bool IsEqual(object x, object y) + { + if (x == y) + { + return true; + } + + if (x == null || y == null) + { + return false; + } + + DateTimeOffset date1 = (DateTimeOffset)x; + DateTimeOffset date2 = (DateTimeOffset)y; + + if (date1.Equals(date2)) + return true; + + return (date1.Year == date2.Year && + date1.Month == date2.Month && + date1.Day == date2.Day && + date1.Hour == date2.Hour && + date1.Minute == date2.Minute && + date1.Second == date2.Second && + date1.Offset == date2.Offset); + } + + public override int GetHashCode(object x, EntityMode entityMode) + { + // Custom hash code implementation because DateTimeType is only accurate + // up to seconds. + DateTimeOffset date = (DateTimeOffset)x; + int hashCode = 1; + unchecked + { + hashCode = 31 * hashCode + date.Second; + hashCode = 31 * hashCode + date.Minute; + hashCode = 31 * hashCode + date.Hour; + hashCode = 31 * hashCode + date.Day; + hashCode = 31 * hashCode + date.Month; + hashCode = 31 * hashCode + date.Year; + } + return hashCode; + } + + public override string ToString(object val) + { + return ((DateTimeOffset)val).ToString(); + } + + public override object FromStringValue(string xml) + { + return DateTimeOffset.Parse(xml); + } + + public override string ObjectToSQLString(object value, Dialect.Dialect dialect) + { + return "'" + ((DateTimeOffset)value) + "'"; + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs 2009-02-01 20:55:26 UTC (rev 4010) +++ trunk/nhibernate/src/NHibernate/Type/DateTimeType.cs 2009-02-02 20:28:46 UTC (rev 4011) @@ -22,10 +22,14 @@ private static readonly DateTime BaseDateValue = DateTime.MinValue; /// <summary></summary> - internal DateTimeType() : base(SqlTypeFactory.DateTime) + public DateTimeType() : base(SqlTypeFactory.DateTime) { } + public DateTimeType(SqlType sqlTypeDateTime) : base(sqlTypeDateTime) + { + } + /// <summary></summary> public override string Name { @@ -100,7 +104,7 @@ date1.Second == date2.Second); } - public IComparer Comparator + public virtual IComparer Comparator { get { return Comparer<DateTime>.Default; } } Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-02-01 20:55:26 UTC (rev 4010) +++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-02-02 20:28:46 UTC (rev 4011) @@ -108,7 +108,11 @@ RegisterType(typeof(Byte), NHibernateUtil.Byte, "byte"); RegisterType(typeof(Char), NHibernateUtil.Character, "character"); RegisterType(typeof(CultureInfo), NHibernateUtil.CultureInfo, "locale"); + /*registering "datetime" after of "datetime2", + NH will choose "datetime" when no type is specified in the mapping*/ + RegisterType(typeof(DateTime), NHibernateUtil.DateTime2, "datetime2"); RegisterType(typeof(DateTime), NHibernateUtil.DateTime, "datetime"); + RegisterType(typeof(DateTimeOffset), NHibernateUtil.DateTimeOffset, "datetimeoffset"); RegisterType(typeof(Decimal), NHibernateUtil.Decimal, "big_decimal"); RegisterType(typeof(Double), NHibernateUtil.Double, "double"); RegisterType(typeof(Guid), NHibernateUtil.Guid, "guid"); Modified: trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs 2009-02-01 20:55:26 UTC (rev 4010) +++ trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs 2009-02-02 20:28:46 UTC (rev 4011) @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Data; +using NHibernate.Dialect; using NHibernate.Exceptions; using NHibernate.Util; using NUnit.Framework; @@ -22,7 +23,7 @@ protected override void Configure(Cfg.Configuration configuration) { - if((Dialect.GetType() == typeof(Dialect.MsSql2005Dialect)) || (Dialect.GetType() == typeof(Dialect.MsSql2000Dialect))) + if(Dialect is MsSql2000Dialect) { configuration.SetProperty(NHibernate.Cfg.Environment.SqlExceptionConverter, typeof (MSSQLExceptionConverterExample).AssemblyQualifiedName); Modified: trunk/nhibernate/src/NHibernate.Test/GeneratedTest/ComponentOwner.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GeneratedTest/ComponentOwner.hbm.xml 2009-02-01 20:55:26 UTC (rev 4010) +++ trunk/nhibernate/src/NHibernate.Test/GeneratedTest/ComponentOwner.hbm.xml 2009-02-02 20:28:46 UTC (rev 4011) @@ -47,6 +47,7 @@ </drop> <dialect-scope name="NHibernate.Dialect.MsSql2000Dialect"/> <dialect-scope name="NHibernate.Dialect.MsSql2005Dialect"/> + <dialect-scope name="NHibernate.Dialect.MsSql2008Dialect"/> </database-object> <database-object> Modified: trunk/nhibernate/src/NHibernate.Test/GeneratedTest/GeneratedPropertyEntity.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GeneratedTest/GeneratedPropertyEntity.hbm.xml 2009-02-01 20:55:26 UTC (rev 4010) +++ trunk/nhibernate/src/NHibernate.Test/GeneratedTest/GeneratedPropertyEntity.hbm.xml 2009-02-02 20:28:46 UTC (rev 4011) @@ -54,6 +54,7 @@ </drop> <dialect-scope name="NHibernate.Dialect.MsSql2000Dialect"/> <dialect-scope name="NHibernate.Dialect.MsSql2005Dialect"/> + <dialect-scope name="NHibernate.Dialect.MsSql2008Dialect"/> </database-object> </hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-01 20:55:26 UTC (rev 4010) +++ trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-02-02 20:28:46 UTC (rev 4011) @@ -18,11 +18,11 @@ static HQLFunctions() { notSupportedStandardFunction.Add("locate", - new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(FirebirdDialect), typeof(PostgreSQLDialect) }); + new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) ,typeof(FirebirdDialect), typeof(PostgreSQLDialect) }); notSupportedStandardFunction.Add("bit_length", - new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect) }); + new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) }); notSupportedStandardFunction.Add("extract", - new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect) }); + new System.Type[] { typeof(MsSql2000Dialect), typeof(MsSql2005Dialect), typeof(MsSql2008Dialect) }); } private void IgnoreIfNotSupported(string functionName) Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs 2009-02-02 20:28:46 UTC (rev 4011) @@ -0,0 +1,15 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.DateTime2AndDateTimeOffSet +{ + public class AllDates + { + public int Id { get; set; } + + public DateTime Sql_datetime { get; set; } + + public DateTime Sql_datetime2 { get; set; } + + public DateTimeOffset Sql_datetimeoffset { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs 2009-02-02 20:28:46 UTC (rev 4011) @@ -0,0 +1,86 @@ +using System; +using System.Collections; +using NHibernate.Dialect; +using NHibernate.Type; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.DateTime2AndDateTimeOffSet +{ + [TestFixture] + public class DateTime2AndDateTimeOffSetFixture : TestCase + { + protected override IList Mappings + { + get { return new[] { "NHSpecificTest.DateTime2AndDateTimeOffSet.Mappings.hbm.xml" }; } + } + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect is MsSql2008Dialect; + } + + + [Test] + public void Dates01() + { + + var Now = DateTime.Now; + var NowOS = DateTimeOffset.Now; + var dates = new AllDates + { + Sql_datetime = Now, + Sql_datetime2 = DateTime.MinValue, + Sql_datetimeoffset = NowOS, + }; + + using(ISession s = OpenSession()) + using(ITransaction tx = s.BeginTransaction()) + { + s.Save(dates); + tx.Commit(); + } + + using(ISession s = OpenSession()) + using(ITransaction tx = s.BeginTransaction()) + { + var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>(); + + DateTimeAssert.AreEqual(datesRecovered.Sql_datetime,Now); + DateTimeAssert.AreEqual(datesRecovered.Sql_datetime2, DateTime.MinValue); + DateTimeAssert.AreEqual(datesRecovered.Sql_datetimeoffset, NowOS); + } + + using(ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>(); + s.Delete(datesRecovered); + tx.Commit(); + } + } + + public class DateTimeAssert + { + public static void AreEqual(DateTime dt1,DateTime dt2) + { + bool areEqual = new DateTimeType().IsEqual(dt1,dt2); + + if(!areEqual) + Assert.Fail("Expected {0} but was {1}"); + } + + public static void AreEqual(DateTimeOffset dt1, DateTimeOffset dt2) + { + bool areEqual = new DateTimeOffsetType().IsEqual(dt1, dt2); + + if (!areEqual) + Assert.Fail("Expected {0} but was {1}"); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml 2009-02-02 20:28:46 UTC (rev 4011) @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.MsSql2008" + assembly="NHibernate.Test"> + + <class name="AllDates" lazy="false"> + + <id name="Id"> + <generator class="identity"/> + </id> + + <property name="Sql_datetime" /> + <property name="Sql_datetime2" type="datetime2" /> + <property name="Sql_datetimeoffset" type="datetimeoffset" /> + + </class> + +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-01 20:55:26 UTC (rev 4010) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-02 20:28:46 UTC (rev 4011) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.21022</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{7AEE5B37-C552-4E59-9B6F-88755BCB5070}</ProjectGuid> <OutputType>Library</OutputType> @@ -14,6 +14,9 @@ <OldToolsVersion>2.0</OldToolsVersion> <UpgradeBackupLocation> </UpgradeBackupLocation> + <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> + <TargetFrameworkSubset> + </TargetFrameworkSubset> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -377,6 +380,8 @@ <Compile Include="NHSpecificTest\Futures\FutureQueryFixture.cs" /> <Compile Include="NHSpecificTest\Futures\Fixture.cs" /> <Compile Include="NHSpecificTest\Futures\Person.cs" /> + <Compile Include="NHSpecificTest\DateTime2AndDateTimeOffSet\AllDates.cs" /> + <Compile Include="NHSpecificTest\DateTime2AndDateTimeOffSet\DateTime2AndDateTimeOffSetFixture.cs" /> <Compile Include="NHSpecificTest\NH1274ExportExclude\Home.cs" /> <Compile Include="NHSpecificTest\NH1274ExportExclude\NH1274ExportExcludeFixture.cs" /> <Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" /> @@ -971,6 +976,7 @@ <Compile Include="TypesTest\BooleanTypeFixture.cs" /> <Compile Include="TypesTest\ByteClass.cs" /> <Compile Include="TypesTest\ByteTypeFixture.cs" /> + <Compile Include="TypesTest\Decima2lTypeFixture.cs" /> <Compile Include="TypesTest\DateTimeTypeFixture.cs" /> <Compile Include="TypesTest\DecimalClass.cs" /> <Compile Include="TypesTest\DecimalTypeFixture.cs" /> @@ -1606,6 +1612,7 @@ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\DateTime2AndDateTimeOffSet\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\Futures\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1643\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1640\Mappings.hbm.xml" /> Copied: trunk/nhibernate/src/NHibernate.Test/TypesTest/Decima2lTypeFixture.cs (from rev 4005, trunk/nhibernate/src/NHibernate.Test/TypesTest/DecimalTypeFixture.cs) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypesTest/Decima2lTypeFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypesTest/Decima2lTypeFixture.cs 2009-02-02 20:28:46 UTC (rev 4011) @@ -0,0 +1,47 @@ +using System; +using NHibernate.Type; +using NUnit.Framework; + +namespace NHibernate.Test.TypesTest +{ + /// <summary> + /// TestFixtures for the <see cref="DateTimeType"/>. + /// </summary> + [TestFixture] + public class DateTime2TypeFixture + { + [Test] + public void Next() + { + DateTimeType type = (DateTimeType)NHibernateUtil.DateTime2; + object current = DateTime.Parse("2004-01-01"); + object next = type.Next(current, null); + + Assert.IsTrue(next is DateTime, "Next should be DateTime"); + Assert.IsTrue((DateTime)next > (DateTime)current, + "next should be greater than current (could be equal depending on how quickly this occurs)"); + } + + [Test] + public void Seed() + { + DateTimeType type = (DateTimeType)NHibernateUtil.DateTime; + Assert.IsTrue(type.Seed(null) is DateTime, "seed should be DateTime"); + } + + [Test] + public void DeepCopyNotNull() + { + NullableType type = NHibernateUtil.DateTime; + + object value1 = DateTime.Now; + object value2 = type.DeepCopy(value1, EntityMode.Poco, null); + + Assert.AreEqual(value1, value2, "Copies should be the same."); + + + value2 = ((DateTime)value2).AddHours(2); + Assert.IsFalse(value1 == value2, "value2 was changed, value1 should not have changed also."); + } + } +} \ 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: <dav...@us...> - 2009-02-01 20:55:33
|
Revision: 4010 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4010&view=rev Author: davybrion Date: 2009-02-01 20:55:26 +0000 (Sun, 01 Feb 2009) Log Message: ----------- added some (commented) settings to the config file for MySQL testing Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/App.config Modified: trunk/nhibernate/src/NHibernate.Test/App.config =================================================================== --- trunk/nhibernate/src/NHibernate.Test/App.config 2009-01-31 14:56:37 UTC (rev 4009) +++ trunk/nhibernate/src/NHibernate.Test/App.config 2009-02-01 20:55:26 UTC (rev 4010) @@ -57,11 +57,15 @@ <!-- This is the System.Data.dll provider for MSSQL Server --> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> - <property name="connection.connection_string"> - Server=(local);initial catalog=nhibernate;Integrated Security=SSPI - </property> - <property name="show_sql">false</property> - <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> + <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> + <property name="connection.connection_string">Server=(local);initial catalog=nhibernate;Integrated Security=SSPI</property> + + <!-- This is for running the tests with a MySQL database --> + <!--<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property> + <property name="dialect">NHibernate.Dialect.MySQL5Dialect</property> + <property name="connection.connection_string">Server=localhost;Database=nhibernate;User ID=nhibernate;Password=nhibernate</property>--> + + <property name="show_sql">false</property> <property name="use_outer_join">true</property> <property name="command_timeout">444</property> <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-01-31 14:56:41
|
Revision: 4009 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4009&view=rev Author: fabiomaulo Date: 2009-01-31 14:56:37 +0000 (Sat, 31 Jan 2009) Log Message: ----------- Added test Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/SQLFunctionTemplateTest.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/SQLFunctionTemplateTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/SQLFunctionTemplateTest.cs 2009-01-31 13:02:25 UTC (rev 4008) +++ trunk/nhibernate/src/NHibernate.Test/HQL/SQLFunctionTemplateTest.cs 2009-01-31 14:56:37 UTC (rev 4009) @@ -94,6 +94,14 @@ args.Add(2); args.Add(3); Assert.AreEqual("func(1,3)", ft.Render(args, factoryImpl).ToString()); + + // Args in different position + args.Clear(); + ft = new SQLFunctionTemplate(NHibernateUtil.String, "func(?2, ?1, ?3)"); + args.Add(1); + args.Add(2); + args.Add(3); + Assert.AreEqual("func(2, 1, 3)", ft.Render(args, factoryImpl).ToString()); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-01-31 13:02:28
|
Revision: 4008 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4008&view=rev Author: fabiomaulo Date: 2009-01-31 13:02:25 +0000 (Sat, 31 Jan 2009) Log Message: ----------- Fix indentation and xml comment Modified Paths: -------------- trunk/nhibernate/src/NHibernate/IQuery.cs Modified: trunk/nhibernate/src/NHibernate/IQuery.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQuery.cs 2009-01-30 17:41:12 UTC (rev 4007) +++ trunk/nhibernate/src/NHibernate/IQuery.cs 2009-01-31 13:02:25 UTC (rev 4008) @@ -64,7 +64,7 @@ /// <summary> Return the HQL select clause aliases (if any)</summary> /// <returns> an array of aliases as strings </returns> - string[] ReturnAliases{get;} + string[] ReturnAliases { get; } /// <summary> /// The names of all named parameters of the query @@ -585,21 +585,22 @@ /// </summary> IQuery SetResultTransformer(IResultTransformer resultTransformer); - /// <summary> - /// Get a enumerable that when enumerated will execute - /// a batch of queries in a single database roundtrip - /// </summary> - /// <typeparam name="T"></typeparam> - /// <returns></returns> - IEnumerable<T> Future<T>(); + /// <summary> + /// Get a enumerable that when enumerated will execute + /// a batch of queries in a single database roundtrip + /// </summary> + /// <typeparam name="T"></typeparam> + /// <returns></returns> + IEnumerable<T> Future<T>(); - /// Get an IFutureValue instance, whose value can be retrieved through - /// its Value property. The query is not executed until the Value property - /// is retrieved, which will execute other Future queries as well in a - /// single roundtrip - /// </summary> - /// <typeparam name="T"></typeparam> - /// <returns></returns> - IFutureValue<T> FutureValue<T>(); + /// <summary> + /// Get an IFutureValue instance, whose value can be retrieved through + /// its Value property. The query is not executed until the Value property + /// is retrieved, which will execute other Future queries as well in a + /// single roundtrip + /// </summary> + /// <typeparam name="T"></typeparam> + /// <returns></returns> + IFutureValue<T> FutureValue<T>(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-01-30 17:41:17
|
Revision: 4007 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4007&view=rev Author: fabiomaulo Date: 2009-01-30 17:41:12 +0000 (Fri, 30 Jan 2009) Log Message: ----------- Fix NH-1644 by Alexandre Payment Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Driver/OracleLiteDataClientDriver.cs Modified: trunk/nhibernate/src/NHibernate/Driver/OracleLiteDataClientDriver.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Driver/OracleLiteDataClientDriver.cs 2009-01-30 17:35:22 UTC (rev 4006) +++ trunk/nhibernate/src/NHibernate/Driver/OracleLiteDataClientDriver.cs 2009-01-30 17:41:12 UTC (rev 4007) @@ -10,35 +10,32 @@ public class OracleLiteDataClientDriver : ReflectionBasedDriver, IEmbeddedBatcherFactoryProvider { /// <summary> - /// Initializes a new instance of <see cref="OracleLiteDataClientDriver"/>. + /// Initializes a new instance of <see cref="OracleLiteDataClientDriver"/>. /// </summary> /// <exception cref="HibernateException"> - /// Thrown when the <c>Oracle.DataAccess.Lite_w32</c> assembly can not be loaded. + /// Thrown when the <c>Oracle.DataAccess.Lite_w32</c> assembly can not be loaded. /// </exception> - public OracleLiteDataClientDriver() + public OracleLiteDataClientDriver() : base( - "Oracle.DataAccess.Lite_w32", - "Oracle.DataAccess.Lite.OracleConnection", - "Oracle.DataAccess.Lite.OracleCommand") + "Oracle.DataAccess.Lite_w32", + "Oracle.DataAccess.Lite.OracleConnection", + "Oracle.DataAccess.Lite.OracleCommand") { } - /// <summary></summary> public override bool UseNamedPrefixInSql { - get { return true; } + get { return false; } } - /// <summary></summary> public override bool UseNamedPrefixInParameter { - get { return true; } + get { return false; } } - /// <summary></summary> public override string NamedPrefix { - get { return ":"; } + get { return string.Empty; } } /// <remarks> @@ -60,7 +57,7 @@ System.Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass { - get { return typeof (OracleDataClientBatchingBatcherFactory); } + get { return typeof(OracleDataClientBatchingBatcherFactory); } } #endregion This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-01-30 17:35:26
|
Revision: 4006 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4006&view=rev Author: fabiomaulo Date: 2009-01-30 17:35:22 +0000 (Fri, 30 Jan 2009) Log Message: ----------- Fix NH-1584 by Seth Schubert Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/AssociationKey.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/TestFixture.cs Modified: trunk/nhibernate/src/NHibernate/Engine/AssociationKey.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/AssociationKey.cs 2009-01-27 15:01:15 UTC (rev 4005) +++ trunk/nhibernate/src/NHibernate/Engine/AssociationKey.cs 2009-01-30 17:35:22 UTC (rev 4006) @@ -12,25 +12,35 @@ { private readonly EntityKey ownerKey; private readonly string propertyName; + private readonly int hashCode; public AssociationKey(EntityKey ownerKey, string propertyName) { this.ownerKey = ownerKey; this.propertyName = propertyName; + hashCode = ownerKey.GetHashCode() ^ propertyName.GetHashCode() ^ ownerKey.EntityName.GetHashCode(); } public override bool Equals(object that) { - if(this==that) return true; + // NH : Different behavior for NH-1584 + if (this == that) + { + return true; + } - AssociationKey key = that as AssociationKey; - if(key==null) return false; - return key.propertyName.Equals(propertyName) && key.ownerKey.Equals(ownerKey); + var key = that as AssociationKey; + if (key == null) + { + return false; + } + return key.propertyName.Equals(propertyName) && key.ownerKey.Equals(ownerKey) + && key.ownerKey.EntityName.Equals(ownerKey.EntityName); } public override int GetHashCode() { - return ownerKey.GetHashCode() ^ propertyName.GetHashCode(); + return hashCode; } } -} +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/TestFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/TestFixture.cs 2009-01-27 15:01:15 UTC (rev 4005) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/TestFixture.cs 2009-01-30 17:35:22 UTC (rev 4006) @@ -6,14 +6,9 @@ namespace NHibernate.Test.NHSpecificTest.NH1584 { - [TestFixture, Ignore("Not supported yet.")] + [TestFixture] public class TestFixture : BugTestCase { - public override string BugNumber - { - get { return "NH1584"; } - } - protected override void OnTearDown() { using (ISession session = OpenSession()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Bourdages D. <ig...@im...> - 2009-01-28 00:01:15
|
Best present to your girlfriend. Love Is Nott Enough http://lchernatav.narod.ru To prevent his escape. The others advanced on camels nor any other mode of conveyance are, under them is very peculiar, and i devoted some time strife, and victors and vanquished endeavoured it up thick with some butter, and a clove of garlick,. |
From: <te...@us...> - 2009-01-27 15:01:23
|
Revision: 4005 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4005&view=rev Author: tehlike Date: 2009-01-27 15:01:15 +0000 (Tue, 27 Jan 2009) Log Message: ----------- Adding Where to Extra Lazy queries. Fix for NH-1627 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs trunk/nhibernate/src/NHibernate.Test/Extralazy/User.cs trunk/nhibernate/src/NHibernate.Test/Extralazy/UserGroup.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Extralazy/Photo.cs Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-01-27 04:23:01 UTC (rev 4004) +++ trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-01-27 15:01:15 UTC (rev 4005) @@ -836,15 +836,25 @@ return frag.ToSqlStringFragment(false); } - + private SqlString AddWhereFragment(SqlString sql) + { + if (!hasWhere) + return sql; + var sqlStringBuilder = new SqlStringBuilder(sql); + sqlStringBuilder.Add(" and ").Add(sqlWhereString); + return sqlStringBuilder.ToSqlString(); + } private SqlString GenerateSelectSizeString(bool isIntegerIndexed) { string selectValue = isIntegerIndexed ? "max(" + IndexColumnNames[0] + ") + 1" : "count(" + ElementColumnNames[0] + ")"; //sets, maps, bags - return - new SqlSimpleSelectBuilder(dialect, factory).SetTableName(TableName).AddWhereFragment(KeyColumnNames, KeyType, "="). - AddColumn(selectValue).ToSqlString(); + + var sqlString=new SqlSimpleSelectBuilder(dialect, factory) + .SetTableName(TableName) + .AddWhereFragment(KeyColumnNames, KeyType, "=") + .AddColumn(selectValue).ToSqlString(); + return AddWhereFragment(sqlString); } private SqlString GenerateDetectRowByIndexString() @@ -855,10 +865,14 @@ } // TODO NH: may be we need something else when Index is mixed with Formula - return - new SqlSimpleSelectBuilder(dialect, factory).SetTableName(TableName).AddWhereFragment(KeyColumnNames, KeyType, "="). - AddWhereFragment(IndexColumnNames, IndexType, "=").AddWhereFragment(indexFormulas, IndexType, "=").AddColumn("1"). - ToSqlString(); + var sqlString= + new SqlSimpleSelectBuilder(dialect, factory) + .SetTableName(TableName) + .AddWhereFragment(KeyColumnNames, KeyType, "=") + .AddWhereFragment(IndexColumnNames, IndexType, "=") + .AddWhereFragment(indexFormulas, IndexType, "=") + .AddColumn("1").ToSqlString(); + return AddWhereFragment(sqlString); } private SqlString GenerateSelectRowByIndexString() @@ -868,18 +882,26 @@ return null; } - return - new SqlSimpleSelectBuilder(dialect, factory).SetTableName(TableName).AddWhereFragment(KeyColumnNames, KeyType, "="). - AddWhereFragment(IndexColumnNames, IndexType, "=").AddWhereFragment(indexFormulas, IndexType, "=").AddColumns( - ElementColumnNames, elementColumnAliases).AddColumns(indexFormulas, indexColumnAliases).ToSqlString(); + var sqlString=new SqlSimpleSelectBuilder(dialect, factory) + .SetTableName(TableName) + .AddWhereFragment(KeyColumnNames, KeyType, "=") + .AddWhereFragment(IndexColumnNames, IndexType, "=") + .AddWhereFragment(indexFormulas, IndexType, "=") + .AddColumns(ElementColumnNames, elementColumnAliases) + .AddColumns(indexFormulas, indexColumnAliases).ToSqlString(); + return AddWhereFragment(sqlString); } private SqlString GenerateDetectRowByElementString() { - return - new SqlSimpleSelectBuilder(dialect, factory).SetTableName(TableName).AddWhereFragment(KeyColumnNames, KeyType, "="). - AddWhereFragment(ElementColumnNames, ElementType, "=").AddWhereFragment(elementFormulas, ElementType, "="). - AddColumn("1").ToSqlString(); + var sqlString= + new SqlSimpleSelectBuilder(dialect, factory) + .SetTableName(TableName) + .AddWhereFragment(KeyColumnNames, KeyType, "=") + .AddWhereFragment(ElementColumnNames, ElementType, "=") + .AddWhereFragment(elementFormulas, ElementType, "=") + .AddColumn("1").ToSqlString(); + return AddWhereFragment(sqlString); } protected virtual SelectFragment GenerateSelectFragment(string alias, string columnSuffix) Modified: trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs 2009-01-27 04:23:01 UTC (rev 4004) +++ trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs 2009-01-27 15:01:15 UTC (rev 4005) @@ -21,7 +21,40 @@ { get { return null; } } + [Test] + public void ExtraLazyWithWhereClause() + { + using(ISession s = OpenSession()) + using(ITransaction t=s.BeginTransaction()) + { + s.CreateSQLQuery("insert into Users (Name,Password) values('gavin','secret')") + .UniqueResult(); + s.CreateSQLQuery("insert into Photos (Title,Owner) values('PRVaaa','gavin')") + .UniqueResult(); + s.CreateSQLQuery("insert into Photos (Title,Owner) values('PUBbbb','gavin')") + .UniqueResult(); + t.Commit(); + } + using(ISession s = OpenSession()) + { + var gavin = s.Get<User>("gavin"); + Assert.AreEqual(1, gavin.Photos.Count); + Assert.IsFalse(NHibernateUtil.IsInitialized(gavin.Documents)); + } + using(ISession s=OpenSession()) + using(ITransaction t=s.BeginTransaction()) + { + s.CreateSQLQuery("delete from Photos") + .UniqueResult(); + s.CreateSQLQuery("delete from Users") + .UniqueResult(); + + t.Commit(); + } + sessions.Evict(typeof(User)); + sessions.Evict(typeof(Photo)); + } [Test] public void OrphanDelete() { Added: trunk/nhibernate/src/NHibernate.Test/Extralazy/Photo.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Extralazy/Photo.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Extralazy/Photo.cs 2009-01-27 15:01:15 UTC (rev 4005) @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.Extralazy +{ + public class Photo + { + + protected Photo() {} + public Photo(string title, User owner) + { + this.Title = title; + this.Owner = owner; + } + + public virtual string Title + { + get; set; + } + + public virtual User Owner + { + get; set; + } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/Extralazy/User.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Extralazy/User.cs 2009-01-27 04:23:01 UTC (rev 4004) +++ trunk/nhibernate/src/NHibernate.Test/Extralazy/User.cs 2009-01-27 15:01:15 UTC (rev 4005) @@ -9,6 +9,7 @@ private string password; private IDictionary session = new Hashtable(); private ISet documents = new HashedSet(); + private ISet photos = new HashedSet(); protected User() {} public User(string name, string password) { @@ -39,5 +40,12 @@ get { return documents; } set { documents = value; } } + + + public virtual ISet Photos + { + get { return photos; } + set { photos = value; } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Extralazy/UserGroup.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Extralazy/UserGroup.hbm.xml 2009-01-27 04:23:01 UTC (rev 4004) +++ trunk/nhibernate/src/NHibernate.Test/Extralazy/UserGroup.hbm.xml 2009-01-27 15:01:15 UTC (rev 4005) @@ -25,8 +25,15 @@ <key column="owner"/> <one-to-many class="Document"/> </set> + <set name="Photos" inverse="true" lazy="true" where="Title like 'PRV%'" cascade="all,delete-orphan"> + <key column="owner"/> + <one-to-many class="Photo"/> + </set> </class> - + <class name="Photo" table="photos"> + <id name="Title"/> + <many-to-one name="Owner" not-null="true"/> + </class> <class name="Document" table="documents"> <id name="Title"/> <property name="Content" type="string" length="10000"/> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-27 04:23:01 UTC (rev 4004) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-27 15:01:15 UTC (rev 4005) @@ -224,6 +224,7 @@ <Compile Include="Extralazy\Document.cs" /> <Compile Include="Extralazy\ExtraLazyFixture.cs" /> <Compile Include="Extralazy\Group.cs" /> + <Compile Include="Extralazy\Photo.cs" /> <Compile Include="Extralazy\SessionAttribute.cs" /> <Compile Include="Extralazy\User.cs" /> <Compile Include="FilterTest\BinaryFiltered.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-01-27 04:23:21
|
Revision: 4004 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4004&view=rev Author: darioquintana Date: 2009-01-27 04:23:01 +0000 (Tue, 27 Jan 2009) Log Message: ----------- Refactoring: DelayedEnumerator and FutureValue moved as outer classes to reuse code. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Impl/DelayedEnumerator.cs trunk/nhibernate/src/NHibernate/Impl/FutureValue.cs Added: trunk/nhibernate/src/NHibernate/Impl/DelayedEnumerator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/DelayedEnumerator.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Impl/DelayedEnumerator.cs 2009-01-27 04:23:01 UTC (rev 4004) @@ -0,0 +1,42 @@ +using System.Collections; +using System.Collections.Generic; + +namespace NHibernate.Impl +{ + internal class DelayedEnumerator<T> : IEnumerable<T> + { + public delegate IList GetResult(); + + private readonly GetResult result; + + public DelayedEnumerator(GetResult result) + { + this.result = result; + } + + public IEnumerable<T> Enumerable + { + get + { + foreach (T item in result()) + { + yield return item; + } + } + } + + #region IEnumerable<T> Members + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable)Enumerable).GetEnumerator(); + } + + public IEnumerator<T> GetEnumerator() + { + return Enumerable.GetEnumerator(); + } + + #endregion + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-27 03:49:11 UTC (rev 4003) +++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-27 04:23:01 UTC (rev 4004) @@ -50,77 +50,5 @@ int currentIndex = index; return new DelayedEnumerator<T>(() => (IList)Results[currentIndex]); } - - #region Nested type: FutureValue - - private class FutureValue<T> : IFutureValue<T> - { - public delegate IList GetResult(); - - private readonly GetResult getResult; - - public FutureValue(GetResult result) - { - getResult = result; - } - - public T Value - { - get - { - var result = getResult(); - - if (result.Count == 0) - { - return default(T); - } - - return (T)result[0]; - } - } - } - - #endregion - - #region Nested type: DelayedEnumerator - - private class DelayedEnumerator<T> : IEnumerable<T> - { - public delegate IList GetResult(); - - private readonly GetResult result; - - public DelayedEnumerator(GetResult result) - { - this.result = result; - } - - public IEnumerable<T> Enumerable - { - get - { - foreach (T item in result()) - { - yield return item; - } - } - } - - #region IEnumerable<T> Members - - IEnumerator IEnumerable.GetEnumerator() - { - return ((IEnumerable)Enumerable).GetEnumerator(); - } - - public IEnumerator<T> GetEnumerator() - { - return Enumerable.GetEnumerator(); - } - - #endregion - } - - #endregion } } Modified: trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs 2009-01-27 03:49:11 UTC (rev 4003) +++ trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs 2009-01-27 04:23:01 UTC (rev 4004) @@ -50,77 +50,5 @@ int currentIndex = index; return new DelayedEnumerator<T>(() => (IList)Results[currentIndex]); } - - #region Nested type: FutureValue - - private class FutureValue<T> : IFutureValue<T> - { - public delegate IList GetResult(); - - private readonly GetResult getResult; - - public FutureValue(GetResult result) - { - getResult = result; - } - - public T Value - { - get - { - var result = getResult(); - - if (result.Count == 0) - { - return default(T); - } - - return (T)result[0]; - } - } - } - - #endregion - - #region Nested type: DelayedEnumerator - - private class DelayedEnumerator<T> : IEnumerable<T> - { - public delegate IList GetResult(); - - private readonly GetResult result; - - public DelayedEnumerator(GetResult result) - { - this.result = result; - } - - public IEnumerable<T> Enumerable - { - get - { - foreach (T item in result()) - { - yield return item; - } - } - } - - #region IEnumerable<T> Members - - IEnumerator IEnumerable.GetEnumerator() - { - return ((IEnumerable)Enumerable).GetEnumerator(); - } - - public IEnumerator<T> GetEnumerator() - { - return Enumerable.GetEnumerator(); - } - - #endregion - } - - #endregion } } Added: trunk/nhibernate/src/NHibernate/Impl/FutureValue.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/FutureValue.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Impl/FutureValue.cs 2009-01-27 04:23:01 UTC (rev 4004) @@ -0,0 +1,31 @@ +using System.Collections; + +namespace NHibernate.Impl +{ + internal class FutureValue<T> : IFutureValue<T> + { + public delegate IList GetResult(); + + private readonly GetResult getResult; + + public FutureValue(GetResult result) + { + getResult = result; + } + + public T Value + { + get + { + var result = getResult(); + + if (result.Count == 0) + { + return default(T); + } + + return (T)result[0]; + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-27 03:49:11 UTC (rev 4003) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-27 04:23:01 UTC (rev 4004) @@ -458,8 +458,10 @@ <Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" /> <Compile Include="Id\SelectGenerator.cs" /> <Compile Include="IFutureValue.cs" /> + <Compile Include="Impl\DelayedEnumerator.cs" /> <Compile Include="Impl\FutureQueryBatch.cs" /> <Compile Include="Impl\FutureCriteriaBatch.cs" /> + <Compile Include="Impl\FutureValue.cs" /> <Compile Include="Properties\BackFieldStrategy.cs" /> <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> <Compile Include="Bytecode\IAccessOptimizer.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-01-27 03:49:30
|
Revision: 4003 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4003&view=rev Author: darioquintana Date: 2009-01-27 03:49:11 +0000 (Tue, 27 Jan 2009) Log Message: ----------- Adding support for IQuery.Future<T>() Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs trunk/nhibernate/src/NHibernate/IQuery.cs trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs Modified: trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-01-26 23:00:00 UTC (rev 4002) +++ trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-01-27 03:49:11 UTC (rev 4003) @@ -285,5 +285,7 @@ int ExecuteUpdate(string query, QueryParameters queryParameters); FutureCriteriaBatch FutureCriteriaBatch { get; } + + FutureQueryBatch FutureQueryBatch { get; } } } Modified: trunk/nhibernate/src/NHibernate/IQuery.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IQuery.cs 2009-01-26 23:00:00 UTC (rev 4002) +++ trunk/nhibernate/src/NHibernate/IQuery.cs 2009-01-27 03:49:11 UTC (rev 4003) @@ -584,5 +584,22 @@ /// "shape" of the query result. /// </summary> IQuery SetResultTransformer(IResultTransformer resultTransformer); + + /// <summary> + /// Get a enumerable that when enumerated will execute + /// a batch of queries in a single database roundtrip + /// </summary> + /// <typeparam name="T"></typeparam> + /// <returns></returns> + IEnumerable<T> Future<T>(); + + /// Get an IFutureValue instance, whose value can be retrieved through + /// its Value property. The query is not executed until the Value property + /// is retrieved, which will execute other Future queries as well in a + /// single roundtrip + /// </summary> + /// <typeparam name="T"></typeparam> + /// <returns></returns> + IFutureValue<T> FutureValue<T>(); } } Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2009-01-26 23:00:00 UTC (rev 4002) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractQueryImpl.cs 2009-01-27 03:49:11 UTC (rev 4003) @@ -826,7 +826,19 @@ return this; } - /// <summary> Override the current session cache mode, just for this query. + public IEnumerable<T> Future<T>() + { + session.FutureQueryBatch.Add(this); + return session.FutureQueryBatch.GetEnumerator<T>(); + } + + public IFutureValue<T> FutureValue<T>() + { + session.FutureQueryBatch.Add(this); + return session.FutureQueryBatch.GetFutureValue<T>(); + } + + /// <summary> Override the current session cache mode, just for this query. /// </summary> /// <param name="cacheMode">The cache mode to use. </param> /// <returns> this (for method chaining) </returns> Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-01-26 23:00:00 UTC (rev 4002) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-01-27 03:49:11 UTC (rev 4003) @@ -129,6 +129,7 @@ public abstract int ExecuteNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters); public abstract int ExecuteUpdate(string query, QueryParameters queryParameters); public abstract FutureCriteriaBatch FutureCriteriaBatch { get; internal set; } + public abstract FutureQueryBatch FutureQueryBatch { get; internal set; } public virtual IQuery GetNamedQuery(string queryName) { Added: trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Impl/FutureQueryBatch.cs 2009-01-27 03:49:11 UTC (rev 4003) @@ -0,0 +1,126 @@ +using System.Collections; +using System.Collections.Generic; + +namespace NHibernate.Impl +{ + public class FutureQueryBatch + { + private readonly List<IQuery> queries = new List<IQuery>(); + private int index; + private IList results; + private readonly ISession session; + + public FutureQueryBatch(ISession session) + { + this.session = session; + } + + public IList Results + { + get + { + if (results == null) + { + var multiQuery = session.CreateMultiQuery(); + foreach (var crit in queries) + { + multiQuery.Add(crit); + } + results = multiQuery.List(); + ((SessionImpl)session).FutureQueryBatch = null; + } + return results; + } + } + + public void Add(IQuery query) + { + queries.Add(query); + index = queries.Count - 1; + } + + public IFutureValue<T> GetFutureValue<T>() + { + int currentIndex = index; + return new FutureValue<T>(() => (IList)Results[currentIndex]); + } + + public IEnumerable<T> GetEnumerator<T>() + { + int currentIndex = index; + return new DelayedEnumerator<T>(() => (IList)Results[currentIndex]); + } + + #region Nested type: FutureValue + + private class FutureValue<T> : IFutureValue<T> + { + public delegate IList GetResult(); + + private readonly GetResult getResult; + + public FutureValue(GetResult result) + { + getResult = result; + } + + public T Value + { + get + { + var result = getResult(); + + if (result.Count == 0) + { + return default(T); + } + + return (T)result[0]; + } + } + } + + #endregion + + #region Nested type: DelayedEnumerator + + private class DelayedEnumerator<T> : IEnumerable<T> + { + public delegate IList GetResult(); + + private readonly GetResult result; + + public DelayedEnumerator(GetResult result) + { + this.result = result; + } + + public IEnumerable<T> Enumerable + { + get + { + foreach (T item in result()) + { + yield return item; + } + } + } + + #region IEnumerable<T> Members + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable)Enumerable).GetEnumerator(); + } + + public IEnumerator<T> GetEnumerator() + { + return Enumerable.GetEnumerator(); + } + + #endregion + } + + #endregion + } +} Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-01-26 23:00:00 UTC (rev 4002) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-01-27 03:49:11 UTC (rev 4003) @@ -50,6 +50,7 @@ [NonSerialized] private readonly EntityMode entityMode = EntityMode.Poco; [NonSerialized] private FutureCriteriaBatch futureCriteriaBatch; + [NonSerialized] private FutureQueryBatch futureQueryBatch; [NonSerialized] private readonly EventListeners listeners; @@ -264,6 +265,20 @@ } } + public override FutureQueryBatch FutureQueryBatch + { + get + { + if (futureQueryBatch == null) + futureQueryBatch = new FutureQueryBatch(this); + return futureQueryBatch; + } + internal set + { + futureQueryBatch = value; + } + } + /// <summary></summary> public override IBatcher Batcher { Modified: trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-26 23:00:00 UTC (rev 4002) +++ trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-27 03:49:11 UTC (rev 4003) @@ -819,6 +819,12 @@ internal set { throw new System.NotSupportedException("future queries are not supported for stateless session"); } } + public override FutureQueryBatch FutureQueryBatch + { + get { throw new System.NotSupportedException("future queries are not supported for stateless session"); } + internal set { throw new System.NotSupportedException("future queries are not supported for stateless session"); } + } + public override IEntityPersister GetEntityPersister(string entityName, object obj) { CheckAndUpdateSessionStatus(); Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-26 23:00:00 UTC (rev 4002) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-27 03:49:11 UTC (rev 4003) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.30729</ProductVersion> + <ProductVersion>9.0.21022</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</ProjectGuid> <OutputType>Library</OutputType> @@ -458,6 +458,7 @@ <Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" /> <Compile Include="Id\SelectGenerator.cs" /> <Compile Include="IFutureValue.cs" /> + <Compile Include="Impl\FutureQueryBatch.cs" /> <Compile Include="Impl\FutureCriteriaBatch.cs" /> <Compile Include="Properties\BackFieldStrategy.cs" /> <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs 2009-01-27 03:49:11 UTC (rev 4003) @@ -0,0 +1,122 @@ +using NHibernate.Criterion; +using NHibernate.Impl; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.Futures +{ + using System.Collections; + + [TestFixture] + public class FutureQueryFixture : TestCase + { + + protected override IList Mappings + { + get { return new string[] { "NHSpecificTest.Futures.Mappings.hbm.xml" }; } + } + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + [Test] + public void CanUseFutureQuery() + { + using (var s = sessions.OpenSession()) + { + if (((SessionFactoryImpl)sessions) + .ConnectionProvider.Driver.SupportsMultipleQueries == false) + { + Assert.Ignore("Not applicable for dialects that do not support multiple queries"); + } + + var persons10 = s.CreateQuery("from Person") + .SetMaxResults(10) + .Future<Person>(); + var persons5 = s.CreateQuery("from Person") + .SetMaxResults(5) + .Future<int>(); + + using (var logSpy = new SqlLogSpy()) + { + foreach (var person in persons5) + { + + } + + foreach (var person in persons10) + { + + } + + var events = logSpy.Appender.GetEvents(); + Assert.AreEqual(1, events.Length); + } + } + } + + [Test] + public void TwoFuturesRunInTwoRoundTrips() + { + using (var s = sessions.OpenSession()) + { + if (((SessionFactoryImpl)sessions) + .ConnectionProvider.Driver.SupportsMultipleQueries == false) + { + Assert.Ignore("Not applicable for dialects that do not support multiple queries"); + } + + using (var logSpy = new SqlLogSpy()) + { + var persons10 = s.CreateQuery("from Person") + .SetMaxResults(10) + .Future<Person>(); + + foreach (var person in persons10) { } // fire first future round-trip + + var persons5 = s.CreateQuery("from Person") + .SetMaxResults(5) + .Future<int>(); + + foreach (var person in persons5) { } // fire second future round-trip + + var events = logSpy.Appender.GetEvents(); + Assert.AreEqual(2, events.Length); + } + } + } + + [Test] + public void CanCombineSingleFutureValueWithEnumerableFutures() + { + using (var s = sessions.OpenSession()) + { + if (((SessionFactoryImpl)sessions) + .ConnectionProvider.Driver.SupportsMultipleQueries == false) + { + Assert.Ignore("Not applicable for dialects that do not support multiple queries"); + } + + var persons = s.CreateQuery("from Person") + .SetMaxResults(10) + .Future<Person>(); + + var personCount = s.CreateQuery("select count(*) from Person") + .FutureValue<long>(); + + using (var logSpy = new SqlLogSpy()) + { + long count = personCount.Value; + + foreach (var person in persons) + { + } + + var events = logSpy.Appender.GetEvents(); + Assert.AreEqual(1, events.Length); + } + } + } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-26 23:00:00 UTC (rev 4002) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-27 03:49:11 UTC (rev 4003) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.30729</ProductVersion> + <ProductVersion>9.0.21022</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{7AEE5B37-C552-4E59-9B6F-88755BCB5070}</ProjectGuid> <OutputType>Library</OutputType> @@ -373,6 +373,7 @@ <Compile Include="NHSpecificTest\BasicTimeFixture.cs" /> <Compile Include="NHSpecificTest\BugTestCase.cs" /> <Compile Include="NHSpecificTest\CollectionFixture.cs" /> + <Compile Include="NHSpecificTest\Futures\FutureQueryFixture.cs" /> <Compile Include="NHSpecificTest\Futures\Fixture.cs" /> <Compile Include="NHSpecificTest\Futures\Person.cs" /> <Compile Include="NHSpecificTest\NH1274ExportExclude\Home.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pha...@us...> - 2009-01-26 23:00:05
|
Revision: 4002 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4002&view=rev Author: phatcher Date: 2009-01-26 23:00:00 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Upgrade NUnit to 2.4.8 Backport changes to SetCacheConcurrencyStrategy for NH Search Modified Paths: -------------- branches/2.0.x/nhibernate/lib/net/2.0/nunit.core.dll branches/2.0.x/nhibernate/lib/net/2.0/nunit.framework.dll branches/2.0.x/nhibernate/src/NHibernate/Cfg/Configuration.cs branches/2.0.x/nhibernate/src/NHibernate-2.0.sln branches/2.0.x/nhibernate/src/NHibernate.Test/TestCase.cs Modified: branches/2.0.x/nhibernate/lib/net/2.0/nunit.core.dll =================================================================== (Binary files differ) Modified: branches/2.0.x/nhibernate/lib/net/2.0/nunit.framework.dll =================================================================== (Binary files differ) Modified: branches/2.0.x/nhibernate/src/NHibernate/Cfg/Configuration.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate/Cfg/Configuration.cs 2009-01-26 10:26:50 UTC (rev 4001) +++ branches/2.0.x/nhibernate/src/NHibernate/Cfg/Configuration.cs 2009-01-26 23:00:00 UTC (rev 4002) @@ -1323,7 +1323,7 @@ } string region = string.IsNullOrEmpty(ccc.Region) ? role : ccc.Region; - SetCacheConcurrencyStrategy(role, CfgXmlHelper.ClassCacheUsageConvertToString(ccc.Usage), region); + SetCollectionCacheConcurrencyStrategy(role, CfgXmlHelper.ClassCacheUsageConvertToString(ccc.Usage), region); } // Events @@ -1353,6 +1353,20 @@ return this; } + internal RootClass GetRootClassMapping(string clazz) + { + try + { + return (RootClass)GetClassMapping(clazz); + } + catch (InvalidCastException) + { + throw new HibernateConfigException( + "class-cache Configuration: You may only specify a cache for root <class> mappings " + "(cache was specified for " + + clazz + ")"); + } + } + internal RootClass GetRootClassMapping(System.Type clazz) { PersistentClass persistentClass = GetClassMapping(clazz); @@ -1388,6 +1402,20 @@ SetCacheConcurrencyStrategy(clazz, concurrencyStrategy, region, true); } + /// <summary> + /// Set up a cache for an entity class + /// </summary> + public Configuration SetCacheConcurrencyStrategy(string clazz, string concurrencyStrategy) + { + SetCacheConcurrencyStrategy(clazz, concurrencyStrategy, clazz); + return this; + } + + internal void SetCacheConcurrencyStrategy(string clazz, string concurrencyStrategy, string region) + { + SetCacheConcurrencyStrategy(clazz, concurrencyStrategy, region, true); + } + internal void SetCacheConcurrencyStrategy(System.Type clazz, string concurrencyStrategy, string region, bool includeLazy) { @@ -1397,16 +1425,25 @@ rootClass.SetLazyPropertiesCacheable(includeLazy); } + internal void SetCacheConcurrencyStrategy(string clazz, string concurrencyStrategy, + string region, bool includeLazy) + { + RootClass rootClass = GetRootClassMapping(StringHelper.GetFullClassname(clazz)); + rootClass.CacheConcurrencyStrategy = concurrencyStrategy; + rootClass.CacheRegionName = region; + rootClass.SetLazyPropertiesCacheable(includeLazy); + } + /// <summary> /// Set up a cache for a collection role /// </summary> - public Configuration SetCacheConcurrencyStrategy(string collectionRole, string concurrencyStrategy) + public Configuration SetCollectionCacheConcurrencyStrategy(string collectionRole, string concurrencyStrategy) { - SetCacheConcurrencyStrategy(collectionRole, concurrencyStrategy, collectionRole); + SetCollectionCacheConcurrencyStrategy(collectionRole, concurrencyStrategy, collectionRole); return this; } - internal void SetCacheConcurrencyStrategy(string collectionRole, string concurrencyStrategy, string region) + internal void SetCollectionCacheConcurrencyStrategy(string collectionRole, string concurrencyStrategy, string region) { NHibernate.Mapping.Collection collection = GetCollectionMapping(collectionRole); collection.CacheConcurrencyStrategy = concurrencyStrategy; Modified: branches/2.0.x/nhibernate/src/NHibernate-2.0.sln =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate-2.0.sln 2009-01-26 10:26:50 UTC (rev 4001) +++ branches/2.0.x/nhibernate/src/NHibernate-2.0.sln 2009-01-26 23:00:00 UTC (rev 4002) @@ -28,6 +28,13 @@ EndProjectSection EndProject Global + GlobalSection(DPCodeReviewSolutionGUID) = preSolution + DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} + EndGlobalSection + GlobalSection(SubversionScc) = preSolution + Svn-Managed = True + Manager = AnkhSVN - Subversion Support for Visual Studio + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU Modified: branches/2.0.x/nhibernate/src/NHibernate.Test/TestCase.cs =================================================================== --- branches/2.0.x/nhibernate/src/NHibernate.Test/TestCase.cs 2009-01-26 10:26:50 UTC (rev 4001) +++ branches/2.0.x/nhibernate/src/NHibernate.Test/TestCase.cs 2009-01-26 23:00:00 UTC (rev 4002) @@ -291,7 +291,7 @@ foreach (Mapping.Collection coll in configuration.CollectionMappings) { - configuration.SetCacheConcurrencyStrategy(coll.Role, CacheConcurrencyStrategy); + configuration.SetCollectionCacheConcurrencyStrategy(coll.Role, CacheConcurrencyStrategy); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kp...@us...> - 2009-01-26 10:27:03
|
Revision: 4001 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4001&view=rev Author: kpixel Date: 2009-01-26 10:26:50 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Port "HHH-2884 : SessionFactory close notifications" from Revision 14452 (Hibernate 3.1) Except SessionFactoryObserver and test/events/CallbackTest Revision Links: -------------- http://nhibernate.svn.sourceforge.net/nhibernate/?rev=14452&view=rev Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Event/EventListeners.cs trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Event/IDestructible.cs Modified: trunk/nhibernate/src/NHibernate/Event/EventListeners.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/EventListeners.cs 2009-01-25 19:31:49 UTC (rev 4000) +++ trunk/nhibernate/src/NHibernate/Event/EventListeners.cs 2009-01-26 10:26:50 UTC (rev 4001) @@ -12,6 +12,8 @@ [Serializable] public class EventListeners { + private readonly List<object> initializedListeners = new List<object>(); + private static readonly IDictionary<ListenerType, System.Type> eventInterfaceFromType = new Dictionary<ListenerType, System.Type>(28); @@ -607,6 +609,7 @@ private void InitializeListeners(Configuration cfg, object[] list) { + initializedListeners.AddRange(list); foreach (object i in list) { IInitializable initializable = i as IInitializable; @@ -622,5 +625,24 @@ // todo-events Not ported return this; } + + public void DestroyListeners() + { + try + { + foreach (object i in initializedListeners) + { + IDestructible destructible = i as IDestructible; + if (destructible != null) + { + destructible.Cleanup(); + } + } + } + catch (Exception e) + { + throw new HibernateException("could not destruct listeners", e); + } + } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate/Event/IDestructible.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/IDestructible.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Event/IDestructible.cs 2009-01-26 10:26:50 UTC (rev 4001) @@ -0,0 +1,15 @@ + +namespace NHibernate.Event +{ + /// <summary> + /// Contract for listeners which require notification of SessionFactory closing, + /// presumably to destroy internal state. + /// </summary> + public interface IDestructible + { + /// <summary> + /// Notification of <see cref="ISessionFactory"/> shutdown. + /// </summary> + void Cleanup(); + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-01-25 19:31:49 UTC (rev 4000) +++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2009-01-26 10:26:50 UTC (rev 4001) @@ -743,6 +743,8 @@ { schemaExport.Drop(false, true); } + + eventListeners.DestroyListeners(); } public void Evict(System.Type persistentClass, object id) Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-25 19:31:49 UTC (rev 4000) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-26 10:26:50 UTC (rev 4001) @@ -452,6 +452,7 @@ <Compile Include="Dialect\SybaseASA9Dialect.cs" /> <Compile Include="Driver\IfxDriver.cs" /> <Compile Include="Driver\OracleLiteDataClientDriver.cs" /> + <Compile Include="Event\IDestructible.cs" /> <Compile Include="Exceptions\ReflectionBasedSqlStateExtracter.cs" /> <Compile Include="Exceptions\SqlStateExtracter.cs" /> <Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Dario Q. <con...@da...> - 2009-01-25 23:01:03
|
You can create a new one and mark it as closed, just for tracking, and later we can obtain the release notes automatically from Jira. On Sun, Jan 25, 2009 at 5:56 PM, Davy Brion <ra...@da...> wrote: > nope sorry, i didn't think of it > > > On Sun, Jan 25, 2009 at 8:49 PM, Tuna Toksoz <te...@gm...> wrote: > >> Davy did you create a jira for this? >> >> Tuna Toksöz >> http://tunatoksoz.com >> >> Typos included to enhance the readers attention! >> >> >> >> >> On Sun, Jan 25, 2009 at 9:31 PM, <dav...@us...> wrote: >> >>> Revision: 4000 >>> >>> http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4000&view=rev >>> Author: davybrion >>> Date: 2009-01-25 19:31:49 +0000 (Sun, 25 Jan 2009) >>> >>> Log Message: >>> ----------- >>> implementation for FutureValue<T> method on ICriteria (very similar to >>> the Future<T> implementation) >>> >>> Modified Paths: >>> -------------- >>> trunk/nhibernate/src/NHibernate/ICriteria.cs >>> trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> trunk/nhibernate/src/NHibernate/NHibernate.csproj >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> >>> Added Paths: >>> ----------- >>> trunk/nhibernate/src/NHibernate/IFutureValue.cs >>> >>> Modified: trunk/nhibernate/src/NHibernate/ICriteria.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-23 >>> 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-25 >>> 19:31:49 UTC (rev 4000) >>> @@ -253,6 +253,16 @@ >>> /// <returns></returns> >>> IEnumerable<T> Future<T>(); >>> >>> + /// <summary> >>> + /// Get an IFutureValue instance, whose value can be >>> retrieved through >>> + /// its Value property. The query is not executed until >>> the Value property >>> + /// is retrieved, which will execute other Future queries >>> as well in a >>> + /// single roundtrip >>> + /// </summary> >>> + /// <typeparam name="T"></typeparam> >>> + /// <returns></returns> >>> + IFutureValue<T> FutureValue<T>(); >>> + >>> #region NHibernate specific >>> >>> /// <summary> >>> >>> Added: trunk/nhibernate/src/NHibernate/IFutureValue.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/IFutureValue.cs >>> (rev 0) >>> +++ trunk/nhibernate/src/NHibernate/IFutureValue.cs 2009-01-25 >>> 19:31:49 UTC (rev 4000) >>> @@ -0,0 +1,7 @@ >>> +namespace NHibernate >>> +{ >>> + public interface IFutureValue<T> >>> + { >>> + T Value { get; } >>> + } >>> +} >>> \ No newline at end of file >>> >>> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> 2009-01-23 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> 2009-01-25 19:31:49 UTC (rev 4000) >>> @@ -371,6 +371,12 @@ >>> return new Subcriteria(this, this, >>> associationPath, alias, joinType); >>> } >>> >>> + public IFutureValue<T> FutureValue<T>() >>> + { >>> + session.FutureCriteriaBatch.Add(this); >>> + return >>> session.FutureCriteriaBatch.GetFutureValue<T>(); >>> + } >>> + >>> public IEnumerable<T> Future<T>() >>> { >>> session.FutureCriteriaBatch.Add(this); >>> @@ -687,6 +693,11 @@ >>> return root.List(); >>> } >>> >>> + public IFutureValue<T> FutureValue<T>() >>> + { >>> + return root.FutureValue<T>(); >>> + } >>> + >>> public IEnumerable<T> Future<T>() >>> { >>> return root.Future<T>(); >>> >>> Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> 2009-01-23 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> 2009-01-25 19:31:49 UTC (rev 4000) >>> @@ -3,87 +3,124 @@ >>> >>> namespace NHibernate.Impl >>> { >>> - public class FutureCriteriaBatch >>> - { >>> - private readonly List<ICriteria> criterias = new >>> List<ICriteria>(); >>> - private int index; >>> - private IList results; >>> - private readonly ISession session; >>> + public class FutureCriteriaBatch >>> + { >>> + private readonly List<ICriteria> criterias = new >>> List<ICriteria>(); >>> + private int index; >>> + private IList results; >>> + private readonly ISession session; >>> >>> - public FutureCriteriaBatch(ISession session) >>> - { >>> - this.session = session; >>> - } >>> + public FutureCriteriaBatch(ISession session) >>> + { >>> + this.session = session; >>> + } >>> >>> - public IList Results >>> - { >>> - get >>> - { >>> - if (results == null) >>> - { >>> - var multiCriteria = session.CreateMultiCriteria(); >>> - foreach (var crit in criterias) >>> - { >>> - multiCriteria.Add(crit); >>> - } >>> - results = multiCriteria.List(); >>> - ((SessionImpl)session).FutureCriteriaBatch = null; >>> - } >>> - return results; >>> - } >>> - } >>> + public IList Results >>> + { >>> + get >>> + { >>> + if (results == null) >>> + { >>> + var multiCriteria = >>> session.CreateMultiCriteria(); >>> + foreach (var crit in criterias) >>> + { >>> + multiCriteria.Add(crit); >>> + } >>> + results = multiCriteria.List(); >>> + >>> ((SessionImpl)session).FutureCriteriaBatch = null; >>> + } >>> + return results; >>> + } >>> + } >>> >>> - public void Add(ICriteria criteria) >>> - { >>> - criterias.Add(criteria); >>> - index = criterias.Count - 1; >>> - } >>> + public void Add(ICriteria criteria) >>> + { >>> + criterias.Add(criteria); >>> + index = criterias.Count - 1; >>> + } >>> >>> - public IEnumerable<T> GetEnumerator<T>() >>> - { >>> - int currentIndex = index; >>> - return new DelayedEnumerator<T>(() => >>> (IList)Results[currentIndex]); >>> - } >>> + public IFutureValue<T> GetFutureValue<T>() >>> + { >>> + int currentIndex = index; >>> + return new FutureValue<T>(() => >>> (IList)Results[currentIndex]); >>> + } >>> >>> - #region Nested type: DelayedEnumerator >>> + public IEnumerable<T> GetEnumerator<T>() >>> + { >>> + int currentIndex = index; >>> + return new DelayedEnumerator<T>(() => >>> (IList)Results[currentIndex]); >>> + } >>> >>> - private class DelayedEnumerator<T> : IEnumerable<T> >>> - { >>> - public delegate IList GetResult(); >>> + #region Nested type: FutureValue >>> >>> - private readonly GetResult result; >>> + private class FutureValue<T> : IFutureValue<T> >>> + { >>> + public delegate IList GetResult(); >>> >>> - public DelayedEnumerator(GetResult result) >>> - { >>> - this.result = result; >>> - } >>> + private readonly GetResult getResult; >>> >>> - public IEnumerable<T> Enumerable >>> - { >>> - get >>> - { >>> - foreach (T item in result()) >>> - { >>> - yield return item; >>> - } >>> - } >>> - } >>> + public FutureValue(GetResult result) >>> + { >>> + getResult = result; >>> + } >>> >>> - #region IEnumerable<T> Members >>> + public T Value >>> + { >>> + get >>> + { >>> + var result = getResult(); >>> >>> - IEnumerator IEnumerable.GetEnumerator() >>> - { >>> - return ((IEnumerable) Enumerable).GetEnumerator(); >>> - } >>> + if (result.Count == 0) >>> + { >>> + return default(T); >>> + } >>> >>> - public IEnumerator<T> GetEnumerator() >>> - { >>> - return Enumerable.GetEnumerator(); >>> - } >>> + return (T)result[0]; >>> + } >>> + } >>> + } >>> >>> - #endregion >>> - } >>> + #endregion >>> >>> - #endregion >>> - } >>> + #region Nested type: DelayedEnumerator >>> + >>> + private class DelayedEnumerator<T> : IEnumerable<T> >>> + { >>> + public delegate IList GetResult(); >>> + >>> + private readonly GetResult result; >>> + >>> + public DelayedEnumerator(GetResult result) >>> + { >>> + this.result = result; >>> + } >>> + >>> + public IEnumerable<T> Enumerable >>> + { >>> + get >>> + { >>> + foreach (T item in result()) >>> + { >>> + yield return item; >>> + } >>> + } >>> + } >>> + >>> + #region IEnumerable<T> Members >>> + >>> + IEnumerator IEnumerable.GetEnumerator() >>> + { >>> + return >>> ((IEnumerable)Enumerable).GetEnumerator(); >>> + } >>> + >>> + public IEnumerator<T> GetEnumerator() >>> + { >>> + return Enumerable.GetEnumerator(); >>> + } >>> + >>> + #endregion >>> + } >>> + >>> + #endregion >>> + } >>> } >>> >>> Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-23 >>> 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-25 >>> 19:31:49 UTC (rev 4000) >>> @@ -456,6 +456,7 @@ >>> <Compile Include="Exceptions\SqlStateExtracter.cs" /> >>> <Compile >>> Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" /> >>> <Compile Include="Id\SelectGenerator.cs" /> >>> + <Compile Include="IFutureValue.cs" /> >>> <Compile Include="Impl\FutureCriteriaBatch.cs" /> >>> <Compile Include="Properties\BackFieldStrategy.cs" /> >>> <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> >>> >>> Modified: >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> =================================================================== >>> --- >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> 2009-01-23 07:13:16 UTC (rev 3999) >>> +++ >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> 2009-01-25 19:31:49 UTC (rev 4000) >>> @@ -1,3 +1,4 @@ >>> +using NHibernate.Criterion; >>> using NHibernate.Impl; >>> using NUnit.Framework; >>> >>> @@ -85,5 +86,39 @@ >>> } >>> } >>> } >>> + >>> + [Test] >>> + public void >>> CanCombineSingleFutureValueWithEnumerableFutures() >>> + { >>> + using (var s = sessions.OpenSession()) >>> + { >>> + if (((SessionFactoryImpl)sessions) >>> + >>> .ConnectionProvider.Driver.SupportsMultipleQueries == false) >>> + { >>> + Assert.Ignore("Not applicable for >>> dialects that do not support multiple queries"); >>> + } >>> + >>> + var persons = >>> s.CreateCriteria(typeof(Person)) >>> + .SetMaxResults(10) >>> + .Future<Person>(); >>> + >>> + var personCount = >>> s.CreateCriteria(typeof(Person)) >>> + >>> .SetProjection(Projections.RowCount()) >>> + .FutureValue<int>(); >>> + >>> + using (var logSpy = new SqlLogSpy()) >>> + { >>> + int count = personCount.Value; >>> + >>> + foreach (var person in persons) >>> + { >>> + >>> + } >>> + >>> + var events = >>> logSpy.Appender.GetEvents(); >>> + Assert.AreEqual(1, >>> events.Length); >>> + } >>> + } >>> + } >>> } >>> } >>> >>> >>> This was sent by the SourceForge.net collaborative development platform, >>> the world's largest Open Source development site. >>> >>> >>> ------------------------------------------------------------------------------ >>> This SF.net email is sponsored by: >>> SourcForge Community >>> SourceForge wants to tell your story. >>> http://p.sf.net/sfu/sf-spreadtheword >>> _______________________________________________ >>> Nhibernate-commit mailing list >>> Nhi...@li... >>> https://lists.sourceforge.net/lists/listinfo/nhibernate-commit >>> >> >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by: >> SourcForge Community >> SourceForge wants to tell your story. >> http://p.sf.net/sfu/sf-spreadtheword >> _______________________________________________ >> Nhibernate-commit mailing list >> Nhi...@li... >> https://lists.sourceforge.net/lists/listinfo/nhibernate-commit >> >> > > > -- > Davy Brion > http://davybrion.com > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > > -- Dario Quintana http://darioquintana.com.ar |
From: Tuna T. <te...@gm...> - 2009-01-25 20:25:59
|
No problem =:) Tuna Toksöz http://tunatoksoz.com Typos included to enhance the readers attention! On Sun, Jan 25, 2009 at 9:56 PM, Davy Brion <ra...@da...> wrote: > nope sorry, i didn't think of it > > > On Sun, Jan 25, 2009 at 8:49 PM, Tuna Toksoz <te...@gm...> wrote: > >> Davy did you create a jira for this? >> >> Tuna Toksöz >> http://tunatoksoz.com >> >> Typos included to enhance the readers attention! >> >> >> >> >> On Sun, Jan 25, 2009 at 9:31 PM, <dav...@us...> wrote: >> >>> Revision: 4000 >>> >>> http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4000&view=rev >>> Author: davybrion >>> Date: 2009-01-25 19:31:49 +0000 (Sun, 25 Jan 2009) >>> >>> Log Message: >>> ----------- >>> implementation for FutureValue<T> method on ICriteria (very similar to >>> the Future<T> implementation) >>> >>> Modified Paths: >>> -------------- >>> trunk/nhibernate/src/NHibernate/ICriteria.cs >>> trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> trunk/nhibernate/src/NHibernate/NHibernate.csproj >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> >>> Added Paths: >>> ----------- >>> trunk/nhibernate/src/NHibernate/IFutureValue.cs >>> >>> Modified: trunk/nhibernate/src/NHibernate/ICriteria.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-23 >>> 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-25 >>> 19:31:49 UTC (rev 4000) >>> @@ -253,6 +253,16 @@ >>> /// <returns></returns> >>> IEnumerable<T> Future<T>(); >>> >>> + /// <summary> >>> + /// Get an IFutureValue instance, whose value can be >>> retrieved through >>> + /// its Value property. The query is not executed until >>> the Value property >>> + /// is retrieved, which will execute other Future queries >>> as well in a >>> + /// single roundtrip >>> + /// </summary> >>> + /// <typeparam name="T"></typeparam> >>> + /// <returns></returns> >>> + IFutureValue<T> FutureValue<T>(); >>> + >>> #region NHibernate specific >>> >>> /// <summary> >>> >>> Added: trunk/nhibernate/src/NHibernate/IFutureValue.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/IFutureValue.cs >>> (rev 0) >>> +++ trunk/nhibernate/src/NHibernate/IFutureValue.cs 2009-01-25 >>> 19:31:49 UTC (rev 4000) >>> @@ -0,0 +1,7 @@ >>> +namespace NHibernate >>> +{ >>> + public interface IFutureValue<T> >>> + { >>> + T Value { get; } >>> + } >>> +} >>> \ No newline at end of file >>> >>> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> 2009-01-23 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >>> 2009-01-25 19:31:49 UTC (rev 4000) >>> @@ -371,6 +371,12 @@ >>> return new Subcriteria(this, this, >>> associationPath, alias, joinType); >>> } >>> >>> + public IFutureValue<T> FutureValue<T>() >>> + { >>> + session.FutureCriteriaBatch.Add(this); >>> + return >>> session.FutureCriteriaBatch.GetFutureValue<T>(); >>> + } >>> + >>> public IEnumerable<T> Future<T>() >>> { >>> session.FutureCriteriaBatch.Add(this); >>> @@ -687,6 +693,11 @@ >>> return root.List(); >>> } >>> >>> + public IFutureValue<T> FutureValue<T>() >>> + { >>> + return root.FutureValue<T>(); >>> + } >>> + >>> public IEnumerable<T> Future<T>() >>> { >>> return root.Future<T>(); >>> >>> Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> 2009-01-23 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >>> 2009-01-25 19:31:49 UTC (rev 4000) >>> @@ -3,87 +3,124 @@ >>> >>> namespace NHibernate.Impl >>> { >>> - public class FutureCriteriaBatch >>> - { >>> - private readonly List<ICriteria> criterias = new >>> List<ICriteria>(); >>> - private int index; >>> - private IList results; >>> - private readonly ISession session; >>> + public class FutureCriteriaBatch >>> + { >>> + private readonly List<ICriteria> criterias = new >>> List<ICriteria>(); >>> + private int index; >>> + private IList results; >>> + private readonly ISession session; >>> >>> - public FutureCriteriaBatch(ISession session) >>> - { >>> - this.session = session; >>> - } >>> + public FutureCriteriaBatch(ISession session) >>> + { >>> + this.session = session; >>> + } >>> >>> - public IList Results >>> - { >>> - get >>> - { >>> - if (results == null) >>> - { >>> - var multiCriteria = session.CreateMultiCriteria(); >>> - foreach (var crit in criterias) >>> - { >>> - multiCriteria.Add(crit); >>> - } >>> - results = multiCriteria.List(); >>> - ((SessionImpl)session).FutureCriteriaBatch = null; >>> - } >>> - return results; >>> - } >>> - } >>> + public IList Results >>> + { >>> + get >>> + { >>> + if (results == null) >>> + { >>> + var multiCriteria = >>> session.CreateMultiCriteria(); >>> + foreach (var crit in criterias) >>> + { >>> + multiCriteria.Add(crit); >>> + } >>> + results = multiCriteria.List(); >>> + >>> ((SessionImpl)session).FutureCriteriaBatch = null; >>> + } >>> + return results; >>> + } >>> + } >>> >>> - public void Add(ICriteria criteria) >>> - { >>> - criterias.Add(criteria); >>> - index = criterias.Count - 1; >>> - } >>> + public void Add(ICriteria criteria) >>> + { >>> + criterias.Add(criteria); >>> + index = criterias.Count - 1; >>> + } >>> >>> - public IEnumerable<T> GetEnumerator<T>() >>> - { >>> - int currentIndex = index; >>> - return new DelayedEnumerator<T>(() => >>> (IList)Results[currentIndex]); >>> - } >>> + public IFutureValue<T> GetFutureValue<T>() >>> + { >>> + int currentIndex = index; >>> + return new FutureValue<T>(() => >>> (IList)Results[currentIndex]); >>> + } >>> >>> - #region Nested type: DelayedEnumerator >>> + public IEnumerable<T> GetEnumerator<T>() >>> + { >>> + int currentIndex = index; >>> + return new DelayedEnumerator<T>(() => >>> (IList)Results[currentIndex]); >>> + } >>> >>> - private class DelayedEnumerator<T> : IEnumerable<T> >>> - { >>> - public delegate IList GetResult(); >>> + #region Nested type: FutureValue >>> >>> - private readonly GetResult result; >>> + private class FutureValue<T> : IFutureValue<T> >>> + { >>> + public delegate IList GetResult(); >>> >>> - public DelayedEnumerator(GetResult result) >>> - { >>> - this.result = result; >>> - } >>> + private readonly GetResult getResult; >>> >>> - public IEnumerable<T> Enumerable >>> - { >>> - get >>> - { >>> - foreach (T item in result()) >>> - { >>> - yield return item; >>> - } >>> - } >>> - } >>> + public FutureValue(GetResult result) >>> + { >>> + getResult = result; >>> + } >>> >>> - #region IEnumerable<T> Members >>> + public T Value >>> + { >>> + get >>> + { >>> + var result = getResult(); >>> >>> - IEnumerator IEnumerable.GetEnumerator() >>> - { >>> - return ((IEnumerable) Enumerable).GetEnumerator(); >>> - } >>> + if (result.Count == 0) >>> + { >>> + return default(T); >>> + } >>> >>> - public IEnumerator<T> GetEnumerator() >>> - { >>> - return Enumerable.GetEnumerator(); >>> - } >>> + return (T)result[0]; >>> + } >>> + } >>> + } >>> >>> - #endregion >>> - } >>> + #endregion >>> >>> - #endregion >>> - } >>> + #region Nested type: DelayedEnumerator >>> + >>> + private class DelayedEnumerator<T> : IEnumerable<T> >>> + { >>> + public delegate IList GetResult(); >>> + >>> + private readonly GetResult result; >>> + >>> + public DelayedEnumerator(GetResult result) >>> + { >>> + this.result = result; >>> + } >>> + >>> + public IEnumerable<T> Enumerable >>> + { >>> + get >>> + { >>> + foreach (T item in result()) >>> + { >>> + yield return item; >>> + } >>> + } >>> + } >>> + >>> + #region IEnumerable<T> Members >>> + >>> + IEnumerator IEnumerable.GetEnumerator() >>> + { >>> + return >>> ((IEnumerable)Enumerable).GetEnumerator(); >>> + } >>> + >>> + public IEnumerator<T> GetEnumerator() >>> + { >>> + return Enumerable.GetEnumerator(); >>> + } >>> + >>> + #endregion >>> + } >>> + >>> + #endregion >>> + } >>> } >>> >>> Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-23 >>> 07:13:16 UTC (rev 3999) >>> +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-25 >>> 19:31:49 UTC (rev 4000) >>> @@ -456,6 +456,7 @@ >>> <Compile Include="Exceptions\SqlStateExtracter.cs" /> >>> <Compile >>> Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" /> >>> <Compile Include="Id\SelectGenerator.cs" /> >>> + <Compile Include="IFutureValue.cs" /> >>> <Compile Include="Impl\FutureCriteriaBatch.cs" /> >>> <Compile Include="Properties\BackFieldStrategy.cs" /> >>> <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> >>> >>> Modified: >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> =================================================================== >>> --- >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> 2009-01-23 07:13:16 UTC (rev 3999) >>> +++ >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >>> 2009-01-25 19:31:49 UTC (rev 4000) >>> @@ -1,3 +1,4 @@ >>> +using NHibernate.Criterion; >>> using NHibernate.Impl; >>> using NUnit.Framework; >>> >>> @@ -85,5 +86,39 @@ >>> } >>> } >>> } >>> + >>> + [Test] >>> + public void >>> CanCombineSingleFutureValueWithEnumerableFutures() >>> + { >>> + using (var s = sessions.OpenSession()) >>> + { >>> + if (((SessionFactoryImpl)sessions) >>> + >>> .ConnectionProvider.Driver.SupportsMultipleQueries == false) >>> + { >>> + Assert.Ignore("Not applicable for >>> dialects that do not support multiple queries"); >>> + } >>> + >>> + var persons = >>> s.CreateCriteria(typeof(Person)) >>> + .SetMaxResults(10) >>> + .Future<Person>(); >>> + >>> + var personCount = >>> s.CreateCriteria(typeof(Person)) >>> + >>> .SetProjection(Projections.RowCount()) >>> + .FutureValue<int>(); >>> + >>> + using (var logSpy = new SqlLogSpy()) >>> + { >>> + int count = personCount.Value; >>> + >>> + foreach (var person in persons) >>> + { >>> + >>> + } >>> + >>> + var events = >>> logSpy.Appender.GetEvents(); >>> + Assert.AreEqual(1, >>> events.Length); >>> + } >>> + } >>> + } >>> } >>> } >>> >>> >>> This was sent by the SourceForge.net collaborative development platform, >>> the world's largest Open Source development site. >>> >>> >>> ------------------------------------------------------------------------------ >>> This SF.net email is sponsored by: >>> SourcForge Community >>> SourceForge wants to tell your story. >>> http://p.sf.net/sfu/sf-spreadtheword >>> _______________________________________________ >>> Nhibernate-commit mailing list >>> Nhi...@li... >>> https://lists.sourceforge.net/lists/listinfo/nhibernate-commit >>> >> >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by: >> SourcForge Community >> SourceForge wants to tell your story. >> http://p.sf.net/sfu/sf-spreadtheword >> _______________________________________________ >> Nhibernate-commit mailing list >> Nhi...@li... >> https://lists.sourceforge.net/lists/listinfo/nhibernate-commit >> >> > > > -- > Davy Brion > http://davybrion.com > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > > |
From: Davy B. <ra...@da...> - 2009-01-25 20:23:52
|
nope sorry, i didn't think of it On Sun, Jan 25, 2009 at 8:49 PM, Tuna Toksoz <te...@gm...> wrote: > Davy did you create a jira for this? > > Tuna Toksöz > http://tunatoksoz.com > > Typos included to enhance the readers attention! > > > > > On Sun, Jan 25, 2009 at 9:31 PM, <dav...@us...> wrote: > >> Revision: 4000 >> >> http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4000&view=rev >> Author: davybrion >> Date: 2009-01-25 19:31:49 +0000 (Sun, 25 Jan 2009) >> >> Log Message: >> ----------- >> implementation for FutureValue<T> method on ICriteria (very similar to the >> Future<T> implementation) >> >> Modified Paths: >> -------------- >> trunk/nhibernate/src/NHibernate/ICriteria.cs >> trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >> trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >> trunk/nhibernate/src/NHibernate/NHibernate.csproj >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >> >> Added Paths: >> ----------- >> trunk/nhibernate/src/NHibernate/IFutureValue.cs >> >> Modified: trunk/nhibernate/src/NHibernate/ICriteria.cs >> =================================================================== >> --- trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-23 >> 07:13:16 UTC (rev 3999) >> +++ trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-25 >> 19:31:49 UTC (rev 4000) >> @@ -253,6 +253,16 @@ >> /// <returns></returns> >> IEnumerable<T> Future<T>(); >> >> + /// <summary> >> + /// Get an IFutureValue instance, whose value can be >> retrieved through >> + /// its Value property. The query is not executed until >> the Value property >> + /// is retrieved, which will execute other Future queries >> as well in a >> + /// single roundtrip >> + /// </summary> >> + /// <typeparam name="T"></typeparam> >> + /// <returns></returns> >> + IFutureValue<T> FutureValue<T>(); >> + >> #region NHibernate specific >> >> /// <summary> >> >> Added: trunk/nhibernate/src/NHibernate/IFutureValue.cs >> =================================================================== >> --- trunk/nhibernate/src/NHibernate/IFutureValue.cs >> (rev 0) >> +++ trunk/nhibernate/src/NHibernate/IFutureValue.cs 2009-01-25 >> 19:31:49 UTC (rev 4000) >> @@ -0,0 +1,7 @@ >> +namespace NHibernate >> +{ >> + public interface IFutureValue<T> >> + { >> + T Value { get; } >> + } >> +} >> \ No newline at end of file >> >> Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs >> =================================================================== >> --- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-23 >> 07:13:16 UTC (rev 3999) >> +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-25 >> 19:31:49 UTC (rev 4000) >> @@ -371,6 +371,12 @@ >> return new Subcriteria(this, this, associationPath, >> alias, joinType); >> } >> >> + public IFutureValue<T> FutureValue<T>() >> + { >> + session.FutureCriteriaBatch.Add(this); >> + return >> session.FutureCriteriaBatch.GetFutureValue<T>(); >> + } >> + >> public IEnumerable<T> Future<T>() >> { >> session.FutureCriteriaBatch.Add(this); >> @@ -687,6 +693,11 @@ >> return root.List(); >> } >> >> + public IFutureValue<T> FutureValue<T>() >> + { >> + return root.FutureValue<T>(); >> + } >> + >> public IEnumerable<T> Future<T>() >> { >> return root.Future<T>(); >> >> Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs >> =================================================================== >> --- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-23 >> 07:13:16 UTC (rev 3999) >> +++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-25 >> 19:31:49 UTC (rev 4000) >> @@ -3,87 +3,124 @@ >> >> namespace NHibernate.Impl >> { >> - public class FutureCriteriaBatch >> - { >> - private readonly List<ICriteria> criterias = new >> List<ICriteria>(); >> - private int index; >> - private IList results; >> - private readonly ISession session; >> + public class FutureCriteriaBatch >> + { >> + private readonly List<ICriteria> criterias = new >> List<ICriteria>(); >> + private int index; >> + private IList results; >> + private readonly ISession session; >> >> - public FutureCriteriaBatch(ISession session) >> - { >> - this.session = session; >> - } >> + public FutureCriteriaBatch(ISession session) >> + { >> + this.session = session; >> + } >> >> - public IList Results >> - { >> - get >> - { >> - if (results == null) >> - { >> - var multiCriteria = session.CreateMultiCriteria(); >> - foreach (var crit in criterias) >> - { >> - multiCriteria.Add(crit); >> - } >> - results = multiCriteria.List(); >> - ((SessionImpl)session).FutureCriteriaBatch = null; >> - } >> - return results; >> - } >> - } >> + public IList Results >> + { >> + get >> + { >> + if (results == null) >> + { >> + var multiCriteria = >> session.CreateMultiCriteria(); >> + foreach (var crit in criterias) >> + { >> + multiCriteria.Add(crit); >> + } >> + results = multiCriteria.List(); >> + >> ((SessionImpl)session).FutureCriteriaBatch = null; >> + } >> + return results; >> + } >> + } >> >> - public void Add(ICriteria criteria) >> - { >> - criterias.Add(criteria); >> - index = criterias.Count - 1; >> - } >> + public void Add(ICriteria criteria) >> + { >> + criterias.Add(criteria); >> + index = criterias.Count - 1; >> + } >> >> - public IEnumerable<T> GetEnumerator<T>() >> - { >> - int currentIndex = index; >> - return new DelayedEnumerator<T>(() => >> (IList)Results[currentIndex]); >> - } >> + public IFutureValue<T> GetFutureValue<T>() >> + { >> + int currentIndex = index; >> + return new FutureValue<T>(() => >> (IList)Results[currentIndex]); >> + } >> >> - #region Nested type: DelayedEnumerator >> + public IEnumerable<T> GetEnumerator<T>() >> + { >> + int currentIndex = index; >> + return new DelayedEnumerator<T>(() => >> (IList)Results[currentIndex]); >> + } >> >> - private class DelayedEnumerator<T> : IEnumerable<T> >> - { >> - public delegate IList GetResult(); >> + #region Nested type: FutureValue >> >> - private readonly GetResult result; >> + private class FutureValue<T> : IFutureValue<T> >> + { >> + public delegate IList GetResult(); >> >> - public DelayedEnumerator(GetResult result) >> - { >> - this.result = result; >> - } >> + private readonly GetResult getResult; >> >> - public IEnumerable<T> Enumerable >> - { >> - get >> - { >> - foreach (T item in result()) >> - { >> - yield return item; >> - } >> - } >> - } >> + public FutureValue(GetResult result) >> + { >> + getResult = result; >> + } >> >> - #region IEnumerable<T> Members >> + public T Value >> + { >> + get >> + { >> + var result = getResult(); >> >> - IEnumerator IEnumerable.GetEnumerator() >> - { >> - return ((IEnumerable) Enumerable).GetEnumerator(); >> - } >> + if (result.Count == 0) >> + { >> + return default(T); >> + } >> >> - public IEnumerator<T> GetEnumerator() >> - { >> - return Enumerable.GetEnumerator(); >> - } >> + return (T)result[0]; >> + } >> + } >> + } >> >> - #endregion >> - } >> + #endregion >> >> - #endregion >> - } >> + #region Nested type: DelayedEnumerator >> + >> + private class DelayedEnumerator<T> : IEnumerable<T> >> + { >> + public delegate IList GetResult(); >> + >> + private readonly GetResult result; >> + >> + public DelayedEnumerator(GetResult result) >> + { >> + this.result = result; >> + } >> + >> + public IEnumerable<T> Enumerable >> + { >> + get >> + { >> + foreach (T item in result()) >> + { >> + yield return item; >> + } >> + } >> + } >> + >> + #region IEnumerable<T> Members >> + >> + IEnumerator IEnumerable.GetEnumerator() >> + { >> + return >> ((IEnumerable)Enumerable).GetEnumerator(); >> + } >> + >> + public IEnumerator<T> GetEnumerator() >> + { >> + return Enumerable.GetEnumerator(); >> + } >> + >> + #endregion >> + } >> + >> + #endregion >> + } >> } >> >> Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj >> =================================================================== >> --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-23 >> 07:13:16 UTC (rev 3999) >> +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-25 >> 19:31:49 UTC (rev 4000) >> @@ -456,6 +456,7 @@ >> <Compile Include="Exceptions\SqlStateExtracter.cs" /> >> <Compile >> Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" /> >> <Compile Include="Id\SelectGenerator.cs" /> >> + <Compile Include="IFutureValue.cs" /> >> <Compile Include="Impl\FutureCriteriaBatch.cs" /> >> <Compile Include="Properties\BackFieldStrategy.cs" /> >> <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> >> >> Modified: >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >> =================================================================== >> --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >> 2009-01-23 07:13:16 UTC (rev 3999) >> +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs >> 2009-01-25 19:31:49 UTC (rev 4000) >> @@ -1,3 +1,4 @@ >> +using NHibernate.Criterion; >> using NHibernate.Impl; >> using NUnit.Framework; >> >> @@ -85,5 +86,39 @@ >> } >> } >> } >> + >> + [Test] >> + public void >> CanCombineSingleFutureValueWithEnumerableFutures() >> + { >> + using (var s = sessions.OpenSession()) >> + { >> + if (((SessionFactoryImpl)sessions) >> + >> .ConnectionProvider.Driver.SupportsMultipleQueries == false) >> + { >> + Assert.Ignore("Not applicable for >> dialects that do not support multiple queries"); >> + } >> + >> + var persons = >> s.CreateCriteria(typeof(Person)) >> + .SetMaxResults(10) >> + .Future<Person>(); >> + >> + var personCount = >> s.CreateCriteria(typeof(Person)) >> + >> .SetProjection(Projections.RowCount()) >> + .FutureValue<int>(); >> + >> + using (var logSpy = new SqlLogSpy()) >> + { >> + int count = personCount.Value; >> + >> + foreach (var person in persons) >> + { >> + >> + } >> + >> + var events = >> logSpy.Appender.GetEvents(); >> + Assert.AreEqual(1, events.Length); >> + } >> + } >> + } >> } >> } >> >> >> This was sent by the SourceForge.net collaborative development platform, >> the world's largest Open Source development site. >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by: >> SourcForge Community >> SourceForge wants to tell your story. >> http://p.sf.net/sfu/sf-spreadtheword >> _______________________________________________ >> Nhibernate-commit mailing list >> Nhi...@li... >> https://lists.sourceforge.net/lists/listinfo/nhibernate-commit >> > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > > -- Davy Brion http://davybrion.com |
From: Tuna T. <te...@gm...> - 2009-01-25 19:49:40
|
Davy did you create a jira for this? Tuna Toksöz http://tunatoksoz.com Typos included to enhance the readers attention! On Sun, Jan 25, 2009 at 9:31 PM, <dav...@us...> wrote: > Revision: 4000 > > http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4000&view=rev > Author: davybrion > Date: 2009-01-25 19:31:49 +0000 (Sun, 25 Jan 2009) > > Log Message: > ----------- > implementation for FutureValue<T> method on ICriteria (very similar to the > Future<T> implementation) > > Modified Paths: > -------------- > trunk/nhibernate/src/NHibernate/ICriteria.cs > trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs > trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs > trunk/nhibernate/src/NHibernate/NHibernate.csproj > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs > > Added Paths: > ----------- > trunk/nhibernate/src/NHibernate/IFutureValue.cs > > Modified: trunk/nhibernate/src/NHibernate/ICriteria.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-23 07:13:16 > UTC (rev 3999) > +++ trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-25 19:31:49 > UTC (rev 4000) > @@ -253,6 +253,16 @@ > /// <returns></returns> > IEnumerable<T> Future<T>(); > > + /// <summary> > + /// Get an IFutureValue instance, whose value can be > retrieved through > + /// its Value property. The query is not executed until the > Value property > + /// is retrieved, which will execute other Future queries > as well in a > + /// single roundtrip > + /// </summary> > + /// <typeparam name="T"></typeparam> > + /// <returns></returns> > + IFutureValue<T> FutureValue<T>(); > + > #region NHibernate specific > > /// <summary> > > Added: trunk/nhibernate/src/NHibernate/IFutureValue.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/IFutureValue.cs > (rev 0) > +++ trunk/nhibernate/src/NHibernate/IFutureValue.cs 2009-01-25 19:31:49 > UTC (rev 4000) > @@ -0,0 +1,7 @@ > +namespace NHibernate > +{ > + public interface IFutureValue<T> > + { > + T Value { get; } > + } > +} > \ No newline at end of file > > Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-23 > 07:13:16 UTC (rev 3999) > +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-25 > 19:31:49 UTC (rev 4000) > @@ -371,6 +371,12 @@ > return new Subcriteria(this, this, associationPath, > alias, joinType); > } > > + public IFutureValue<T> FutureValue<T>() > + { > + session.FutureCriteriaBatch.Add(this); > + return > session.FutureCriteriaBatch.GetFutureValue<T>(); > + } > + > public IEnumerable<T> Future<T>() > { > session.FutureCriteriaBatch.Add(this); > @@ -687,6 +693,11 @@ > return root.List(); > } > > + public IFutureValue<T> FutureValue<T>() > + { > + return root.FutureValue<T>(); > + } > + > public IEnumerable<T> Future<T>() > { > return root.Future<T>(); > > Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-23 > 07:13:16 UTC (rev 3999) > +++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-25 > 19:31:49 UTC (rev 4000) > @@ -3,87 +3,124 @@ > > namespace NHibernate.Impl > { > - public class FutureCriteriaBatch > - { > - private readonly List<ICriteria> criterias = new > List<ICriteria>(); > - private int index; > - private IList results; > - private readonly ISession session; > + public class FutureCriteriaBatch > + { > + private readonly List<ICriteria> criterias = new > List<ICriteria>(); > + private int index; > + private IList results; > + private readonly ISession session; > > - public FutureCriteriaBatch(ISession session) > - { > - this.session = session; > - } > + public FutureCriteriaBatch(ISession session) > + { > + this.session = session; > + } > > - public IList Results > - { > - get > - { > - if (results == null) > - { > - var multiCriteria = session.CreateMultiCriteria(); > - foreach (var crit in criterias) > - { > - multiCriteria.Add(crit); > - } > - results = multiCriteria.List(); > - ((SessionImpl)session).FutureCriteriaBatch = null; > - } > - return results; > - } > - } > + public IList Results > + { > + get > + { > + if (results == null) > + { > + var multiCriteria = > session.CreateMultiCriteria(); > + foreach (var crit in criterias) > + { > + multiCriteria.Add(crit); > + } > + results = multiCriteria.List(); > + > ((SessionImpl)session).FutureCriteriaBatch = null; > + } > + return results; > + } > + } > > - public void Add(ICriteria criteria) > - { > - criterias.Add(criteria); > - index = criterias.Count - 1; > - } > + public void Add(ICriteria criteria) > + { > + criterias.Add(criteria); > + index = criterias.Count - 1; > + } > > - public IEnumerable<T> GetEnumerator<T>() > - { > - int currentIndex = index; > - return new DelayedEnumerator<T>(() => > (IList)Results[currentIndex]); > - } > + public IFutureValue<T> GetFutureValue<T>() > + { > + int currentIndex = index; > + return new FutureValue<T>(() => > (IList)Results[currentIndex]); > + } > > - #region Nested type: DelayedEnumerator > + public IEnumerable<T> GetEnumerator<T>() > + { > + int currentIndex = index; > + return new DelayedEnumerator<T>(() => > (IList)Results[currentIndex]); > + } > > - private class DelayedEnumerator<T> : IEnumerable<T> > - { > - public delegate IList GetResult(); > + #region Nested type: FutureValue > > - private readonly GetResult result; > + private class FutureValue<T> : IFutureValue<T> > + { > + public delegate IList GetResult(); > > - public DelayedEnumerator(GetResult result) > - { > - this.result = result; > - } > + private readonly GetResult getResult; > > - public IEnumerable<T> Enumerable > - { > - get > - { > - foreach (T item in result()) > - { > - yield return item; > - } > - } > - } > + public FutureValue(GetResult result) > + { > + getResult = result; > + } > > - #region IEnumerable<T> Members > + public T Value > + { > + get > + { > + var result = getResult(); > > - IEnumerator IEnumerable.GetEnumerator() > - { > - return ((IEnumerable) Enumerable).GetEnumerator(); > - } > + if (result.Count == 0) > + { > + return default(T); > + } > > - public IEnumerator<T> GetEnumerator() > - { > - return Enumerable.GetEnumerator(); > - } > + return (T)result[0]; > + } > + } > + } > > - #endregion > - } > + #endregion > > - #endregion > - } > + #region Nested type: DelayedEnumerator > + > + private class DelayedEnumerator<T> : IEnumerable<T> > + { > + public delegate IList GetResult(); > + > + private readonly GetResult result; > + > + public DelayedEnumerator(GetResult result) > + { > + this.result = result; > + } > + > + public IEnumerable<T> Enumerable > + { > + get > + { > + foreach (T item in result()) > + { > + yield return item; > + } > + } > + } > + > + #region IEnumerable<T> Members > + > + IEnumerator IEnumerable.GetEnumerator() > + { > + return > ((IEnumerable)Enumerable).GetEnumerator(); > + } > + > + public IEnumerator<T> GetEnumerator() > + { > + return Enumerable.GetEnumerator(); > + } > + > + #endregion > + } > + > + #endregion > + } > } > > Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj > =================================================================== > --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-23 07:13:16 > UTC (rev 3999) > +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-25 19:31:49 > UTC (rev 4000) > @@ -456,6 +456,7 @@ > <Compile Include="Exceptions\SqlStateExtracter.cs" /> > <Compile > Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" /> > <Compile Include="Id\SelectGenerator.cs" /> > + <Compile Include="IFutureValue.cs" /> > <Compile Include="Impl\FutureCriteriaBatch.cs" /> > <Compile Include="Properties\BackFieldStrategy.cs" /> > <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> > > Modified: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs > 2009-01-23 07:13:16 UTC (rev 3999) > +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs > 2009-01-25 19:31:49 UTC (rev 4000) > @@ -1,3 +1,4 @@ > +using NHibernate.Criterion; > using NHibernate.Impl; > using NUnit.Framework; > > @@ -85,5 +86,39 @@ > } > } > } > + > + [Test] > + public void > CanCombineSingleFutureValueWithEnumerableFutures() > + { > + using (var s = sessions.OpenSession()) > + { > + if (((SessionFactoryImpl)sessions) > + > .ConnectionProvider.Driver.SupportsMultipleQueries == false) > + { > + Assert.Ignore("Not applicable for > dialects that do not support multiple queries"); > + } > + > + var persons = > s.CreateCriteria(typeof(Person)) > + .SetMaxResults(10) > + .Future<Person>(); > + > + var personCount = > s.CreateCriteria(typeof(Person)) > + > .SetProjection(Projections.RowCount()) > + .FutureValue<int>(); > + > + using (var logSpy = new SqlLogSpy()) > + { > + int count = personCount.Value; > + > + foreach (var person in persons) > + { > + > + } > + > + var events = > logSpy.Appender.GetEvents(); > + Assert.AreEqual(1, events.Length); > + } > + } > + } > } > } > > > This was sent by the SourceForge.net collaborative development platform, > the world's largest Open Source development site. > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > |
From: <dav...@us...> - 2009-01-25 19:31:51
|
Revision: 4000 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4000&view=rev Author: davybrion Date: 2009-01-25 19:31:49 +0000 (Sun, 25 Jan 2009) Log Message: ----------- implementation for FutureValue<T> method on ICriteria (very similar to the Future<T> implementation) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/ICriteria.cs trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate/IFutureValue.cs Modified: trunk/nhibernate/src/NHibernate/ICriteria.cs =================================================================== --- trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-23 07:13:16 UTC (rev 3999) +++ trunk/nhibernate/src/NHibernate/ICriteria.cs 2009-01-25 19:31:49 UTC (rev 4000) @@ -253,6 +253,16 @@ /// <returns></returns> IEnumerable<T> Future<T>(); + /// <summary> + /// Get an IFutureValue instance, whose value can be retrieved through + /// its Value property. The query is not executed until the Value property + /// is retrieved, which will execute other Future queries as well in a + /// single roundtrip + /// </summary> + /// <typeparam name="T"></typeparam> + /// <returns></returns> + IFutureValue<T> FutureValue<T>(); + #region NHibernate specific /// <summary> Added: trunk/nhibernate/src/NHibernate/IFutureValue.cs =================================================================== --- trunk/nhibernate/src/NHibernate/IFutureValue.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/IFutureValue.cs 2009-01-25 19:31:49 UTC (rev 4000) @@ -0,0 +1,7 @@ +namespace NHibernate +{ + public interface IFutureValue<T> + { + T Value { get; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-23 07:13:16 UTC (rev 3999) +++ trunk/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs 2009-01-25 19:31:49 UTC (rev 4000) @@ -371,6 +371,12 @@ return new Subcriteria(this, this, associationPath, alias, joinType); } + public IFutureValue<T> FutureValue<T>() + { + session.FutureCriteriaBatch.Add(this); + return session.FutureCriteriaBatch.GetFutureValue<T>(); + } + public IEnumerable<T> Future<T>() { session.FutureCriteriaBatch.Add(this); @@ -687,6 +693,11 @@ return root.List(); } + public IFutureValue<T> FutureValue<T>() + { + return root.FutureValue<T>(); + } + public IEnumerable<T> Future<T>() { return root.Future<T>(); Modified: trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-23 07:13:16 UTC (rev 3999) +++ trunk/nhibernate/src/NHibernate/Impl/FutureCriteriaBatch.cs 2009-01-25 19:31:49 UTC (rev 4000) @@ -3,87 +3,124 @@ namespace NHibernate.Impl { - public class FutureCriteriaBatch - { - private readonly List<ICriteria> criterias = new List<ICriteria>(); - private int index; - private IList results; - private readonly ISession session; + public class FutureCriteriaBatch + { + private readonly List<ICriteria> criterias = new List<ICriteria>(); + private int index; + private IList results; + private readonly ISession session; - public FutureCriteriaBatch(ISession session) - { - this.session = session; - } + public FutureCriteriaBatch(ISession session) + { + this.session = session; + } - public IList Results - { - get - { - if (results == null) - { - var multiCriteria = session.CreateMultiCriteria(); - foreach (var crit in criterias) - { - multiCriteria.Add(crit); - } - results = multiCriteria.List(); - ((SessionImpl)session).FutureCriteriaBatch = null; - } - return results; - } - } + public IList Results + { + get + { + if (results == null) + { + var multiCriteria = session.CreateMultiCriteria(); + foreach (var crit in criterias) + { + multiCriteria.Add(crit); + } + results = multiCriteria.List(); + ((SessionImpl)session).FutureCriteriaBatch = null; + } + return results; + } + } - public void Add(ICriteria criteria) - { - criterias.Add(criteria); - index = criterias.Count - 1; - } + public void Add(ICriteria criteria) + { + criterias.Add(criteria); + index = criterias.Count - 1; + } - public IEnumerable<T> GetEnumerator<T>() - { - int currentIndex = index; - return new DelayedEnumerator<T>(() => (IList)Results[currentIndex]); - } + public IFutureValue<T> GetFutureValue<T>() + { + int currentIndex = index; + return new FutureValue<T>(() => (IList)Results[currentIndex]); + } - #region Nested type: DelayedEnumerator + public IEnumerable<T> GetEnumerator<T>() + { + int currentIndex = index; + return new DelayedEnumerator<T>(() => (IList)Results[currentIndex]); + } - private class DelayedEnumerator<T> : IEnumerable<T> - { - public delegate IList GetResult(); + #region Nested type: FutureValue - private readonly GetResult result; + private class FutureValue<T> : IFutureValue<T> + { + public delegate IList GetResult(); - public DelayedEnumerator(GetResult result) - { - this.result = result; - } + private readonly GetResult getResult; - public IEnumerable<T> Enumerable - { - get - { - foreach (T item in result()) - { - yield return item; - } - } - } + public FutureValue(GetResult result) + { + getResult = result; + } - #region IEnumerable<T> Members + public T Value + { + get + { + var result = getResult(); - IEnumerator IEnumerable.GetEnumerator() - { - return ((IEnumerable) Enumerable).GetEnumerator(); - } + if (result.Count == 0) + { + return default(T); + } - public IEnumerator<T> GetEnumerator() - { - return Enumerable.GetEnumerator(); - } + return (T)result[0]; + } + } + } - #endregion - } + #endregion - #endregion - } + #region Nested type: DelayedEnumerator + + private class DelayedEnumerator<T> : IEnumerable<T> + { + public delegate IList GetResult(); + + private readonly GetResult result; + + public DelayedEnumerator(GetResult result) + { + this.result = result; + } + + public IEnumerable<T> Enumerable + { + get + { + foreach (T item in result()) + { + yield return item; + } + } + } + + #region IEnumerable<T> Members + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable)Enumerable).GetEnumerator(); + } + + public IEnumerator<T> GetEnumerator() + { + return Enumerable.GetEnumerator(); + } + + #endregion + } + + #endregion + } } Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-23 07:13:16 UTC (rev 3999) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-25 19:31:49 UTC (rev 4000) @@ -456,6 +456,7 @@ <Compile Include="Exceptions\SqlStateExtracter.cs" /> <Compile Include="Exceptions\TemplatedViolatedConstraintNameExtracter.cs" /> <Compile Include="Id\SelectGenerator.cs" /> + <Compile Include="IFutureValue.cs" /> <Compile Include="Impl\FutureCriteriaBatch.cs" /> <Compile Include="Properties\BackFieldStrategy.cs" /> <Compile Include="Bytecode\CodeDom\BytecodeProviderImpl.cs" /> Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs 2009-01-23 07:13:16 UTC (rev 3999) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs 2009-01-25 19:31:49 UTC (rev 4000) @@ -1,3 +1,4 @@ +using NHibernate.Criterion; using NHibernate.Impl; using NUnit.Framework; @@ -85,5 +86,39 @@ } } } + + [Test] + public void CanCombineSingleFutureValueWithEnumerableFutures() + { + using (var s = sessions.OpenSession()) + { + if (((SessionFactoryImpl)sessions) + .ConnectionProvider.Driver.SupportsMultipleQueries == false) + { + Assert.Ignore("Not applicable for dialects that do not support multiple queries"); + } + + var persons = s.CreateCriteria(typeof(Person)) + .SetMaxResults(10) + .Future<Person>(); + + var personCount = s.CreateCriteria(typeof(Person)) + .SetProjection(Projections.RowCount()) + .FutureValue<int>(); + + using (var logSpy = new SqlLogSpy()) + { + int count = personCount.Value; + + foreach (var person in persons) + { + + } + + var events = logSpy.Appender.GetEvents(); + Assert.AreEqual(1, events.Length); + } + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |