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: <aye...@us...> - 2009-05-15 07:44:45
|
Revision: 4313 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4313&view=rev Author: ayenderahien Date: 2009-05-15 07:44:35 +0000 (Fri, 15 May 2009) Log Message: ----------- SqlClientBatchingBatcher will now log to added statements consistently, regardless if AbstractBatcher is enabled or not. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs trunk/nhibernate/src/NHibernate.Test/LogSpy.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-15 06:31:42 UTC (rev 4312) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-15 07:44:35 UTC (rev 4313) @@ -50,7 +50,7 @@ } else { - Factory.Settings.SqlStatementLogger.LogCommand(batchUpdate, FormatStyle.Basic); + Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); } currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate); if (currentBatch.CountOfCommands >= batchSize) Modified: trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs 2009-05-15 06:31:42 UTC (rev 4312) +++ trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs 2009-05-15 07:44:35 UTC (rev 4313) @@ -120,7 +120,7 @@ sessions.Statistics.Clear(); FillDb(); string logs = sl.GetWholeLog(); - Assert.That(logs, Text.DoesNotContain("batch").IgnoreCase); + Assert.That(logs, Text.DoesNotContain("batcher").IgnoreCase); Assert.That(logs, Text.Contains("INSERT").IgnoreCase); } } Modified: trunk/nhibernate/src/NHibernate.Test/LogSpy.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/LogSpy.cs 2009-05-15 06:31:42 UTC (rev 4312) +++ trunk/nhibernate/src/NHibernate.Test/LogSpy.cs 2009-05-15 07:44:35 UTC (rev 4313) @@ -48,7 +48,10 @@ var wholeMessage = new StringBuilder(); foreach (LoggingEvent loggingEvent in Appender.GetEvents()) { - wholeMessage.Append(loggingEvent.RenderedMessage); + wholeMessage + .Append(loggingEvent.LoggerName) + .Append(" ") + .Append(loggingEvent.RenderedMessage); } return wholeMessage.ToString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-15 06:31:53
|
Revision: 4312 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4312&view=rev Author: fabiomaulo Date: 2009-05-15 06:31:42 +0000 (Fri, 15 May 2009) Log Message: ----------- Minor (refactoring) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs Modified: trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-05-15 05:10:15 UTC (rev 4311) +++ trunk/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs 2009-05-15 06:31:42 UTC (rev 4312) @@ -1,6 +1,7 @@ using System; -using System.Collections; using System.Data; +using System.Collections.Generic; +using NHibernate.Util; namespace NHibernate.SqlTypes { @@ -8,18 +9,14 @@ /// SqlTypeFactory provides Singleton access to the SqlTypes. /// </summary> [Serializable] - public sealed class SqlTypeFactory + public static class SqlTypeFactory { // key = typeof(sqlType).Name : ie - BinarySqlType(l), BooleanSqlType, DecimalSqlType(p,s) // value = SqlType - private static Hashtable sqlTypes = Hashtable.Synchronized(new Hashtable(41)); + private static readonly IDictionary<string, SqlType> SqlTypes = + new ThreadSafeDictionary<string, SqlType>(new Dictionary<string, SqlType>(128)); - private SqlTypeFactory() - { - } - public static readonly SqlType Guid = new SqlType(DbType.Guid); - public static readonly SqlType Boolean = new SqlType(DbType.Boolean); public static readonly SqlType Byte = new SqlType(DbType.Byte); public static readonly SqlType Currency = new SqlType(DbType.Currency); @@ -41,47 +38,38 @@ public static readonly SqlType[] NoTypes = new SqlType[0]; - public static AnsiStringSqlType GetAnsiString(int length) + private delegate SqlType TypeWithLenCreateDelegate(int length); // Func<int, T> + + private static T GetTypeWithLen<T>(int length, TypeWithLenCreateDelegate createDelegate) where T : SqlType { - string key = GetKeyForLengthBased(typeof(AnsiStringSqlType).Name, length); - AnsiStringSqlType returnSqlType = (AnsiStringSqlType) sqlTypes[key]; - if (returnSqlType == null) + string key = GetKeyForLengthBased(typeof (T).Name, length); + SqlType result; + if (!SqlTypes.TryGetValue(key, out result)) { - returnSqlType = new AnsiStringSqlType(length); - sqlTypes.Add(key, returnSqlType); + result = createDelegate(length); + SqlTypes.Add(key, result); } - return returnSqlType; + return (T) result; } - public static BinarySqlType GetBinary(int length) + public static AnsiStringSqlType GetAnsiString(int length) { - string key = GetKeyForLengthBased(typeof(BinarySqlType).Name, length); - BinarySqlType returnSqlType = (BinarySqlType) sqlTypes[key]; - if (returnSqlType == null) - { - returnSqlType = new BinarySqlType(length); - sqlTypes.Add(key, returnSqlType); - } - return returnSqlType; + return GetTypeWithLen<AnsiStringSqlType>(length, l => new AnsiStringSqlType(l)); } - public static SqlType GetDecimal(byte precision, byte scale) + public static BinarySqlType GetBinary(int length) { - return new SqlType(DbType.Decimal, precision, scale); + return GetTypeWithLen<BinarySqlType>(length, l => new BinarySqlType(l)); } public static StringSqlType GetString(int length) { - string key = GetKeyForLengthBased(typeof(StringSqlType).Name, length); + return GetTypeWithLen<StringSqlType>(length, l => new StringSqlType(l)); + } - StringSqlType returnSqlType = (StringSqlType) sqlTypes[key]; - if (returnSqlType == null) - { - returnSqlType = new StringSqlType(length); - sqlTypes.Add(key, returnSqlType); - } - - return returnSqlType; + public static SqlType GetDecimal(byte precision, byte scale) + { + return new SqlType(DbType.Decimal, precision, scale); } private static string GetKeyForLengthBased(string name, int length) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-05-15 05:10:24
|
Revision: 4311 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4311&view=rev Author: ayenderahien Date: 2009-05-15 05:10:15 +0000 (Fri, 15 May 2009) Log Message: ----------- minor - fixing spelling mistake in the log changing the log level of errors when querying the database to be Error instead of Warn Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-05-15 04:38:07 UTC (rev 4310) +++ trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-05-15 05:10:15 UTC (rev 4311) @@ -199,7 +199,7 @@ catch (Exception e) { e.Data["actual-sql-query"] = cmd.CommandText; - log.Warn("Could not execute command: " + cmd.CommandText, e); + log.Error("Could not execute command: " + cmd.CommandText, e); throw; } } @@ -217,7 +217,7 @@ catch (Exception e) { e.Data["actual-sql-query"] = cmd.CommandText; - log.Warn("Could not exeucte query: " + cmd.CommandText, e); + log.Error("Could not execute query: " + cmd.CommandText, e); throw; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-15 04:38:12
|
Revision: 4310 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4310&view=rev Author: fabiomaulo Date: 2009-05-15 04:38:07 +0000 (Fri, 15 May 2009) Log Message: ----------- Test NH1338 (if it was real, was fixed in some moment) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Mappings.hbm.xml Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Fixture.cs 2009-05-15 04:38:07 UTC (rev 4310) @@ -0,0 +1,129 @@ +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1388 +{ + public class Student + { + private int _id; + private readonly IDictionary<Subject, Major> _majors = new Dictionary<Subject, Major>(); + + public virtual int Id + { + get { return _id; } + } + + public virtual IDictionary<Subject, Major> Majors + { + get { return _majors; } + } + } + + public class Subject + { + public int Id { get; set; } + + public string Title { get; set; } + } + + public class Major + { + public string Note { get; set; } + } + + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void BagTest() + { + int studentId = 1; + + // Set major. + using (ISession session = OpenSession()) + { + ITransaction t = session.BeginTransaction(); + var student = new Student(); + var subject1 = new Subject {Id = 1}; + var subject2 = new Subject {Id = 2}; + + // Create major objects. + var major1 = new Major {Note = ""}; + + var major2 = new Major {Note = ""}; + + // Set major objects. + student.Majors[subject1] = major1; + student.Majors[subject2] = major2; + + session.Save(subject1); + session.Save(subject2); + session.Save(student); + + session.Flush(); + t.Commit(); + } + // Remove major for subject 2. + using (ISession session = OpenSession()) + { + ITransaction t = session.BeginTransaction(); + var student = session.Get<Student>(studentId); + var subject2 = session.Get<Subject>(2); + + // Remove major. + student.Majors.Remove(subject2); + + session.Flush(); + t.Commit(); + } + + // Get major for subject 2. + using (ISession session = OpenSession()) + { + ITransaction t = session.BeginTransaction(); + var student = session.Get<Student>(studentId); + var subject2 = session.Get<Subject>(2); + + Assert.IsNotNull(subject2); + + // Major for subject 2 should have been removed. + Assert.IsFalse(student.Majors.ContainsKey(subject2)); + + t.Commit(); + } + + // Remove all - NHibernate will now succeed in removing all. + using (ISession session = OpenSession()) + { + ITransaction t = session.BeginTransaction(); + var student = session.Get<Student>(studentId); + student.Majors.Clear(); + session.Flush(); + t.Commit(); + } + } + + protected override void OnTearDown() + { + // clean up the database + using (ISession session = OpenSession()) + { + session.BeginTransaction(); + foreach (var student in session.CreateCriteria(typeof (Student)).List<Student>()) + { + session.Delete(student); + } + foreach (var subject in session.CreateCriteria(typeof (Subject)).List<Subject>()) + { + session.Delete(subject); + } + session.Transaction.Commit(); + } + } + + protected override string CacheConcurrencyStrategy + { + get { return null; } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Mappings.hbm.xml 2009-05-15 04:38:07 UTC (rev 4310) @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping + xmlns="urn:nhibernate-mapping-2.2" + default-lazy="true" + default-cascade="save-update" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1388"> + + <class name="Student" table="STUDENT" lazy="false"> + + <id name="Id" column="STUDENT_ID" type="int" access="nosetter.camelcase-underscore"> + <generator class="native" > + <param name="sequence">STUDENT_ID_SEQUENCE</param> + </generator> + </id> + + <map name="Majors" + cascade="all" + inverse="false" + access="field.camelcase-underscore" + fetch="select" + lazy="true" + batch-size="100" + table="MAJOR"> + <key column="STUDENT_ID" foreign-key="STUDENT_ID" /> + <index-many-to-many column="SUBJECT_ID" class="Subject" /> + <composite-element class="Major"> + <property name="Note" column="NOTE" /> + </composite-element> + </map> + + </class> + + <class name="Subject" table="SUBJECT" lazy="false"> + + <id name="Id" column="SUBJECT_ID" type="int"> + <generator class="assigned" /> + </id> + + <property name="Title" column="TITLE" /> + </class> + +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 01:28:03 UTC (rev 4309) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 04:38:07 UTC (rev 4310) @@ -331,6 +331,7 @@ <Compile Include="MappingTest\Wicked.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" /> + <Compile Include="NHSpecificTest\NH1388\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1574\Principal.cs" /> <Compile Include="NHSpecificTest\NH1574\SpecializedPrincipal.cs" /> <Compile Include="NHSpecificTest\NH1574\SpecializedTeaml.cs" /> @@ -1784,6 +1785,7 @@ <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1388\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\ElementsEnums\SimpleWithEnums.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1574\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1776\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-15 01:28:13
|
Revision: 4309 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4309&view=rev Author: fabiomaulo Date: 2009-05-15 01:28:03 +0000 (Fri, 15 May 2009) Log Message: ----------- Fixed NH-1098 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1098/FilterParameterOrderFixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1098/FilterParameterOrderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1098/FilterParameterOrderFixture.cs 2009-05-15 01:14:05 UTC (rev 4308) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1098/FilterParameterOrderFixture.cs 2009-05-15 01:28:03 UTC (rev 4309) @@ -1,257 +1,219 @@ -using System; using System.Collections.Generic; using System.Text; -using NHibernate; -using NUnit.Framework; using NHibernate.Criterion; +using NHibernate.Hql.Ast.ANTLR; +using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH1098 { - [TestFixture] - public class FilterParameterOrderFixture : BugTestCase - { - public override string BugNumber - { - get { return "NH1098"; } - } + [TestFixture] + public class FilterParameterOrderFixture : BugTestCase + { + protected override void OnSetUp() + { + ISession session = OpenSession(); - protected override void OnSetUp() - { - ISession session = OpenSession(); + var a1 = new A {Id = 1, ValueA = 5, Enabled = false}; + session.Save(a1); - A a1 = new A(); - a1.Id = 1; - a1.ValueA = 5; - a1.Enabled = false; - session.Save( a1 ); + var a2 = new A {Id = 2, ValueA = 6, Enabled = true}; + session.Save(a2); - A a2 = new A(); - a2.Id = 2; - a2.ValueA = 6; - a2.Enabled = true; - session.Save( a2 ); + var a3 = new A {Id = 3, ValueA = 4, Enabled = true}; + session.Save(a3); - A a3 = new A(); - a3.Id = 3; - a3.ValueA = 4; - a3.Enabled = true; - session.Save( a3 ); + var a4 = new A {Id = 4, ValueA = 6, Enabled = true}; + session.Save(a4); - A a4 = new A(); - a4.Id = 4; - a4.ValueA = 6; - a4.Enabled = true; - session.Save( a4 ); + var b1 = new B {Id = 1, ValueB = 5, Enabled = false}; + session.Save(b1); - B b1 = new B(); - b1.Id = 1; - b1.ValueB = 5; - b1.Enabled = false; - session.Save( b1 ); + var b2 = new B {Id = 2, ValueB = 6, Enabled = true}; + session.Save(b2); - B b2 = new B(); - b2.Id = 2; - b2.ValueB = 6; - b2.Enabled = true; - session.Save( b2 ); + var b3 = new B {Id = 3, ValueB = 2, Enabled = false}; + session.Save(b3); - B b3 = new B(); - b3.Id = 3; - b3.ValueB = 2; - b3.Enabled = false; - session.Save( b3 ); + var b4 = new B {Id = 4, ValueB = 6, Enabled = true}; + session.Save(b4); - B b4 = new B(); - b4.Id = 4; - b4.ValueB = 6; - b4.Enabled = true; - session.Save( b4 ); + a1.C.Add(a1.Id, "Text1"); + a1.C.Add(a2.Id, "Text2"); - a1.C.Add( a1.Id, "Text1" ); - a1.C.Add( a2.Id, "Text2" ); + session.Flush(); + session.Close(); + } - session.Flush(); - session.Close(); - } + protected override void OnTearDown() + { + ISession session = OpenSession(); + session.Delete("from A"); + session.Delete("from B"); + session.Flush(); + session.Close(); + } - protected override void OnTearDown() - { - ISession session = OpenSession(); - session.Delete( "from A" ); - session.Delete( "from B" ); - session.Flush(); - session.Close(); - } + [Test] + public void CriteriaParameterOrder() + { + ISession session = OpenSession(); + session.EnableFilter("EnabledObjects").SetParameter("Enabled", true); - [Test] - public void CriteriaParameterOrder() - { - ISession session = OpenSession(); - session.EnableFilter( "EnabledObjects" ).SetParameter( "Enabled", true ); + DetachedCriteria detached = DetachedCriteria.For(typeof (B), "b"); + detached.Add(Restrictions.LtProperty("a.ValueA", "b.ValueB")).Add(Restrictions.Gt("ValueB", 5)).SetProjection( + Projections.Property("ValueB")); - DetachedCriteria detached = DetachedCriteria.For( typeof( B ), "b" ); - detached.Add( Expression.LtProperty( "a.ValueA", "b.ValueB" ) ) - .Add( Expression.Gt( "ValueB", 5 ) ) - .SetProjection( Projections.Property( "ValueB" ) ); + ICriteria crit = session.CreateCriteria(typeof (A), "a"); + crit.Add(Restrictions.Lt("ValueA", 6)).Add(Subqueries.Exists(detached)); - ICriteria crit = session.CreateCriteria( typeof( A ), "a" ); - crit.Add( Expression.Lt( "ValueA", 6 ) ) - .Add( Subqueries.Exists( detached ) ); + // + // Query: + // {select a0_.id as id0_, a0_.val_a as val2_0_, a0_.enabled as enabled0_ + // from table_a a0_ + // where a0_.enabled = ? and ((a0_.val_a<? )and + // (exists(select b1_.val_b + // from table_b b1_ + // where b1_.enabled = ? and + // ((a0_.val_a<b1_.val_b )and(b1_.val_b>? )))))} + // + // Parameter: + // 1) "this_.enabled = :EnabledObjects.Enabled" [filter #1] + // 2) "this_.val_a < (?)" [positional #1] + // 3) "this_0_.enabled = :EnabledObjects.Enabled" [filter #2] + // 4) "this_0_.val_b > (?)" [positional #2] + // + // => OK, parameter are in correct order: filter #1, pos #1, filter #2, pos #2 + // - // - // Query: - // {select a0_.id as id0_, a0_.val_a as val2_0_, a0_.enabled as enabled0_ - // from table_a a0_ - // where a0_.enabled = ? and ((a0_.val_a<? )and - // (exists(select b1_.val_b - // from table_b b1_ - // where b1_.enabled = ? and - // ((a0_.val_a<b1_.val_b )and(b1_.val_b>? )))))} - // - // Parameter: - // 1) "this_.enabled = :EnabledObjects.Enabled" [filter #1] - // 2) "this_.val_a < (?)" [positional #1] - // 3) "this_0_.enabled = :EnabledObjects.Enabled" [filter #2] - // 4) "this_0_.val_b > (?)" [positional #2] - // - // => OK, parameter are in correct order: filter #1, pos #1, filter #2, pos #2 - // + IList<A> result = crit.List<A>(); + Assert.AreEqual(1, result.Count); + } - IList<A> result = crit.List<A>(); - Assert.AreEqual( 1, result.Count ); - } + [Test] + public void QueryWithNamedParameters() + { + ISession session = OpenSession(); + session.EnableFilter("EnabledObjects").SetParameter("Enabled", true); - [Test] - public void QueryWithNamedParameters() - { - ISession session = OpenSession(); - session.EnableFilter( "EnabledObjects" ).SetParameter( "Enabled", true ); + var sql = new StringBuilder(); + sql.Append("from A as a where a.ValueA < :ValA"); + sql.Append(" and exists (select b.ValueB from B as b where "); + sql.Append(" a.ValueA < b.ValueB and b.ValueB > :ValB)"); - StringBuilder sql = new StringBuilder(); - sql.Append( "from A as a where a.ValueA < :ValA" ); - sql.Append( " and exists (select b.ValueB from B as b where " ); - sql.Append( " a.ValueA < b.ValueB and b.ValueB > :ValB)" ); + IQuery query = session.CreateQuery(sql.ToString()); + query.SetParameter("ValA", 6); + query.SetParameter("ValB", 5); - IQuery query = session.CreateQuery( sql.ToString() ); - query.SetParameter( "ValA", 6 ); - query.SetParameter( "ValB", 5 ); + // + // Query: + // {select a0_.id as id0_, a0_.val_a as val2_0_, a0_.enabled as enabled0_ + // from table_a a0_ + // where a0_.enabled = ? and ((a0_.val_a<? )and + // (exists(select b1_.val_b + // from table_b b1_ + // where b1_.enabled = ? and ((a0_.val_a<b1_.val_b )and(b1_.val_b>? )))))} + // + // Parameter: + // 1) "this_.enabled = :EnabledObjects.Enabled" [filter #1] + // 2) "this_.val_a < (?)" [named parameter #1] + // 3) "this_0_.enabled = :EnabledObjects.Enabled" [filter #2] + // 4) "this_0_.val_b > (?)" [named parameter #2] + // + // => ERROR, parameters are in wrong order: filter #1, filter #2, named #1, named #2 + // - // - // Query: - // {select a0_.id as id0_, a0_.val_a as val2_0_, a0_.enabled as enabled0_ - // from table_a a0_ - // where a0_.enabled = ? and ((a0_.val_a<? )and - // (exists(select b1_.val_b - // from table_b b1_ - // where b1_.enabled = ? and ((a0_.val_a<b1_.val_b )and(b1_.val_b>? )))))} - // - // Parameter: - // 1) "this_.enabled = :EnabledObjects.Enabled" [filter #1] - // 2) "this_.val_a < (?)" [named parameter #1] - // 3) "this_0_.enabled = :EnabledObjects.Enabled" [filter #2] - // 4) "this_0_.val_b > (?)" [named parameter #2] - // - // => ERROR, parameters are in wrong order: filter #1, filter #2, named #1, named #2 - // + IList<A> result = query.List<A>(); + Assert.AreEqual(1, result.Count); + } - IList<A> result = query.List<A>(); - Assert.AreEqual( 1, result.Count ); - } + [Test] + public void QueryWithPositionalParameter() + { + ISession session = OpenSession(); + session.EnableFilter("EnabledObjects").SetParameter("Enabled", true); - [Test] - public void QueryWithPositionalParameter() - { - ISession session = OpenSession(); - session.EnableFilter( "EnabledObjects" ).SetParameter( "Enabled", true ); + var sql = new StringBuilder(); + sql.Append("from A as a where a.ValueA < ?"); + sql.Append(" and exists (select b.ValueB from B as b where "); + sql.Append(" a.ValueA < b.ValueB and b.ValueB > ?)"); - StringBuilder sql = new StringBuilder(); - sql.Append( "from A as a where a.ValueA < ?" ); - sql.Append( " and exists (select b.ValueB from B as b where " ); - sql.Append( " a.ValueA < b.ValueB and b.ValueB > ?)" ); + IQuery query = session.CreateQuery(sql.ToString()); + query.SetInt32(0, 6); + query.SetInt32(1, 5); - IQuery query = session.CreateQuery( sql.ToString() ); - query.SetInt32( 0, 6 ); - query.SetInt32( 1, 5 ); + // + // Query: + // {select a0_.id as id0_, a0_.val_a as val2_0_, a0_.enabled as enabled0_ + // from table_a a0_ + // where a0_.enabled = ? and ((a0_.val_a<? )and + // (exists(select b1_.val_b + // from table_b b1_ + // where b1_.enabled = ? and ((a0_.val_a<b1_.val_b )and(b1_.val_b>? )))))} + // + // Parameter: + // 1) "this_.enabled = :EnabledObjects.Enabled" [filter #1] + // 2) "this_.val_a < (?)" [positional parameter #1] + // 3) "this_0_.enabled = :EnabledObjects.Enabled" [filter #2] + // 4) "this_0_.val_b > (?)" [positional parameter #2] + // + // => OK, parameters are in correct order: filter #1, pos 12, filter #2, pos #2 + // - // - // Query: - // {select a0_.id as id0_, a0_.val_a as val2_0_, a0_.enabled as enabled0_ - // from table_a a0_ - // where a0_.enabled = ? and ((a0_.val_a<? )and - // (exists(select b1_.val_b - // from table_b b1_ - // where b1_.enabled = ? and ((a0_.val_a<b1_.val_b )and(b1_.val_b>? )))))} - // - // Parameter: - // 1) "this_.enabled = :EnabledObjects.Enabled" [filter #1] - // 2) "this_.val_a < (?)" [positional parameter #1] - // 3) "this_0_.enabled = :EnabledObjects.Enabled" [filter #2] - // 4) "this_0_.val_b > (?)" [positional parameter #2] - // - // => OK, parameters are in correct order: filter #1, pos 12, filter #2, pos #2 - // + IList<A> result = query.List<A>(); + Assert.AreEqual(1, result.Count); + } - IList<A> result = query.List<A>(); - Assert.AreEqual( 1, result.Count ); - } + [Test] + public void QueryWithMixedParameters() + { + ISession session = OpenSession(); + session.EnableFilter("EnabledObjects").SetParameter("Enabled", true); - [Test, Ignore( "Known issue, parameter order is wrong when named and positional parameters are mixed" )] - public void QueryWithMixedParameters() - { - ISession session = OpenSession(); - session.EnableFilter( "EnabledObjects" ).SetParameter( "Enabled", true ); + var sql = new StringBuilder(); + sql.Append("from A as a where a.ValueA < :ValA"); + sql.Append(" and exists (select b.ValueB from B as b where "); + sql.Append(" a.ValueA < b.ValueB and b.ValueB > ?)"); - StringBuilder sql = new StringBuilder(); - sql.Append( "from A as a where a.ValueA < :ValA" ); - sql.Append( " and exists (select b.ValueB from B as b where " ); - sql.Append( " a.ValueA < b.ValueB and b.ValueB > ?)" ); + Assert.Throws<SemanticException>(() => session.CreateQuery(sql.ToString())); + // + // Query: + // {select a0_.id as id0_, a0_.val_a as val2_0_, a0_.enabled as enabled0_ + // from table_a a0_ + // where a0_.enabled = ? and ((a0_.val_a<? )and + // (exists(select b1_.val_b + // from table_b b1_ + // where b1_.enabled = ? and ((a0_.val_a<b1_.val_b )and(b1_.val_b>? )))))} + // + // Parameter: + // 1) "this_.enabled = :EnabledObjects.Enabled" [filter #1] + // 2) "this_.val_a < (?)" [named parameter #1] + // 3) "this_0_.enabled = :EnabledObjects.Enabled" [filter #2] + // 4) "this_0_.val_b > (?)" [positional parameter #1] + // + // => ERROR, parameters are in wrong order: filter #1, pos #1, filter #2, named #1 + // + } - IQuery query = session.CreateQuery( sql.ToString() ); - query.SetInt32( 0, 5 ); - query.SetParameter( "ValA", 6 ); + [Test] + public void QueryMapElements() + { + IQuery query = OpenSession().CreateQuery("from A a where a.C[:ValC] = :Text"); + query.SetInt32("ValC", 1); + query.SetString("Text", "Text1"); - // - // Query: - // {select a0_.id as id0_, a0_.val_a as val2_0_, a0_.enabled as enabled0_ - // from table_a a0_ - // where a0_.enabled = ? and ((a0_.val_a<? )and - // (exists(select b1_.val_b - // from table_b b1_ - // where b1_.enabled = ? and ((a0_.val_a<b1_.val_b )and(b1_.val_b>? )))))} - // - // Parameter: - // 1) "this_.enabled = :EnabledObjects.Enabled" [filter #1] - // 2) "this_.val_a < (?)" [named parameter #1] - // 3) "this_0_.enabled = :EnabledObjects.Enabled" [filter #2] - // 4) "this_0_.val_b > (?)" [positional parameter #1] - // - // => ERROR, parameters are in wrong order: filter #1, pos #1, filter #2, named #1 - // + // Query: + // {select a0_.id as id0_, a0_.val_a as val2_0_, a0_.enabled as enabled0_ + // from table_a a0_, table_c c1_ + // where (c1_.text = (?) and a0_.id=c1_.val_a and c1_.val_c = (?) ); } + // Parameter: + // 1) "c1_.text = (?)" [named parameter #2 Text] + // 2) "c1_.val_c = (?)" [named parameter #1 ValC] + // + // => ERROR, parameters are in wrong order: named ValC, named Text - IList<A> result = query.List<A>(); - Assert.AreEqual( 1, result.Count ); - } + var a = query.UniqueResult<A>(); - [Test,Ignore("Parameter order is wrong when index is used")] - public void QueryMapElements() - { - IQuery query = OpenSession().CreateQuery( "from A a where a.C[:ValC] = :Text" ); - query.SetInt32( "ValC", 1 ); - query.SetString( "Text", "Text1" ); - - // Query: - // {select a0_.id as id0_, a0_.val_a as val2_0_, a0_.enabled as enabled0_ - // from table_a a0_, table_c c1_ - // where (c1_.text = (?) and a0_.id=c1_.val_a and c1_.val_c = (?) ); } - // Parameter: - // 1) "c1_.text = (?)" [named parameter #2 Text] - // 2) "c1_.val_c = (?)" [named parameter #1 ValC] - // - // => ERROR, parameters are in wrong order: named ValC, named Text - - A a = query.UniqueResult<A>(); - - Assert.AreEqual( a.C[1], "Text1" ); - } - } -} + Assert.AreEqual(a.C[1], "Text1"); + } + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-15 01:14:14
|
Revision: 4308 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4308&view=rev Author: fabiomaulo Date: 2009-05-15 01:14:05 +0000 (Fri, 15 May 2009) Log Message: ----------- Starting some improv. for <element> enums Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnums.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/Something.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagFixture.cs 2009-05-15 01:14:05 UTC (rev 4308) @@ -0,0 +1,48 @@ +using System.Collections; +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.ElementsEnums +{ + [TestFixture] + public class IntEnumsBagFixture : TestCase + { + protected override IList Mappings + { + get { return new[] { "NHSpecificTest.ElementsEnums.SimpleWithEnums.hbm.xml" }; } + } + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + [Test] + [Description("Should load the list of enums (NH-1772)")] + public void LoadEnums() + { + object savedId; + using (ISession s = OpenSession()) + using (s.BeginTransaction()) + { + savedId = s.Save(new SimpleWithEnums { Things = new List<Something> { Something.B, Something.C, Something.D, Something.E } }); + s.Transaction.Commit(); + } + + using (ISession s = OpenSession()) + using (s.BeginTransaction()) + { + var swe = s.Get<SimpleWithEnums>(savedId); + Assert.That(swe.Things, Is.EqualTo(new[] {Something.B, Something.C, Something.D, Something.E})); + s.Transaction.Commit(); + } + + using (ISession s = OpenSession()) + using (s.BeginTransaction()) + { + s.Delete("from SimpleWithEnums"); + s.Transaction.Commit(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnums.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnums.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnums.hbm.xml 2009-05-15 01:14:05 UTC (rev 4308) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.ElementsEnums"> + + <class name="SimpleWithEnums"> + <id type="int"> + <generator class="native"/> + </id> + + <property name="Something"/> + <bag name="Things"> + <key column="bid"/> + <element type="NHibernate.Test.NHSpecificTest.ElementsEnums.Something, NHibernate.Test" column="enumvalue"/> + </bag> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/Something.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/Something.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/Something.cs 2009-05-15 01:14:05 UTC (rev 4308) @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.ElementsEnums +{ + public enum Something + { + A,B,C,D,E,F + } + + public class SimpleWithEnums + { + public virtual Something Something { get; set; } + public virtual IList<Something> Things { get; set; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 21:38:50 UTC (rev 4307) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 01:14:05 UTC (rev 4308) @@ -329,6 +329,8 @@ <Compile Include="HQL\BaseFunctionFixture.cs" /> <Compile Include="MappingTest\NonReflectiveBinderFixture.cs" /> <Compile Include="MappingTest\Wicked.cs" /> + <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" /> + <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" /> <Compile Include="NHSpecificTest\NH1574\Principal.cs" /> <Compile Include="NHSpecificTest\NH1574\SpecializedPrincipal.cs" /> <Compile Include="NHSpecificTest\NH1574\SpecializedTeaml.cs" /> @@ -1782,6 +1784,7 @@ <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\ElementsEnums\SimpleWithEnums.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1574\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1776\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1773\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-14 21:39:07
|
Revision: 4307 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4307&view=rev Author: fabiomaulo Date: 2009-05-14 21:38:50 +0000 (Thu, 14 May 2009) Log Message: ----------- Applied NH-1726 Modified Paths: -------------- trunk/nhibernate/releasenotes.txt Modified: trunk/nhibernate/releasenotes.txt =================================================================== --- trunk/nhibernate/releasenotes.txt 2009-05-14 21:35:00 UTC (rev 4306) +++ trunk/nhibernate/releasenotes.txt 2009-05-14 21:38:50 UTC (rev 4307) @@ -25,7 +25,8 @@ * see NH-1633 if you are using SQL native queries * CriteriaUtil is gone. NHibernate.Transform.Transformers now returns predefined IResultTransformer. * Now filters are working even with many-to-one association for Criteria and HQL (NH-1293, NH-1179) - + * ISessionFactory.Settings is gone (moved to ISessionFactoryImplementor.Settings) + Build 2.1.0.Alpha2 (rev4167) ======================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-14 21:35:15
|
Revision: 4306 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4306&view=rev Author: fabiomaulo Date: 2009-05-14 21:35:00 +0000 (Thu, 14 May 2009) Log Message: ----------- The user said that is a valid test... it not fail on trunk. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Principal.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedPrincipal.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedTeaml.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/StatelessTest.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Team.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Mappings.hbm.xml 2009-05-14 21:35:00 UTC (rev 4306) @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1574"> + + <class name="SpecializedTeamStorage" + table="TeamStorage" + discriminator-value="-1963354017"> + <id name="Id" type="Int32" column="TeamStorageID"> + <generator class="hilo"> + <param name="table">HiLoGenerator</param> + <param name="column">NextValue</param> + <param name="max_lo">100</param> + </generator> + </id> + <property name="Name" column="Name" type="String" length="450" /> + <property name="EloRanking" column="EloRanking" type="Int32" /> + <property name="MaxElo" column="MaxElo" type="Int32" /> + <property name="MinElo" column="MinElo" type="Int32" /> + <property name="CreationDate" column="CreationDate" type="DateTime" /> + <property name="NumberPlayedBattles" column="NumberPlayedBattles" type="Int32" /> + <property name="LadderActive" column="LadderActive" type="Boolean" /> + <property name="LadderPosition" column="LadderPosition" type="Int32" /> + <property name="IsInBattle" column="IsInBattle" type="Int32" /> + <property name="RestUntil" column="RestUntil" type="Int32" /> + <property name="StoppedUntil" column="StoppedUntil" type="Int32" /> + <bag name="Principals" inverse="true" lazy="true"> + <key column="TeamID" /> + <one-to-many class="SpecializedPrincipal" /> + </bag> + </class> + + <class name="SpecializedPrincipal" + table="Principal" + discriminator-value="-2035371692"> + <id name="Id" type="Int32" column="PrincipalID"> + <generator class="hilo"> + <param name="table">HiLoGenerator</param> + <param name="column">NextValue</param> + <param name="max_lo">100</param> + </generator> + </id> + <property name="IsBot" column="IsBot" type="Boolean" /> + <property name="MyStatsId" column="MyStatsId" type="Int32" /> + <property name="EloRanking" column="EloRanking" type="Int32" /> + <property name="ReceiveMail" column="ReceiveMail" type="Boolean" /> + <property name="Credits" column="Credits" type="Int32" /> + <property name="LadderActive" column="LadderActive" type="Boolean" /> + <property name="LadderPosition" column="LadderPosition" type="Int32" /> + <property name="IsInBattle" column="IsInBattle" type="Int32" /> + <property name="RestUntil" column="RestUntil" type="Int32" /> + <property name="StoppedUntil" column="StoppedUntil" type="Int32" /> + <property name="AvailableVacationTicks" column="AvailableVacationTicks" type="Int32" /> + <property name="VacationStartTick" column="VacationStartTick" type="Int32" /> + <property name="VacationEndtick" column="VacationEndtick" type="Int32" /> + <property name="AutoStartVacations" column="AutoStartVacations" type="Boolean" /> + + <many-to-one name="Team" column="TeamID" not-null="false" /> + + <property name="Name" column="Name" type="String" length="200" /> + <property name="Password" column="Password" type="String" length="50" /> + <property name="Email" column="Email" type="String" length="200" /> + <property name="Ip" column="Ip" type="String" length="15" /> + <property name="RegistDate" column="RegistDate" type="DateTime" /> + <property name="LastLogin" column="LastLogin" type="DateTime" /> + <property name="Approved" column="Approved" type="Boolean" /> + <property name="IsOnline" column="IsOnline" type="Boolean" /> + <property name="Locked" column="Locked" type="Boolean" /> + <property name="Locale" column="Locale" type="String" length="6" /> + <property name="ConfirmationCode" column="ConfirmationCode" type="String" length="100" /> + <property name="RawRoles" column="RawRoles" type="String" length="250" /> + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Principal.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Principal.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Principal.cs 2009-05-14 21:35:00 UTC (rev 4306) @@ -0,0 +1,283 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1574 +{ + public class Principal + { + private bool approved; + private bool autoStartVacations; + private int availableVacationTicks; + private string confirmationCode; + private int credits; + private int eloRanking; + private string email; + private string ip; + private bool isBot; + private int isInBattle; + private bool isOnline; + private bool ladderActive; + private int ladderPosition; + private DateTime lastLogin = DateTime.Now; + private string locale; + private bool locked; + private int myStatsId; + private string name; + private string password; + private string rawRoles; + private bool receiveMail; + private DateTime registDate = DateTime.Now; + private int restUntil; + private int stoppedUntil; + private int vacationEndtick; + private int vacationStartTick; + + private int id; + private SpecializedTeamStorage team; + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + /// <summary> + /// Gets the Principal's IsBot + /// </summary> + public virtual bool IsBot + { + set { isBot = value; } + get { return isBot; } + } + + /// <summary> + /// Gets the Principal's MyStatsId + /// </summary> + public virtual int MyStatsId + { + set { myStatsId = value; } + get { return myStatsId; } + } + + /// <summary> + /// Gets the Principal's EloRanking + /// </summary> + public virtual int EloRanking + { + set { eloRanking = value; } + get { return eloRanking; } + } + + /// <summary> + /// Gets the Principal's ReceiveMail + /// </summary> + public virtual bool ReceiveMail + { + set { receiveMail = value; } + get { return receiveMail; } + } + + /// <summary> + /// Gets the Principal's Credits + /// </summary> + public virtual int Credits + { + set { credits = value; } + get { return credits; } + } + + /// <summary> + /// Gets the Principal's LadderActive + /// </summary> + public virtual bool LadderActive + { + set { ladderActive = value; } + get { return ladderActive; } + } + + /// <summary> + /// Gets the Principal's LadderPosition + /// </summary> + public virtual int LadderPosition + { + set { ladderPosition = value; } + get { return ladderPosition; } + } + + /// <summary> + /// Gets the Principal's IsInBattle + /// </summary> + public virtual int IsInBattle + { + set { isInBattle = value; } + get { return isInBattle; } + } + + /// <summary> + /// Gets the Principal's RestUntil + /// </summary> + public virtual int RestUntil + { + set { restUntil = value; } + get { return restUntil; } + } + + /// <summary> + /// Gets the Principal's StoppedUntil + /// </summary> + public virtual int StoppedUntil + { + set { stoppedUntil = value; } + get { return stoppedUntil; } + } + + /// <summary> + /// Gets the Principal's AvailableVacationTicks + /// </summary> + public virtual int AvailableVacationTicks + { + set { availableVacationTicks = value; } + get { return availableVacationTicks; } + } + + /// <summary> + /// Gets the Principal's VacationStartTick + /// </summary> + public virtual int VacationStartTick + { + set { vacationStartTick = value; } + get { return vacationStartTick; } + } + + /// <summary> + /// Gets the Principal's VacationEndtick + /// </summary> + public virtual int VacationEndtick + { + set { vacationEndtick = value; } + get { return vacationEndtick; } + } + + /// <summary> + /// Gets the Principal's AutoStartVacations + /// </summary> + public virtual bool AutoStartVacations + { + set { autoStartVacations = value; } + get { return autoStartVacations; } + } + + /// <summary> + /// Gets the Principal's Name + /// </summary> + public virtual string Name + { + set { name = value; } + get { return name; } + } + + /// <summary> + /// Gets the Principal's Password + /// </summary> + public virtual string Password + { + set { password = value; } + get { return password; } + } + + /// <summary> + /// Gets the Principal's Email + /// </summary> + public virtual string Email + { + set { email = value; } + get { return email; } + } + + /// <summary> + /// Gets the Principal's Ip + /// </summary> + public virtual string Ip + { + set { ip = value; } + get { return ip; } + } + + /// <summary> + /// Gets the Principal's RegistDate + /// </summary> + public virtual DateTime RegistDate + { + set { registDate = value; } + get { return registDate; } + } + + /// <summary> + /// Gets the Principal's LastLogin + /// </summary> + public virtual DateTime LastLogin + { + set { lastLogin = value; } + get { return lastLogin; } + } + + /// <summary> + /// Gets the Principal's Approved + /// </summary> + public virtual bool Approved + { + set { approved = value; } + get { return approved; } + } + + /// <summary> + /// Gets the Principal's IsOnline + /// </summary> + public virtual bool IsOnline + { + set { isOnline = value; } + get { return isOnline; } + } + + /// <summary> + /// Gets the Principal's Locked + /// </summary> + public virtual bool Locked + { + set { locked = value; } + get { return locked; } + } + + /// <summary> + /// Gets the Principal's Locale + /// </summary> + public virtual string Locale + { + set { locale = value; } + get { return locale; } + } + + /// <summary> + /// Gets the Principal's ConfirmationCode + /// </summary> + public virtual string ConfirmationCode + { + set { confirmationCode = value; } + get { return confirmationCode; } + } + + /// <summary> + /// Gets the Principal's RawRoles + /// </summary> + public virtual string RawRoles + { + set { rawRoles = value; } + get { return rawRoles; } + } + + public virtual SpecializedTeamStorage Team + { + get { return team; } + set { team = value; } + } + } ; +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedPrincipal.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedPrincipal.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedPrincipal.cs 2009-05-14 21:35:00 UTC (rev 4306) @@ -0,0 +1,4 @@ +namespace NHibernate.Test.NHSpecificTest.NH1574 +{ + public class SpecializedPrincipal : Principal {} ; +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedTeaml.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedTeaml.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedTeaml.cs 2009-05-14 21:35:00 UTC (rev 4306) @@ -0,0 +1,4 @@ +namespace NHibernate.Test.NHSpecificTest.NH1574 +{ + public class SpecializedTeamStorage : TeamStorage {} ; +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/StatelessTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/StatelessTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/StatelessTest.cs 2009-05-14 21:35:00 UTC (rev 4306) @@ -0,0 +1,46 @@ +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1574 +{ + [TestFixture] + public class StatelessTest : BugTestCase + { + [Test] + public void StatelessManyToOne() + { + using (ISession session = OpenSession()) + { + var principal = new SpecializedPrincipal(); + var team = new SpecializedTeamStorage(); + principal.Team = team; + session.SaveOrUpdate(team); + session.SaveOrUpdate(principal); + session.Flush(); + } + + using (IStatelessSession session = sessions.OpenStatelessSession()) + { + IQuery query = session.CreateQuery("from SpecializedPrincipal p"); + IList<Principal> principals = query.List<Principal>(); + Assert.AreEqual(1, principals.Count); + + ITransaction trans = session.BeginTransaction(); + foreach (var principal in principals) + { + principal.Name = "Buu"; + session.Update(principal); + } + trans.Commit(); + } + + // cleanup + using (ISession session = OpenSession()) + { + session.Delete("from SpecializedTeamStorage"); + session.Delete("from SpecializedPrincipal"); + session.Flush(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Team.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Team.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Team.cs 2009-05-14 21:35:00 UTC (rev 4306) @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1574 +{ + public class TeamStorage + { + private DateTime creationDate = DateTime.Now; + private int eloRanking; + private int isInBattle; + private bool ladderActive; + private int ladderPosition; + private int maxElo; + private int minElo; + private string name; + private int numberPlayedBattles; + private int restUntil; + private int stoppedUntil; + + private int id; + private IList<Principal> principals; + + /// <summary> + /// Gets the TeamStorage's Name + /// </summary> + public virtual string Name + { + set { name = value; } + get { return name; } + } + + /// <summary> + /// Gets the TeamStorage's EloRanking + /// </summary> + public virtual int EloRanking + { + set { eloRanking = value; } + get { return eloRanking; } + } + + /// <summary> + /// Gets the TeamStorage's MaxElo + /// </summary> + public virtual int MaxElo + { + set { maxElo = value; } + get { return maxElo; } + } + + /// <summary> + /// Gets the TeamStorage's MinElo + /// </summary> + public virtual int MinElo + { + set { minElo = value; } + get { return minElo; } + } + + /// <summary> + /// Gets the TeamStorage's CreationDate + /// </summary> + public virtual DateTime CreationDate + { + set { creationDate = value; } + get { return creationDate; } + } + + /// <summary> + /// Gets the TeamStorage's NumberPlayedBattles + /// </summary> + public virtual int NumberPlayedBattles + { + set { numberPlayedBattles = value; } + get { return numberPlayedBattles; } + } + + /// <summary> + /// Gets the TeamStorage's LadderActive + /// </summary> + public virtual bool LadderActive + { + set { ladderActive = value; } + get { return ladderActive; } + } + + /// <summary> + /// Gets the TeamStorage's LadderPosition + /// </summary> + public virtual int LadderPosition + { + set { ladderPosition = value; } + get { return ladderPosition; } + } + + /// <summary> + /// Gets the TeamStorage's IsInBattle + /// </summary> + public virtual int IsInBattle + { + set { isInBattle = value; } + get { return isInBattle; } + } + + /// <summary> + /// Gets the TeamStorage's RestUntil + /// </summary> + public virtual int RestUntil + { + set { restUntil = value; } + get { return restUntil; } + } + + /// <summary> + /// Gets the TeamStorage's StoppedUntil + /// </summary> + public virtual int StoppedUntil + { + set { stoppedUntil = value; } + get { return stoppedUntil; } + } + + public virtual IList<Principal> Principals + { + get { return principals; } + set { principals = value; } + } + + public virtual int Id + { + get { return id; } + set { id = value; } + } + } ; +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 21:10:28 UTC (rev 4305) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 21:35:00 UTC (rev 4306) @@ -329,6 +329,11 @@ <Compile Include="HQL\BaseFunctionFixture.cs" /> <Compile Include="MappingTest\NonReflectiveBinderFixture.cs" /> <Compile Include="MappingTest\Wicked.cs" /> + <Compile Include="NHSpecificTest\NH1574\Principal.cs" /> + <Compile Include="NHSpecificTest\NH1574\SpecializedPrincipal.cs" /> + <Compile Include="NHSpecificTest\NH1574\SpecializedTeaml.cs" /> + <Compile Include="NHSpecificTest\NH1574\StatelessTest.cs" /> + <Compile Include="NHSpecificTest\NH1574\Team.cs" /> <Compile Include="NHSpecificTest\Dates\TimeFixture.cs" /> <Compile Include="NHSpecificTest\DtcFailures\DtcFailuresFixture.cs" /> <Compile Include="NHSpecificTest\DtcFailures\Person.cs" /> @@ -1777,6 +1782,7 @@ <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1574\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1776\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1773\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1760\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-14 21:10:43
|
Revision: 4305 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4305&view=rev Author: fabiomaulo Date: 2009-05-14 21:10:28 +0000 (Thu, 14 May 2009) Log Message: ----------- Applied patch NH-1777 (by Roger) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs trunk/nhibernate/src/NHibernate/Criterion/Example.cs trunk/nhibernate/src/NHibernate/Engine/Cascade.cs trunk/nhibernate/src/NHibernate/Engine/ExecuteUpdateResultCheckStyle.cs trunk/nhibernate/src/NHibernate/Engine/StatefulPersistenceContext.cs trunk/nhibernate/src/NHibernate/Engine/UnsavedValueFactory.cs trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryReturnProcessor.cs trunk/nhibernate/src/NHibernate/Loader/Loader.cs trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs Modified: trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -34,9 +34,11 @@ public override bool Equals(object other) { - if (!(other is FilterKey)) + var that = other as FilterKey; + if (that == null) + { return false; - FilterKey that = (FilterKey) other; + } if (!that.filterName.Equals(filterName)) return false; if (!CollectionHelper.DictionaryEquals<string, TypedValue>(that.filterParameters, filterParameters)) Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -665,9 +665,9 @@ value.SetTypeUsingReflection(className, propertyName, PropertyAccess(subnode)); // This is done here 'cos we might only know the type here (ugly!) - if (value is ToOne) + var toOne = value as ToOne; + if (toOne != null) { - ToOne toOne = (ToOne) value; string propertyRef = toOne.ReferencedPropertyName; if (propertyRef != null) mappings.AddUniquePropertyReference(toOne.ReferencedEntityName, propertyRef); Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -236,25 +236,25 @@ model.SqlType = null; } - private Mapping.Property CreateProperty(ToOne value, string propertyName, System.Type parentClass, + private Property CreateProperty(ToOne value, string propertyName, System.Type parentClass, HbmKeyManyToOne keyManyToOneSchema) { if (parentClass != null && value.IsSimpleValue) - value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName, keyManyToOneSchema.access ?? mappings.DefaultAccess); + value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName, + keyManyToOneSchema.access ?? mappings.DefaultAccess); string propertyRef = value.ReferencedPropertyName; if (propertyRef != null) mappings.AddUniquePropertyReference(value.ReferencedEntityName, propertyRef); value.CreateForeignKey(); - Mapping.Property prop = new Mapping.Property(); - prop.Value = value; + var prop = new Property {Value = value}; BindProperty(keyManyToOneSchema, prop); return prop; } - private void BindProperty(HbmKeyManyToOne keyManyToOneSchema, Mapping.Property property) + private void BindProperty(HbmKeyManyToOne keyManyToOneSchema, Property property) { property.Name = keyManyToOneSchema.name; @@ -343,30 +343,30 @@ model.SqlType = null; } - private Mapping.Property CreateProperty(SimpleValue value, string propertyName, System.Type parentClass, + private Property CreateProperty(SimpleValue value, string propertyName, System.Type parentClass, HbmKeyProperty keyPropertySchema) { if (parentClass != null && value.IsSimpleValue) - value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName, keyPropertySchema.access ?? mappings.DefaultAccess); + value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName, + keyPropertySchema.access ?? mappings.DefaultAccess); // This is done here 'cos we might only know the type here (ugly!) - if (value is ToOne) + var toOne = value as ToOne; + if (toOne != null) { - ToOne toOne = (ToOne) value; string propertyRef = toOne.ReferencedPropertyName; if (propertyRef != null) mappings.AddUniquePropertyReference(toOne.ReferencedEntityName, propertyRef); } value.CreateForeignKey(); - Mapping.Property prop = new Mapping.Property(); - prop.Value = value; + var prop = new Property {Value = value}; BindProperty(keyPropertySchema, prop); return prop; } - private void BindProperty(HbmKeyProperty keyPropertySchema, Mapping.Property property) + private void BindProperty(HbmKeyProperty keyPropertySchema, Property property) { property.Name = keyPropertySchema.name; Modified: trunk/nhibernate/src/NHibernate/Criterion/Example.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Criterion/Example.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Criterion/Example.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -417,9 +417,9 @@ // parameter passed in. if (value != null) { - if (value is string) + var stringValue = value as string; + if (stringValue != null) { - string stringValue = (string) value; if (_isIgnoreCaseEnabled) { stringValue = stringValue.ToLower(); @@ -430,7 +430,8 @@ } value = stringValue; } - list.Add(new TypedValue(type, value, EntityMode.Poco)); // TODO NH Different behavior: In H3.2 EntityMode is nullable + list.Add(new TypedValue(type, value, EntityMode.Poco)); + // TODO NH Different behavior: In H3.2 EntityMode is nullable } } Modified: trunk/nhibernate/src/NHibernate/Engine/Cascade.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/Cascade.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Engine/Cascade.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -218,9 +218,11 @@ private void CascadeCollectionElements(object child, CollectionType collectionType, CascadeStyle style, IType elemType, object anything, bool isCascadeDeleteEnabled) { // we can't cascade to non-embedded elements - bool embeddedElements = eventSource.EntityMode != EntityMode.Xml || ((EntityType)collectionType.GetElementType(eventSource.Factory)).IsEmbeddedInXML; + bool embeddedElements = eventSource.EntityMode != EntityMode.Xml + || ((EntityType) collectionType.GetElementType(eventSource.Factory)).IsEmbeddedInXML; - bool reallyDoCascade = style.ReallyDoCascade(action) && embeddedElements && child != CollectionType.UnfetchedCollection; + bool reallyDoCascade = style.ReallyDoCascade(action) && embeddedElements + && child != CollectionType.UnfetchedCollection; if (reallyDoCascade) { @@ -232,8 +234,9 @@ log.Info("done cascade " + action + " for collection: " + collectionType.Role); } - bool deleteOrphans = style.HasOrphanDelete && action.DeleteOrphans && - elemType.IsEntityType && child is IPersistentCollection; //a newly instantiated collection can't have orphans + var childAsPersColl = child as IPersistentCollection; + bool deleteOrphans = style.HasOrphanDelete && action.DeleteOrphans && elemType.IsEntityType + && childAsPersColl != null; //a newly instantiated collection can't have orphans if (deleteOrphans) { @@ -244,7 +247,7 @@ // 1. newly instantiated collections // 2. arrays (we can't track orphans for detached arrays) string entityName = collectionType.GetAssociatedEntityName(eventSource.Factory); - DeleteOrphans(entityName, (IPersistentCollection)child); + DeleteOrphans(entityName, childAsPersColl); log.Info("done deleting orphans for collection: " + collectionType.Role); } Modified: trunk/nhibernate/src/NHibernate/Engine/ExecuteUpdateResultCheckStyle.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/ExecuteUpdateResultCheckStyle.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Engine/ExecuteUpdateResultCheckStyle.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -1,6 +1,5 @@ using System; using NHibernate.SqlCommand; -using System.Runtime.Serialization; namespace NHibernate.Engine { @@ -39,12 +38,14 @@ public override bool Equals(object obj) { - if (obj is ExecuteUpdateResultCheckStyle) + var castedObj = obj as ExecuteUpdateResultCheckStyle; + if (castedObj != null) { - return this.name == ((ExecuteUpdateResultCheckStyle) obj).name; + return name == castedObj.name; } return false; } + public override int GetHashCode() { return name.GetHashCode(); Modified: trunk/nhibernate/src/NHibernate/Engine/StatefulPersistenceContext.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/StatefulPersistenceContext.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Engine/StatefulPersistenceContext.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -572,14 +572,13 @@ //{ // value = wrapper.Element; //} - - if (value is INHibernateProxy) + var proxy = value as INHibernateProxy; + if (proxy != null) { if (log.IsDebugEnabled) { log.Debug("setting proxy identifier: " + id); } - INHibernateProxy proxy = (INHibernateProxy)value; ILazyInitializer li = proxy.HibernateLazyInitializer; li.Identifier = id; ReassociateProxy(li, proxy); @@ -648,18 +647,14 @@ //{ // maybeProxy = wrapper.Element; //} - - if (maybeProxy is INHibernateProxy) + var proxy = maybeProxy as INHibernateProxy; + if (proxy != null) { - INHibernateProxy proxy = (INHibernateProxy)maybeProxy; ILazyInitializer li = proxy.HibernateLazyInitializer; ReassociateProxy(li, proxy); return li.GetImplementation(); //initialize + unwrap the object } - else - { - return maybeProxy; - } + return maybeProxy; } /// <summary> Modified: trunk/nhibernate/src/NHibernate/Engine/UnsavedValueFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/UnsavedValueFactory.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Engine/UnsavedValueFactory.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -11,7 +11,7 @@ { } - private static object[] NoParameters = new object[0]; + private static readonly object[] NoParameters = new object[0]; private static object Instantiate(ConstructorInfo constructor) { @@ -45,47 +45,42 @@ object defaultValue = identifierGetter.Get(Instantiate(constructor)); return new IdentifierValue(defaultValue); } - else if (identifierGetter != null && (identifierType is PrimitiveType)) + var idTypeAsPrimitiveType = identifierType as PrimitiveType; + if (identifierGetter != null && idTypeAsPrimitiveType != null) { - object defaultValue = ((PrimitiveType) identifierType).DefaultValue; + object defaultValue = idTypeAsPrimitiveType.DefaultValue; return new IdentifierValue(defaultValue); } - else - { - return IdentifierValue.SaveNull; - } + return IdentifierValue.SaveNull; } - else if ("null" == unsavedValue) + if ("null" == unsavedValue) { return IdentifierValue.SaveNull; } - else if( "undefined" == unsavedValue ) + if ("undefined" == unsavedValue) { return IdentifierValue.Undefined; } - else if ("none" == unsavedValue) + if ("none" == unsavedValue) { return IdentifierValue.SaveNone; } - else if ("any" == unsavedValue) + if ("any" == unsavedValue) { return IdentifierValue.SaveAny; } - else + try { - try - { - return new IdentifierValue(((IIdentifierType) identifierType).StringToObject(unsavedValue)); - } - catch (InvalidCastException cce) - { - throw new MappingException("Bad identifier type: " + identifierType.Name, cce); - } - catch (Exception e) - { - throw new MappingException("Could not parse identifier unsaved-value: " + unsavedValue, e); - } + return new IdentifierValue(((IIdentifierType) identifierType).StringToObject(unsavedValue)); } + catch (InvalidCastException cce) + { + throw new MappingException("Bad identifier type: " + identifierType.Name, cce); + } + catch (Exception e) + { + throw new MappingException("Could not parse identifier unsaved-value: " + unsavedValue, e); + } } public static VersionValue GetUnsavedVersionValue( Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -169,7 +169,8 @@ private object ReturnNarrowedProxy(LoadEvent @event, IEntityPersister persister, EntityKey keyToLoad, LoadType options, IPersistenceContext persistenceContext, object proxy) { log.Debug("entity proxy found in session cache"); - ILazyInitializer li = ((INHibernateProxy)proxy).HibernateLazyInitializer; + var castedProxy = (INHibernateProxy) proxy; + ILazyInitializer li = castedProxy.HibernateLazyInitializer; if (li.Unwrap) { return li.GetImplementation(); @@ -189,7 +190,7 @@ // NH Different behavior : NH-1252 return null; } - return persistenceContext.NarrowProxy((INHibernateProxy)proxy, persister, keyToLoad, impl); + return persistenceContext.NarrowProxy(castedProxy, persister, keyToLoad, impl); } /// <summary> Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -423,9 +423,10 @@ { throw new ArgumentNullException("obj", "null object passed to GetCurrentLockMode"); } - if (obj is INHibernateProxy) + var proxy = obj as INHibernateProxy; + if (proxy != null) { - obj = ((INHibernateProxy)obj).HibernateLazyInitializer.GetImplementation(this); + obj = proxy.HibernateLazyInitializer.GetImplementation(this); if (obj == null) { return LockMode.None; @@ -1288,14 +1289,14 @@ using (new SessionIdLoggingContext(sessionId)) { CheckAndUpdateSessionStatus(); - INHibernateProxy proxy = obj as INHibernateProxy; + var proxy = obj as INHibernateProxy; if (proxy != null) { if (!persistenceContext.ContainsProxy(proxy)) { throw new TransientObjectException("proxy was not associated with the session"); } - ILazyInitializer li = ((INHibernateProxy)obj).HibernateLazyInitializer; + ILazyInitializer li = proxy.HibernateLazyInitializer; obj = li.GetImplementation(); } @@ -1513,25 +1514,23 @@ // Actually the case for proxies will probably work even with // the session closed, but do the check here anyway, so that // the behavior is uniform. - - if (obj is INHibernateProxy) + var proxy = obj as INHibernateProxy; + if (proxy != null) { - ILazyInitializer li = ((INHibernateProxy)obj).HibernateLazyInitializer; + ILazyInitializer li = proxy.HibernateLazyInitializer; if (li.Session != this) { throw new TransientObjectException("The proxy was not associated with this session"); } return li.Identifier; } - else + + EntityEntry entry = persistenceContext.GetEntry(obj); + if (entry == null) { - EntityEntry entry = persistenceContext.GetEntry(obj); - if (entry == null) - { - throw new TransientObjectException("the instance was not associated with this session"); - } - return entry.Id; + throw new TransientObjectException("the instance was not associated with this session"); } + return entry.Id; } } @@ -1940,12 +1939,12 @@ { using (new SessionIdLoggingContext(sessionId)) { - IEntityPersister persister = Factory.GetEntityPersister(entityName); - if (!(persister is IOuterJoinLoadable)) + var persister = Factory.GetEntityPersister(entityName) as IOuterJoinLoadable; + if (persister == null) { throw new MappingException("class persister is not OuterJoinLoadable: " + entityName); } - return (IOuterJoinLoadable)persister; + return persister; } } @@ -1954,13 +1953,13 @@ using (new SessionIdLoggingContext(sessionId)) { CheckAndUpdateSessionStatus(); - - if (obj is INHibernateProxy) + var proxy = obj as INHibernateProxy; + if (proxy != null) { //do not use proxiesByKey, since not all //proxies that point to this session's //instances are in that collection! - ILazyInitializer li = ((INHibernateProxy)obj).HibernateLazyInitializer; + ILazyInitializer li = proxy.HibernateLazyInitializer; if (li.IsUninitialized) { //if it is an uninitialized proxy, pointing Modified: trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryReturnProcessor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryReturnProcessor.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryReturnProcessor.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -149,11 +149,12 @@ private ISqlLoadable GetSQLLoadable(string entityName) { IEntityPersister persister = factory.GetEntityPersister(entityName); - if (!(persister is ISqlLoadable)) + var persisterAsSqlLoadable = persister as ISqlLoadable; + if (persisterAsSqlLoadable == null) { throw new MappingException("class persister is not ISqlLoadable: " + entityName); } - return (ISqlLoadable) persister; + return persisterAsSqlLoadable; } private string GenerateEntitySuffix() Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -565,8 +565,9 @@ PostLoadEvent post; if (session.IsEventSource) { - pre = new PreLoadEvent((IEventSource) session); - post = new PostLoadEvent((IEventSource) session); + var eventSourceSession = (IEventSource) session; + pre = new PreLoadEvent(eventSourceSession); + post = new PostLoadEvent(eventSourceSession); } else { Modified: trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs 2009-05-14 17:40:11 UTC (rev 4304) +++ trunk/nhibernate/src/NHibernate/Util/ArrayHelper.cs 2009-05-14 21:10:28 UTC (rev 4305) @@ -156,23 +156,24 @@ public static string[][] To2DStringArray(ICollection coll) { - string[][] result = new string[ coll.Count ][]; + var result = new string[ coll.Count ][]; int i = 0; foreach (object row in coll) { - if (row is ICollection) + var rowAsCollection = row as ICollection; + if (rowAsCollection != null) { - result[i] = new string[((ICollection)row).Count]; + result[i] = new string[rowAsCollection.Count]; int j = 0; - foreach (object cell in (ICollection)row) + foreach (object cell in rowAsCollection) { - result[i][j++] = cell == null ? null : (string)cell; + result[i][j++] = cell == null ? null : (string) cell; } } else { result[i] = new string[1]; - result[i][0] = row == null ? null : (string)row; + result[i][0] = row == null ? null : (string) row; } i++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-14 17:40:20
|
Revision: 4304 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4304&view=rev Author: fabiomaulo Date: 2009-05-14 17:40:11 +0000 (Thu, 14 May 2009) Log Message: ----------- Fix NH-1776 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-05-14 16:26:47 UTC (rev 4303) +++ trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-05-14 17:40:11 UTC (rev 4304) @@ -77,7 +77,7 @@ { if (entry.SqlLocations[index] >= existingParameterLocation) { - entry.SqlLocations[index]++; + entry.IncrementLocation(index); } } } @@ -138,30 +138,36 @@ } } + [Serializable] public class ParameterInfo { - private readonly int[] _sqlLocations; - private readonly IType _expectedType; + private readonly int[] originalLocation; + private readonly int[] sqlLocations; public ParameterInfo(int[] sqlPositions, IType expectedType) { - _sqlLocations = sqlPositions; - _expectedType = expectedType; + originalLocation = (int[])sqlPositions.Clone(); + sqlLocations = sqlPositions; + ExpectedType = expectedType; } - public ParameterInfo(int sqlPosition, IType expectedType) { - _sqlLocations = new int[] { sqlPosition }; - _expectedType = expectedType; + public ParameterInfo(int sqlPosition, IType expectedType) + { + originalLocation = new[] { sqlPosition }; + sqlLocations = new[] { sqlPosition }; + ExpectedType = expectedType; } public int[] SqlLocations { - get { return _sqlLocations; } + get { return sqlLocations; } } - public IType ExpectedType + public IType ExpectedType { get; private set; } + + public void IncrementLocation(int index) { - get { return _expectedType; } + sqlLocations[index] = originalLocation[index] + 1; } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs 2009-05-14 16:26:47 UTC (rev 4303) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs 2009-05-14 17:40:11 UTC (rev 4304) @@ -3,34 +3,42 @@ namespace NHibernate.Test.NHSpecificTest.NH1776 { - [TestFixture, Ignore("Not fixed yet.")] + [TestFixture] public class FilterQueryTwiceFixture : BugTestCase { + // Note : in this test what is really important is the usage of the same HQL + // because QueryPlan + [Test] [Description("Can Query using Session's filter Twice")] public void Bug() { + var c = new Category { Code = "2600", Deleted = false }; + SaveCategory(c); + + // exec queries, twice, different session + ExecQuery(); + ExecQuery(); + + // cleanup using filter using (ISession s = OpenSession()) { using (ITransaction tx = s.BeginTransaction()) { - var c = new Category {Code = "2600", Deleted = false}; - s.SaveOrUpdate(c); + s.EnableFilter("state").SetParameter("deleted", false); + s.Delete("from Category"); tx.Commit(); } } + } - // exec queries, twice, different session - ExecQuery(); - ExecQuery(); - - // cleanup + private void SaveCategory(Category c) + { using (ISession s = OpenSession()) { using (ITransaction tx = s.BeginTransaction()) { - s.EnableFilter("state").SetParameter("deleted", false); - s.Delete("from Category"); + s.Save(c); tx.Commit(); } } @@ -48,5 +56,93 @@ Assert.That(result.Count > 0); } } + + [Test] + [Description("Executing same query with and without filter and with different filter parameter value.")] + public void FilterOnOffOn() + { + var c = new Category { Code = "2600", Deleted = true }; + SaveCategory(c); + + using (ISession s = OpenSession()) + { + s.EnableFilter("state").SetParameter("deleted", false); + + IList<Category> result = + s.CreateQuery("from Category where Code = :code").SetParameter("code", "2600").List<Category>(); + + Assert.That(result.Count == 0); + } + + using (ISession s = OpenSession()) + { + IList<Category> result = + s.CreateQuery("from Category where Code = :code").SetParameter("code", "2600").List<Category>(); + + Assert.That(result.Count > 0); + } + + using (ISession s = OpenSession()) + { + s.EnableFilter("state").SetParameter("deleted", true); + + IList<Category> result = + s.CreateQuery("from Category where Code = :code").SetParameter("code", "2600").List<Category>(); + + Assert.That(result.Count > 0); + } + + Cleanup(); + } + + private void Cleanup() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.CreateQuery("delete from Category").ExecuteUpdate(); + tx.Commit(); + } + } + + [Test] + [Description("Executing same query with different filters combinations.")] + public void MultiFilterOnOffOn() + { + var c = new Category { Code = "2600", Deleted = true }; + SaveCategory(c); + + using (ISession s = OpenSession()) + { + s.EnableFilter("state").SetParameter("deleted", false); + + IList<Category> result = + s.CreateQuery("from Category where Code = :code").SetParameter("code", "2600").List<Category>(); + + Assert.That(result.Count == 0); + } + + using (ISession s = OpenSession()) + { + s.EnableFilter("state").SetParameter("deleted", true); + s.EnableFilter("CodeLike").SetParameter("codepattern", "2%"); + + IList<Category> result = + s.CreateQuery("from Category where Code = :code").SetParameter("code", "NotExists").List<Category>(); + + Assert.That(result.Count == 0); + } + + using (ISession s = OpenSession()) + { + s.EnableFilter("CodeLike").SetParameter("codepattern", "2%"); + + IList<Category> result = + s.CreateQuery("from Category where Code = :code").SetParameter("code", "2600").List<Category>(); + + Assert.That(result.Count > 0); + } + Cleanup(); + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml 2009-05-14 16:26:47 UTC (rev 4303) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml 2009-05-14 17:40:11 UTC (rev 4304) @@ -10,10 +10,15 @@ <property name="Code"/> <property name="Deleted"/> <filter name="state" condition=":deleted = Deleted"/> + <filter name="CodeLike" condition="Code like :codepattern"/> </class> <filter-def name="state" condition=":deleted = Deleted"> <filter-param name="deleted" type="Boolean"/> </filter-def> + + <filter-def name="CodeLike"> + <filter-param name="codepattern" type="string"/> + </filter-def> </hibernate-mapping> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-14 16:26:51
|
Revision: 4303 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4303&view=rev Author: fabiomaulo Date: 2009-05-14 16:26:47 +0000 (Thu, 14 May 2009) Log Message: ----------- Test for NH-1776 not fixed yet. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Category.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Category.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Category.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Category.cs 2009-05-14 16:26:47 UTC (rev 4303) @@ -0,0 +1,9 @@ +namespace NHibernate.Test.NHSpecificTest.NH1776 +{ + public class Category + { + public virtual int Id { get; set; } + public virtual string Code { get; set; } + public virtual bool Deleted { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs 2009-05-14 16:26:47 UTC (rev 4303) @@ -0,0 +1,52 @@ +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1776 +{ + [TestFixture, Ignore("Not fixed yet.")] + public class FilterQueryTwiceFixture : BugTestCase + { + [Test] + [Description("Can Query using Session's filter Twice")] + public void Bug() + { + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + var c = new Category {Code = "2600", Deleted = false}; + s.SaveOrUpdate(c); + tx.Commit(); + } + } + + // exec queries, twice, different session + ExecQuery(); + ExecQuery(); + + // cleanup + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + s.EnableFilter("state").SetParameter("deleted", false); + s.Delete("from Category"); + tx.Commit(); + } + } + } + + private void ExecQuery() + { + using (ISession s = OpenSession()) + { + s.EnableFilter("state").SetParameter("deleted", false); + + IList<Category> result = + s.CreateQuery("from Category where Code = :code").SetParameter("code", "2600").List<Category>(); + + Assert.That(result.Count > 0); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml 2009-05-14 16:26:47 UTC (rev 4303) @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1776" + assembly="NHibernate.Test"> + + <class name="Category"> + <id name="Id"> + <generator class="native"/> + </id> + <property name="Code"/> + <property name="Deleted"/> + <filter name="state" condition=":deleted = Deleted"/> + </class> + + <filter-def name="state" condition=":deleted = Deleted"> + <filter-param name="deleted" type="Boolean"/> + </filter-def> + +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 14:52:56 UTC (rev 4302) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 16:26:47 UTC (rev 4303) @@ -383,6 +383,8 @@ <Compile Include="NHSpecificTest\NH1760\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1773\Domain.cs" /> <Compile Include="NHSpecificTest\NH1773\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1776\Category.cs" /> + <Compile Include="NHSpecificTest\NH1776\FilterQueryTwiceFixture.cs" /> <Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" /> <Compile Include="HQL\HQLFunctions.cs" /> <Compile Include="HQL\Human.cs" /> @@ -1775,6 +1777,7 @@ <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1776\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1773\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1760\Mappings.hbm.xml" /> <EmbeddedResource Include="MappingTest\Wicked.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-14 14:53:01
|
Revision: 4302 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4302&view=rev Author: fabiomaulo Date: 2009-05-14 14:52:56 +0000 (Thu, 14 May 2009) Log Message: ----------- Passing test Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Mappings.hbm.xml Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Person.hbm.xml Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs 2009-05-14 14:44:13 UTC (rev 4301) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs 2009-05-14 14:52:56 UTC (rev 4302) @@ -1,28 +1,11 @@ -using System; -using System.Collections; -using NUnit.Framework; +using NUnit.Framework; +using System.Collections.Generic; namespace NHibernate.Test.NHSpecificTest.NH1773 { [TestFixture] public class Fixture : BugTestCase { - protected override void Configure(NHibernate.Cfg.Configuration configuration) - { - base.Configure(configuration); - configuration.SetProperty(NHibernate.Cfg.Environment.QueryTranslator, typeof(NHibernate.Hql.Classic.ClassicQueryTranslatorFactory).AssemblyQualifiedName); - } - - protected override string MappingsAssembly - { - get { return "NHibernate.Test"; } - } - - protected override IList Mappings - { - get { return new[] { "NHSpecificTest.NH1773.Person.hbm.xml"}; } - } - [Test] public void CustomHQLFunctionsShouldBeRecognizedByTheParser() { @@ -41,10 +24,10 @@ using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { - IList result = s.CreateQuery("select new PersonResult(p, current_timestamp()) from Person p left join fetch p.Country").List(); + IList<PersonResult> result = s.CreateQuery("select new PersonResult(p, current_timestamp()) from Person p left join fetch p.Country").List<PersonResult>(); - Assert.AreEqual("My Name", ((PersonResult)result[0]).Person.Name); - Assert.IsTrue(NHibernateUtil.IsInitialized(((PersonResult)result[0]).Person.Country)); + Assert.AreEqual("My Name", result[0].Person.Name); + Assert.IsTrue(NHibernateUtil.IsInitialized(result[0].Person.Country)); tx.Commit(); } } @@ -54,8 +37,8 @@ using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { - s.Delete("from Person"); - s.Delete("from Country"); + s.CreateQuery("delete from Person").ExecuteUpdate(); + s.CreateQuery("delete from Country").ExecuteUpdate(); tx.Commit(); } } Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Mappings.hbm.xml (from rev 4300, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Person.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Mappings.hbm.xml 2009-05-14 14:52:56 UTC (rev 4302) @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1773"> + <import class="PersonResult" /> + <class name="Person" table="Person"> + <id name="Id" column="id" unsaved-value="0"> + <generator class="assigned" /> + </id> + <property name="Name" column="Name" /> + <property name="Age" column="Age" /> + <many-to-one name="Country" class="Country" column="CountryId" /> + </class> + + <class name="Country" table="Country"> + <id name="Id" column="Id" unsaved-value="0"> + <generator class="assigned" /> + </id> + <property name="Name" column="Name" /> + </class> +</hibernate-mapping> \ No newline at end of file Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Person.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Person.hbm.xml 2009-05-14 14:44:13 UTC (rev 4301) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Person.hbm.xml 2009-05-14 14:52:56 UTC (rev 4302) @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1773"> - <import class="PersonResult" /> - <class name="Person" table="Person"> - <id name="Id" column="id" unsaved-value="0"> - <generator class="assigned" /> - </id> - <property name="Name" column="Name" /> - <property name="Age" column="Age" /> - <many-to-one name="Country" class="Country" column="CountryId" /> - </class> - - <class name="Country" table="Country"> - <id name="Id" column="Id" unsaved-value="0"> - <generator class="assigned" /> - </id> - <property name="Name" column="Name" /> - </class> -</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 14:44:13 UTC (rev 4301) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 14:52:56 UTC (rev 4302) @@ -1775,7 +1775,7 @@ <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> - <EmbeddedResource Include="NHSpecificTest\NH1773\Person.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1773\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1760\Mappings.hbm.xml" /> <EmbeddedResource Include="MappingTest\Wicked.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1393\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-14 14:44:16
|
Revision: 4301 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4301&view=rev Author: fabiomaulo Date: 2009-05-14 14:44:13 +0000 (Thu, 14 May 2009) Log Message: ----------- Only because different CR-LF Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Domain.cs 2009-05-14 11:43:14 UTC (rev 4300) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Domain.cs 2009-05-14 14:44:13 UTC (rev 4301) @@ -1,80 +1,80 @@ -using System; - -namespace NHibernate.Test.NHSpecificTest.NH1773 -{ - public class Person - { - private string _name; - private int _age; - private int _id; - private Country _country; - - public virtual int Id - { - get { return _id; } - set { _id = value; } - } - - public virtual string Name - { - get { return _name; } - set { _name = value; } - } - - public virtual int Age - { - get { return _age; } - set { _age = value; } - } - - public virtual Country Country - { - get { return _country; } - set { _country = value; } - } - } - - public class Country - { - private int _id; - private string _name; - - public virtual int Id - { - get { return _id; } - set { _id = value; } - } - - public virtual string Name - { - get { return _name; } - set { _name = value; } - } - } - - public class PersonResult - { - private Person _person; +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1773 +{ + public class Person + { + private string _name; + private int _age; + private int _id; + private Country _country; + + public virtual int Id + { + get { return _id; } + set { _id = value; } + } + + public virtual string Name + { + get { return _name; } + set { _name = value; } + } + + public virtual int Age + { + get { return _age; } + set { _age = value; } + } + + public virtual Country Country + { + get { return _country; } + set { _country = value; } + } + } + + public class Country + { + private int _id; + private string _name; + + public virtual int Id + { + get { return _id; } + set { _id = value; } + } + + public virtual string Name + { + get { return _name; } + set { _name = value; } + } + } + + public class PersonResult + { + private Person _person; private DateTime _time; public PersonResult(Person x) { - } - - public PersonResult(Person person, DateTime time) - { - _person = person; - _time = time; - } - - public Person Person - { - get { return _person; } - } - - public DateTime Time - { - get { return _time; } - } - } -} + } + + public PersonResult(Person person, DateTime time) + { + _person = person; + _time = time; + } + + public Person Person + { + get { return _person; } + } + + public DateTime Time + { + get { return _time; } + } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs 2009-05-14 11:43:14 UTC (rev 4300) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs 2009-05-14 14:44:13 UTC (rev 4301) @@ -1,63 +1,63 @@ -using System; -using System.Collections; -using NUnit.Framework; - -namespace NHibernate.Test.NHSpecificTest.NH1773 -{ - [TestFixture] - public class Fixture : BugTestCase - { - protected override void Configure(NHibernate.Cfg.Configuration configuration) - { - base.Configure(configuration); - //configuration.SetProperty(NHibernate.Cfg.Environment.QueryTranslator, typeof(NHibernate.Hql.Classic.ClassicQueryTranslatorFactory).AssemblyQualifiedName); - } - - protected override string MappingsAssembly - { - get { return "NHibernate.Test"; } - } - - protected override IList Mappings - { - get { return new[] { "NHSpecificTest.NH1773.Person.hbm.xml"}; } - } - - [Test] - public void CustomHQLFunctionsShouldBeRecognizedByTheParser() - { - using (ISession s = OpenSession()) - { - using (ITransaction tx = s.BeginTransaction()) - { - Country c = new Country() {Id = 100, Name = "US"}; - Person p = new Person() {Age = 35, Name = "My Name", Id=1, Country = c}; - s.Save(c); - s.Save(p); - tx.Commit(); - } - } - - using (ISession s = OpenSession()) - using (ITransaction tx = s.BeginTransaction()) +using System; +using System.Collections; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1773 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override void Configure(NHibernate.Cfg.Configuration configuration) + { + base.Configure(configuration); + configuration.SetProperty(NHibernate.Cfg.Environment.QueryTranslator, typeof(NHibernate.Hql.Classic.ClassicQueryTranslatorFactory).AssemblyQualifiedName); + } + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override IList Mappings + { + get { return new[] { "NHSpecificTest.NH1773.Person.hbm.xml"}; } + } + + [Test] + public void CustomHQLFunctionsShouldBeRecognizedByTheParser() + { + using (ISession s = OpenSession()) { + using (ITransaction tx = s.BeginTransaction()) + { + Country c = new Country() {Id = 100, Name = "US"}; + Person p = new Person() {Age = 35, Name = "My Name", Id=1, Country = c}; + s.Save(c); + s.Save(p); + tx.Commit(); + } + } + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { IList result = s.CreateQuery("select new PersonResult(p, current_timestamp()) from Person p left join fetch p.Country").List(); - - Assert.AreEqual("My Name", ((PersonResult)result[0]).Person.Name); - Assert.IsTrue(NHibernateUtil.IsInitialized(((PersonResult)result[0]).Person.Country)); - tx.Commit(); - } - } - - protected override void OnTearDown() - { - using (ISession s = OpenSession()) - using (ITransaction tx = s.BeginTransaction()) - { - s.Delete("from Person"); - s.Delete("from Country"); - tx.Commit(); - } - } - } -} + + Assert.AreEqual("My Name", ((PersonResult)result[0]).Person.Name); + Assert.IsTrue(NHibernateUtil.IsInitialized(((PersonResult)result[0]).Person.Country)); + tx.Commit(); + } + } + + protected override void OnTearDown() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from Person"); + s.Delete("from Country"); + tx.Commit(); + } + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-05-14 11:43:21
|
Revision: 4300 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4300&view=rev Author: steverstrong Date: 2009-05-14 11:43:14 +0000 (Thu, 14 May 2009) Log Message: ----------- Added test for NH-1773 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Person.hbm.xml Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Domain.cs 2009-05-14 11:43:14 UTC (rev 4300) @@ -0,0 +1,80 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1773 +{ + public class Person + { + private string _name; + private int _age; + private int _id; + private Country _country; + + public virtual int Id + { + get { return _id; } + set { _id = value; } + } + + public virtual string Name + { + get { return _name; } + set { _name = value; } + } + + public virtual int Age + { + get { return _age; } + set { _age = value; } + } + + public virtual Country Country + { + get { return _country; } + set { _country = value; } + } + } + + public class Country + { + private int _id; + private string _name; + + public virtual int Id + { + get { return _id; } + set { _id = value; } + } + + public virtual string Name + { + get { return _name; } + set { _name = value; } + } + } + + public class PersonResult + { + private Person _person; + private DateTime _time; + + public PersonResult(Person x) + { + } + + public PersonResult(Person person, DateTime time) + { + _person = person; + _time = time; + } + + public Person Person + { + get { return _person; } + } + + public DateTime Time + { + get { return _time; } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs 2009-05-14 11:43:14 UTC (rev 4300) @@ -0,0 +1,63 @@ +using System; +using System.Collections; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1773 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override void Configure(NHibernate.Cfg.Configuration configuration) + { + base.Configure(configuration); + //configuration.SetProperty(NHibernate.Cfg.Environment.QueryTranslator, typeof(NHibernate.Hql.Classic.ClassicQueryTranslatorFactory).AssemblyQualifiedName); + } + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override IList Mappings + { + get { return new[] { "NHSpecificTest.NH1773.Person.hbm.xml"}; } + } + + [Test] + public void CustomHQLFunctionsShouldBeRecognizedByTheParser() + { + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + Country c = new Country() {Id = 100, Name = "US"}; + Person p = new Person() {Age = 35, Name = "My Name", Id=1, Country = c}; + s.Save(c); + s.Save(p); + tx.Commit(); + } + } + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + IList result = s.CreateQuery("select new PersonResult(p, current_timestamp()) from Person p left join fetch p.Country").List(); + + Assert.AreEqual("My Name", ((PersonResult)result[0]).Person.Name); + Assert.IsTrue(NHibernateUtil.IsInitialized(((PersonResult)result[0]).Person.Country)); + tx.Commit(); + } + } + + protected override void OnTearDown() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from Person"); + s.Delete("from Country"); + tx.Commit(); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Person.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Person.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Person.hbm.xml 2009-05-14 11:43:14 UTC (rev 4300) @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1773"> + <import class="PersonResult" /> + <class name="Person" table="Person"> + <id name="Id" column="id" unsaved-value="0"> + <generator class="assigned" /> + </id> + <property name="Name" column="Name" /> + <property name="Age" column="Age" /> + <many-to-one name="Country" class="Country" column="CountryId" /> + </class> + + <class name="Country" table="Country"> + <id name="Id" column="Id" unsaved-value="0"> + <generator class="assigned" /> + </id> + <property name="Name" column="Name" /> + </class> +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 11:35:34 UTC (rev 4299) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 11:43:14 UTC (rev 4300) @@ -381,6 +381,8 @@ <Compile Include="NHSpecificTest\NH1742\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1760\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1760\SampleTest.cs" /> + <Compile Include="NHSpecificTest\NH1773\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1773\Fixture.cs" /> <Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" /> <Compile Include="HQL\HQLFunctions.cs" /> <Compile Include="HQL\Human.cs" /> @@ -1773,6 +1775,7 @@ <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1773\Person.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1760\Mappings.hbm.xml" /> <EmbeddedResource Include="MappingTest\Wicked.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1393\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-05-14 11:35:40
|
Revision: 4299 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4299&view=rev Author: steverstrong Date: 2009-05-14 11:35:34 +0000 (Thu, 14 May 2009) Log Message: ----------- Another minor clean up within AST parser, and a fix for NH-1773 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionList.cs trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs trunk/nhibernate/src/NHibernate/Persister/Collection/CollectionPropertyMapping.cs trunk/nhibernate/src/NHibernate/Persister/Collection/ElementPropertyMapping.cs trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractPropertyMapping.cs trunk/nhibernate/src/NHibernate/Persister/Entity/IPropertyMapping.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -847,15 +847,11 @@ if ( fromElements.Count == 1 ) { FromElement fromElement = (FromElement) fromElements[0]; - try - { - log.Info( "attempting to resolve property [" + identText + "] as a non-qualified ref" ); - return fromElement.GetPropertyMapping(identText).ToType(identText) != null; - } - catch( QueryException ) - { - // Should mean that no such property was found - } + + log.Info( "attempting to resolve property [" + identText + "] as a non-qualified ref" ); + + IType type; + return fromElement.GetPropertyMapping(identText).TryToType(identText, out type); } return false; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -136,6 +136,16 @@ //sqlResultTypeList.addAll( constructorArgumentTypeList ); queryReturnTypeList.AddRange(constructorArgumentTypeList ); _scalarSelect = true; + + for (int j = 1; j < _constructorNode.ChildCount; j++) + { + ISelectExpression se = _constructorNode.GetChild(j) as ISelectExpression; + + if (se != null && IsReturnableEntity(se)) + { + _fromElementsForLoad.Add(se.FromElement); + } + } } else { @@ -227,7 +237,7 @@ // generate id select fragment and then property select fragment for // each expression, just like generateSelectFragments(). - RenderNonScalarSelects( CollectSelectExpressions(), fromClause ); + RenderNonScalarSelects( CollectSelectExpressions(true), fromClause ); } if ( _scalarSelect || Walker.IsShallowQuery ) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionList.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionList.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectExpressionList.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -20,8 +20,16 @@ /// <summary> /// Returns an array of SelectExpressions gathered from the children of the given parent AST node. /// </summary> - public ISelectExpression[] CollectSelectExpressions() + public ISelectExpression[] CollectSelectExpressions() { + return CollectSelectExpressions(false); + } + + /// <summary> + /// Returns an array of SelectExpressions gathered from the children of the given parent AST node. + /// </summary> + public ISelectExpression[] CollectSelectExpressions(bool recurse) + { // Get the first child to be considered. Sub-classes may do this differently in order to skip nodes that // are not select expressions (e.g. DISTINCT). IASTNode firstChild = GetFirstSelectExpression(); @@ -30,14 +38,47 @@ for (IASTNode n = firstChild; n != null; n = n.NextSibling) { - var se = n as ISelectExpression; - if (se != null) + if (recurse) { - list.Add(se); + var ctor = n as ConstructorNode; + + if (ctor != null) + { + for (IASTNode cn = ctor.GetChild(1); cn != null; cn = cn.NextSibling) + { + var se = cn as ISelectExpression; + if (se != null) + { + list.Add(se); + } + } + } + else + { + var se = n as ISelectExpression; + if (se != null) + { + list.Add(se); + } + else + { + throw new InvalidOperationException("Unexpected AST: " + n.GetType().FullName + " " + + new ASTPrinter().ShowAsString(n, "")); + } + } } else { - throw new InvalidOperationException("Unexpected AST: " + n.GetType().FullName + " " + new ASTPrinter().ShowAsString(n, "")); + var se = n as ISelectExpression; + if (se != null) + { + list.Add(se); + } + else + { + throw new InvalidOperationException("Unexpected AST: " + n.GetType().FullName + " " + + new ASTPrinter().ShowAsString(n, "")); + } } } Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -1304,6 +1304,19 @@ return elementPropertyMapping.ToType(propertyName); } + public bool TryToType(string propertyName, out IType type) + { + if ("index".Equals(propertyName)) + { + type = indexType; + return true; + } + else + { + return elementPropertyMapping.TryToType(propertyName, out type); + } + } + public string GetManyToManyFilterFragment(string alias, IDictionary<string, IFilter> enabledFilters) { StringBuilder buffer = new StringBuilder(); Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/CollectionPropertyMapping.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Collection/CollectionPropertyMapping.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Persister/Collection/CollectionPropertyMapping.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -1,3 +1,4 @@ +using System; using NHibernate.Persister.Entity; using NHibernate.Type; @@ -42,6 +43,20 @@ } } + public bool TryToType(string propertyName, out IType type) + { + try + { + type = ToType(propertyName); + return true; + } + catch (Exception) + { + type = null; + return false; + } + } + public string[] ToColumns(string alias, string propertyName) { string[] cols; Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/ElementPropertyMapping.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Collection/ElementPropertyMapping.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Persister/Collection/ElementPropertyMapping.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -1,3 +1,4 @@ +using System; using NHibernate.Persister.Entity; using NHibernate.Type; using NHibernate.Util; @@ -32,6 +33,20 @@ } } + public bool TryToType(string propertyName, out IType outType) + { + try + { + outType = ToType(propertyName); + return true; + } + catch (Exception) + { + outType = null; + return false; + } + } + public string[] ToColumns(string alias, string propertyName) { if (propertyName == null || "id".Equals(propertyName)) Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -1720,6 +1720,11 @@ return propertyMapping.ToType(propertyName); } + public bool TryToType(string propertyName, out IType type) + { + return propertyMapping.TryToType(propertyName, out type); + } + public string[] GetPropertyColumnNames(string propertyName) { return propertyMapping.GetColumnNames(propertyName); Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractPropertyMapping.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractPropertyMapping.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractPropertyMapping.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -43,6 +43,11 @@ } } + public bool TryToType(string propertyName, out IType type) + { + return typesByPropertyPath.TryGetValue(propertyName, out type); + } + public virtual string[] ToColumns(string alias, string propertyName) { //TODO: *two* hashmap lookups here is one too many... Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/IPropertyMapping.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/IPropertyMapping.cs 2009-05-14 06:41:09 UTC (rev 4298) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/IPropertyMapping.cs 2009-05-14 11:35:34 UTC (rev 4299) @@ -22,6 +22,14 @@ IType ToType(string propertyName); /// <summary> + /// Given a component path expression, get the type of the property. + /// </summary> + /// <param name="propertyName"></param> + /// <param name="type"></param> + /// <returns>true if a type was found, false if not</returns> + bool TryToType(string propertyName, out IType type); + + /// <summary> /// Given a query alias and a property path, return the qualified column name /// </summary> /// <param name="alias"></param> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-14 06:41:15
|
Revision: 4298 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4298&view=rev Author: fabiomaulo Date: 2009-05-14 06:41:09 +0000 (Thu, 14 May 2009) Log Message: ----------- - Improved log to check Dtc possible problems - Fix NH-1769 (by Timo Rantanen) - added some test for Dtc Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-14 03:56:57 UTC (rev 4297) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-14 06:41:09 UTC (rev 4298) @@ -318,10 +318,13 @@ using (var tx = new TransactionScope(ambientTransation)) { BeforeTransactionCompletion(null); - if (FlushMode != FlushMode.Never) + if (FlushMode != FlushMode.Never && ConnectionManager.IsConnected) { using (ConnectionManager.FlushingFromDtcTransaction) + { + logger.Debug(string.Format("[session-id={0}] Flushing from Dtc Transaction", sessionId)); Flush(); + } } logger.Debug("prepared for DTC transaction"); @@ -333,7 +336,6 @@ { logger.Error("DTC transaction prepre phase failed", exception); preparingEnlistment.ForceRollback(exception); - } } } @@ -382,13 +384,21 @@ AfterTransactionBegin(null); ambientTransation.TransactionCompleted += delegate(object sender, TransactionEventArgs e) { - bool wasSuccessful = e.Transaction.TransactionInformation.Status - == TransactionStatus.Committed; - AfterTransactionCompletion(wasSuccessful, null); - if (shouldCloseSessionOnDtcTransactionCompleted) + bool wasSuccessful = false; + try { - Dispose(true); + wasSuccessful = e.Transaction.TransactionInformation.Status + == TransactionStatus.Committed; } + catch (ObjectDisposedException ode) + { + logger.Warn("Completed transaction was disposed.", ode); + } + AfterTransactionCompletion(wasSuccessful, null); + if (shouldCloseSessionOnDtcTransactionCompleted) + { + Dispose(true); + } ambientTransation = null; }; ambientTransation.EnlistVolatile(this, EnlistmentOptions.EnlistDuringPrepareRequired); Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-14 03:56:57 UTC (rev 4297) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-14 06:41:09 UTC (rev 4298) @@ -226,7 +226,7 @@ if (log.IsDebugEnabled) { - log.Debug("opened session at timestamp: " + timestamp); + log.Debug(string.Format("[session-id={0}]opened session at timestamp:{1}", sessionId, timestamp)); } CheckAndUpdateSessionStatus(); @@ -1655,7 +1655,7 @@ { using (new SessionIdLoggingContext(sessionId)) { - log.Debug("running ISession.Dispose()"); + log.Debug(string.Format("[session-id={0}]running ISession.Dispose()",sessionId)); if (TakingPartInDtcTransaction) { shouldCloseSessionOnDtcTransactionCompleted = true; @@ -1684,6 +1684,8 @@ return; } + log.Debug(string.Format("[session-id={0}]executing real Dispose({1})", sessionId, isDisposing)); + // free managed resources that are being managed by the session if we // know this call came through Dispose() if (isDisposing && !IsClosed) Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs 2009-05-14 03:56:57 UTC (rev 4297) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs 2009-05-14 06:41:09 UTC (rev 4298) @@ -2,6 +2,8 @@ using System.Collections; using System.Threading; using System.Transactions; +using log4net; +using log4net.Repository.Hierarchy; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.DtcFailures @@ -9,9 +11,11 @@ [TestFixture] public class DtcFailuresFixture : TestCase { + private static readonly ILog log = LogManager.GetLogger(typeof(DtcFailuresFixture)); + protected override IList Mappings { - get { return new string[] {"NHSpecificTest.DtcFailures.Mappings.hbm.xml"}; } + get { return new[] {"NHSpecificTest.DtcFailures.Mappings.hbm.xml"}; } } protected override string MappingsAssembly @@ -51,7 +55,7 @@ using (ISession s = sessions.OpenSession()) { new ForceEscalationToDistributedTx(true); //will rollback tx - s.Save(new Person {CreatedAt = DateTime.Today}); + s.Save(new Person { CreatedAt = DateTime.Today }); tx.Complete(); } @@ -67,6 +71,151 @@ } [Test] + [Description("Another action inside the transaction do the rollBack outside nh-session-scope.")] + public void RollbackOutsideNh() + { + try + { + using (var txscope = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + var person = new Person { CreatedAt = DateTime.Now }; + s.Save(person); + } + new ForceEscalationToDistributedTx(true); //will rollback tx + + txscope.Complete(); + } + + log.DebugFormat("Transaction fail."); + Assert.Fail("Expected tx abort"); + } + catch (TransactionAbortedException) + { + log.DebugFormat("Transaction aborted."); + } + } + + [Test] + [Description("rollback inside nh-session-scope should not commit save and the transaction should be aborted.")] + public void TransactionInsertWithRollBackTask() + { + try + { + using (var txscope = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + var person = new Person {CreatedAt = DateTime.Now}; + s.Save(person); + new ForceEscalationToDistributedTx(true); //will rollback tx + person.CreatedAt = DateTime.Now; + s.Update(person); + } + txscope.Complete(); + } + log.DebugFormat("Transaction fail."); + Assert.Fail("Expected tx abort"); + } + catch (TransactionAbortedException) + { + log.DebugFormat("Transaction aborted."); + } + } + + [Test, Ignore("Not fixed.")] + [Description(@"Two session in two txscope +(without an explicit NH transaction and without an explicit flush) +and with a rollback in the second dtc and a ForceRollback outside nh-session-scope.")] + public void TransactionInsertLoadWithRollBackTask() + { + object savedId; + using (var txscope = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + var person = new Person {CreatedAt = DateTime.Now}; + savedId = s.Save(person); + } + txscope.Complete(); + } + try + { + using (var txscope = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + var person = s.Get<Person>(savedId); + person.CreatedAt = DateTime.Now; + s.Update(person); + } + new ForceEscalationToDistributedTx(true); + + log.Debug("completing the tx scope"); + txscope.Complete(); + } + log.Debug("Transaction fail."); + Assert.Fail("Expected tx abort"); + } + catch (TransactionAbortedException) + { + log.Debug("Transaction aborted."); + } + finally + { + using (var txscope = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + var person = s.Get<Person>(savedId); + s.Delete(person); + } + txscope.Complete(); + } + } + } + + private int totalCall; + + [Test, Explicit] + public void MultiThreadedTransaction() + { + // Test added for NH-1709 (trying to recreate the issue... without luck) + // If one thread break the test, you can see the result in the console. + ((Logger)log.Logger).Level = log4net.Core.Level.Debug; + var actions = new MultiThreadRunner<object>.ExecuteAction[] + { + delegate(object o) + { + Can_roll_back_transaction(); + totalCall++; + }, + delegate(object o) + { + RollbackOutsideNh(); + totalCall++; + }, + delegate(object o) + { + TransactionInsertWithRollBackTask(); + totalCall++; + }, + //delegate(object o) + // { + // TransactionInsertLoadWithRollBackTask(); + // totalCall++; + // }, + }; + var mtr = new MultiThreadRunner<object>(20, actions) + { + EndTimeout = 5000, TimeoutBetweenThreadStart = 5 + }; + mtr.Run(null); + log.DebugFormat("{0} calls", totalCall); + } + + [Test] public void CanDeleteItemInDtc() { object id; @@ -95,6 +244,26 @@ } } + [Test] + [Description("Open/Close a session inside a TransactionScope fails.")] + public void NH1744() + { + using (var tx = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + s.Flush(); + } + + using (ISession s = sessions.OpenSession()) + { + s.Flush(); + } + + //and I always leave the transaction disposed without calling tx.Complete(), I let the database server to rollback all actions in this test. + } + } + public class ForceEscalationToDistributedTx : IEnlistmentNotification { private readonly bool shouldRollBack; @@ -114,6 +283,7 @@ Assert.AreNotEqual(thread, Thread.CurrentThread.ManagedThreadId); if (shouldRollBack) { + log.Debug(">>>>Force Rollback<<<<<"); preparingEnlistment.ForceRollback(); } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-14 03:57:03
|
Revision: 4297 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4297&view=rev Author: fabiomaulo Date: 2009-05-14 03:56:57 +0000 (Thu, 14 May 2009) Log Message: ----------- Minor (reformatted) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs 2009-05-13 23:14:26 UTC (rev 4296) +++ trunk/nhibernate/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs 2009-05-14 03:56:57 UTC (rev 4297) @@ -88,15 +88,19 @@ } [Test] - public void TwoTransactionScopesInsideOneSession() { + public void TwoTransactionScopesInsideOneSession() + { var interceptor = new RecordingInterceptor(); - using(var session = sessions.OpenSession(interceptor)) { - using(var scope = new TransactionScope()) { + using (var session = sessions.OpenSession(interceptor)) + { + using (var scope = new TransactionScope()) + { session.CreateCriteria<object>().List(); scope.Complete(); } - using(var scope = new TransactionScope()) { + using (var scope = new TransactionScope()) + { session.CreateCriteria<object>().List(); scope.Complete(); } @@ -107,10 +111,13 @@ } [Test] - public void OneTransactionScopesInsideOneSession() { + public void OneTransactionScopesInsideOneSession() + { var interceptor = new RecordingInterceptor(); - using(var session = sessions.OpenSession(interceptor)) { - using(var scope = new TransactionScope()) { + using (var session = sessions.OpenSession(interceptor)) + { + using (var scope = new TransactionScope()) + { session.CreateCriteria<object>().List(); scope.Complete(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-13 23:14:27
|
Revision: 4296 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4296&view=rev Author: fabiomaulo Date: 2009-05-13 23:14:26 +0000 (Wed, 13 May 2009) Log Message: ----------- Cleaned Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs 2009-05-13 23:07:09 UTC (rev 4295) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs 2009-05-13 23:14:26 UTC (rev 4296) @@ -1,156 +1,141 @@ using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SqlClient; +using System.Collections; using System.Threading; using System.Transactions; -using NHibernate.Criterion; -using NHibernate.Dialect; -using NHibernate.Exceptions; -using NHibernate.Impl; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.DtcFailures { - using System.Collections; + [TestFixture] + public class DtcFailuresFixture : TestCase + { + protected override IList Mappings + { + get { return new string[] {"NHSpecificTest.DtcFailures.Mappings.hbm.xml"}; } + } - [TestFixture] - public class DtcFailuresFixture : TestCase - { + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } - protected override IList Mappings - { - get { return new string[] { "NHSpecificTest.DtcFailures.Mappings.hbm.xml" }; } - } + [Test] + public void WillNotCrashOnDtcPrepareFailure() + { + var tx = new TransactionScope(); + using (ISession s = sessions.OpenSession()) + { + s.Save(new Person {CreatedAt = DateTime.MinValue // will cause SQL date failure + }); + } - protected override string MappingsAssembly - { - get { return "NHibernate.Test"; } - } + new ForceEscalationToDistributedTx(); - [Test] - public void WillNotCrashOnDtcPrepareFailure() - { - var tx = new TransactionScope(); - using (var s = sessions.OpenSession()) - { - s.Save(new Person - { - CreatedAt = DateTime.MinValue // will cause SQL date failure - }); - } + tx.Complete(); + try + { + tx.Dispose(); + Assert.Fail("Expected failure"); + } + catch (AssertionException) + { + throw; + } + catch (Exception) {} + } - new ForceEscalationToDistributedTx(); + [Test] + public void Can_roll_back_transaction() + { + var tx = new TransactionScope(); + using (ISession s = sessions.OpenSession()) + { + new ForceEscalationToDistributedTx(true); //will rollback tx + s.Save(new Person {CreatedAt = DateTime.Today}); - tx.Complete(); - try - { - tx.Dispose(); - Assert.Fail("Expected failure"); - } - catch (AssertionException) - { - throw; - } - catch (Exception) - { - } - } + tx.Complete(); + } + try + { + tx.Dispose(); + Assert.Fail("Expected tx abort"); + } + catch (TransactionAbortedException) + { + //expected + } + } - [Test] - public void Can_roll_back_transaction() - { - var tx = new TransactionScope(); - using (var s = sessions.OpenSession()) - { - new ForceEscalationToDistributedTx(true);//will rollback tx - s.Save(new Person - { - CreatedAt = DateTime.Today - }); + [Test] + public void CanDeleteItemInDtc() + { + object id; + using (var tx = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + id = s.Save(new Person {CreatedAt = DateTime.Today}); - tx.Complete(); - } - try - { - tx.Dispose(); - Assert.Fail("Expected tx abort"); - } - catch (TransactionAbortedException) - { - //expected - } - } + new ForceEscalationToDistributedTx(); - [Test] - public void CanDeleteItemInDtc() - { - object id; - using (var tx = new TransactionScope()) - using (var s = sessions.OpenSession()) - { - id = s.Save(new Person - { - CreatedAt = DateTime.Today - }); + tx.Complete(); + } + } - new ForceEscalationToDistributedTx(); - - tx.Complete(); - } + using (var tx = new TransactionScope()) + { + using (ISession s = sessions.OpenSession()) + { + new ForceEscalationToDistributedTx(); - using (var tx = new TransactionScope()) - using (var s = sessions.OpenSession()) - { - new ForceEscalationToDistributedTx(); - - s.Delete(s.Get<Person>(id)); + s.Delete(s.Get<Person>(id)); - tx.Complete(); - } + tx.Complete(); + } + } + } - } + public class ForceEscalationToDistributedTx : IEnlistmentNotification + { + private readonly bool shouldRollBack; + private readonly int thread; - public class ForceEscalationToDistributedTx : IEnlistmentNotification - { - private readonly bool shouldRollBack; - private readonly int thread; + public ForceEscalationToDistributedTx(bool shouldRollBack) + { + this.shouldRollBack = shouldRollBack; + thread = Thread.CurrentThread.ManagedThreadId; + System.Transactions.Transaction.Current.EnlistDurable(Guid.NewGuid(), this, EnlistmentOptions.None); + } - public ForceEscalationToDistributedTx(bool shouldRollBack) - { - this.shouldRollBack = shouldRollBack; - thread = Thread.CurrentThread.ManagedThreadId; - System.Transactions.Transaction.Current.EnlistDurable(Guid.NewGuid(), this, EnlistmentOptions.None); - } + public ForceEscalationToDistributedTx() : this(false) {} - public ForceEscalationToDistributedTx():this(false) - { - - } + public void Prepare(PreparingEnlistment preparingEnlistment) + { + Assert.AreNotEqual(thread, Thread.CurrentThread.ManagedThreadId); + if (shouldRollBack) + { + preparingEnlistment.ForceRollback(); + } + else + { + preparingEnlistment.Prepared(); + } + } - public void Prepare(PreparingEnlistment preparingEnlistment) - { - Assert.AreNotEqual(thread, Thread.CurrentThread.ManagedThreadId); - if (shouldRollBack) - preparingEnlistment.ForceRollback(); - else - preparingEnlistment.Prepared(); - } + public void Commit(Enlistment enlistment) + { + enlistment.Done(); + } - public void Commit(Enlistment enlistment) - { - enlistment.Done(); - } + public void Rollback(Enlistment enlistment) + { + enlistment.Done(); + } - public void Rollback(Enlistment enlistment) - { - enlistment.Done(); - } - - public void InDoubt(Enlistment enlistment) - { - enlistment.Done(); - } - } - } -} + public void InDoubt(Enlistment enlistment) + { + enlistment.Done(); + } + } + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-13 23:07:17
|
Revision: 4295 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4295&view=rev Author: fabiomaulo Date: 2009-05-13 23:07:09 +0000 (Wed, 13 May 2009) Log Message: ----------- Fix NH-1767 (by James Kovacs) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs trunk/nhibernate/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-13 22:32:05 UTC (rev 4294) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-13 23:07:09 UTC (rev 4295) @@ -381,12 +381,16 @@ logger.DebugFormat("enlisted into DTC transaction: {0}", ambientTransation.IsolationLevel); AfterTransactionBegin(null); ambientTransation.TransactionCompleted += delegate(object sender, TransactionEventArgs e) - { - bool wasSuccessful = e.Transaction.TransactionInformation.Status == TransactionStatus.Committed; - AfterTransactionCompletion(wasSuccessful, null); - if (shouldCloseSessionOnDtcTransactionCompleted) - Dispose(true); - }; + { + bool wasSuccessful = e.Transaction.TransactionInformation.Status + == TransactionStatus.Committed; + AfterTransactionCompletion(wasSuccessful, null); + if (shouldCloseSessionOnDtcTransactionCompleted) + { + Dispose(true); + } + ambientTransation = null; + }; ambientTransation.EnlistVolatile(this, EnlistmentOptions.EnlistDuringPrepareRequired); } } Modified: trunk/nhibernate/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs 2009-05-13 22:32:05 UTC (rev 4294) +++ trunk/nhibernate/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs 2009-05-13 23:07:09 UTC (rev 4295) @@ -14,23 +14,23 @@ public class RecordingInterceptor : EmptyInterceptor { - public bool afterTransactionBeginCalled; - public bool afterTransactionCompletionCalled; - public bool beforeTransactionCompletionCalled; + public int afterTransactionBeginCalled; + public int afterTransactionCompletionCalled; + public int beforeTransactionCompletionCalled; public override void AfterTransactionBegin(ITransaction tx) { - afterTransactionBeginCalled = true; + afterTransactionBeginCalled++; } public override void AfterTransactionCompletion(ITransaction tx) { - afterTransactionCompletionCalled = true; + afterTransactionCompletionCalled++; } public override void BeforeTransactionCompletion(ITransaction tx) { - beforeTransactionCompletionCalled = true; + beforeTransactionCompletionCalled++; } } @@ -40,9 +40,9 @@ RecordingInterceptor interceptor = new RecordingInterceptor(); using (sessions.OpenSession(interceptor)) { - Assert.IsFalse(interceptor.afterTransactionBeginCalled); - Assert.IsFalse(interceptor.beforeTransactionCompletionCalled); - Assert.IsFalse(interceptor.afterTransactionCompletionCalled); + Assert.AreEqual(0, interceptor.afterTransactionBeginCalled); + Assert.AreEqual(0, interceptor.beforeTransactionCompletionCalled); + Assert.AreEqual(0, interceptor.afterTransactionCompletionCalled); } } @@ -53,9 +53,9 @@ using (new TransactionScope()) using (sessions.OpenSession(interceptor)) { - Assert.IsTrue(interceptor.afterTransactionBeginCalled); - Assert.IsFalse(interceptor.beforeTransactionCompletionCalled); - Assert.IsFalse(interceptor.afterTransactionCompletionCalled); + Assert.AreEqual(1, interceptor.afterTransactionBeginCalled); + Assert.AreEqual(0, interceptor.beforeTransactionCompletionCalled); + Assert.AreEqual(0, interceptor.afterTransactionCompletionCalled); } } @@ -70,8 +70,8 @@ scope.Complete(); } session.Dispose(); - Assert.IsTrue(interceptor.beforeTransactionCompletionCalled); - Assert.IsTrue(interceptor.afterTransactionCompletionCalled); + Assert.AreEqual(1, interceptor.beforeTransactionCompletionCalled); + Assert.AreEqual(1, interceptor.afterTransactionCompletionCalled); } @@ -83,9 +83,41 @@ using (sessions.OpenSession(interceptor)) { } - Assert.IsFalse(interceptor.beforeTransactionCompletionCalled); - Assert.IsTrue(interceptor.afterTransactionCompletionCalled); - + Assert.AreEqual(0, interceptor.beforeTransactionCompletionCalled); + Assert.AreEqual(2, interceptor.afterTransactionCompletionCalled); } + + [Test] + public void TwoTransactionScopesInsideOneSession() { + var interceptor = new RecordingInterceptor(); + using(var session = sessions.OpenSession(interceptor)) { + using(var scope = new TransactionScope()) { + session.CreateCriteria<object>().List(); + scope.Complete(); + } + + using(var scope = new TransactionScope()) { + session.CreateCriteria<object>().List(); + scope.Complete(); + } + } + Assert.AreEqual(2, interceptor.afterTransactionBeginCalled); + Assert.AreEqual(2, interceptor.beforeTransactionCompletionCalled); + Assert.AreEqual(2, interceptor.afterTransactionCompletionCalled); + } + + [Test] + public void OneTransactionScopesInsideOneSession() { + var interceptor = new RecordingInterceptor(); + using(var session = sessions.OpenSession(interceptor)) { + using(var scope = new TransactionScope()) { + session.CreateCriteria<object>().List(); + scope.Complete(); + } + } + Assert.AreEqual(1, interceptor.afterTransactionBeginCalled); + Assert.AreEqual(1, interceptor.beforeTransactionCompletionCalled); + Assert.AreEqual(1, interceptor.afterTransactionCompletionCalled); + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-13 22:32:16
|
Revision: 4294 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4294&view=rev Author: fabiomaulo Date: 2009-05-13 22:32:05 +0000 (Wed, 13 May 2009) Log Message: ----------- - Fix the problem created in the my previous commit. - Fixed SqlClientBatchingBatcher and now we have a test about it Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs trunk/nhibernate/src/NHibernate.Test/LogSpy.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Ado/ trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.cs trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.hbm.xml Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 22:07:13 UTC (rev 4293) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 22:32:05 UTC (rev 4294) @@ -19,7 +19,10 @@ { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); - currentBatchCommandsLog = new StringBuilder(); + if (log.IsDebugEnabled) + { + currentBatchCommandsLog = new StringBuilder(); + } } public override int BatchSize @@ -32,20 +35,23 @@ { totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - - if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + if (log.IsDebugEnabled) { string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); - currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); } - else if (log.IsDebugEnabled) + else { log.Debug("Adding to batch:" + lineWithParameters); } + currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); } + else + { + Factory.Settings.SqlStatementLogger.LogCommand(batchUpdate, FormatStyle.Basic); + } currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate); if (currentBatch.CountOfCommands >= batchSize) { @@ -58,12 +64,9 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + if (log.IsDebugEnabled) { - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); - else if (log.IsDebugEnabled) - log.Debug(currentBatchCommandsLog.ToString()); + log.Debug(currentBatchCommandsLog.ToString()); currentBatchCommandsLog = new StringBuilder(); } int rowsAffected = currentBatch.ExecuteNonQuery(); Added: trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs 2009-05-13 22:32:05 UTC (rev 4294) @@ -0,0 +1,197 @@ +using System.Collections; +using NHibernate.AdoNet; +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.Ado +{ + [TestFixture] + public class BatcherFixture: TestCase + { + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override IList Mappings + { + get { return new[] { "Ado.VerySimple.hbm.xml" }; } + } + + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.FormatSql, "true"); + configuration.SetProperty(Environment.GenerateStatistics, "true"); + configuration.SetProperty(Environment.BatchSize, "10"); + } + + protected override bool AppliesTo(Engine.ISessionFactoryImplementor factory) + { + return !(factory.Settings.BatcherFactory is NonBatchingBatcherFactory); + } + + [Test] + [Description("The batcher should run all INSERT queries in only one roundtrip.")] + public void OneRoundTripInserts() + { + sessions.Statistics.Clear(); + FillDb(); + + Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Cleanup(); + } + + private void Cleanup() + { + using (ISession s = sessions.OpenSession()) + using (s.BeginTransaction()) + { + s.CreateQuery("delete from VerySimple").ExecuteUpdate(); + s.Transaction.Commit(); + } + } + + private void FillDb() + { + using (ISession s = sessions.OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Save(new VerySimple {Id = 1, Name = "Fabio", Weight = 119.5}); + s.Save(new VerySimple {Id = 2, Name = "Fiamma", Weight = 9.8}); + tx.Commit(); + } + } + + [Test] + [Description("The batcher should run all UPDATE queries in only one roundtrip.")] + public void OneRoundTripUpdate() + { + FillDb(); + + using (ISession s = sessions.OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + var vs1 = s.Get<VerySimple>(1); + var vs2 = s.Get<VerySimple>(2); + vs1.Weight -= 10; + vs1.Weight -= 1; + sessions.Statistics.Clear(); + s.Update(vs1); + s.Update(vs2); + tx.Commit(); + } + + Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Cleanup(); + } + + [Test] + [Description("The batcher should run all DELETE queries in only one roundtrip.")] + public void OneRoundTripDelete() + { + FillDb(); + + using (ISession s = sessions.OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + var vs1 = s.Get<VerySimple>(1); + var vs2 = s.Get<VerySimple>(2); + sessions.Statistics.Clear(); + s.Delete(vs1); + s.Delete(vs2); + tx.Commit(); + } + + Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Cleanup(); + } + + [Test] + [Description(@"Activating the SQL and turning off the batcher's log the log stream: +-should not contains any batch info +-should contain SQL's log info +-the batcher should work.")] + public void SqlLog() + { + using (new LogSpy(typeof(AbstractBatcher), true)) + { + using (var sl = new SqlLogSpy()) + { + sessions.Statistics.Clear(); + FillDb(); + string logs = sl.GetWholeLog(); + Assert.That(logs, Text.DoesNotContain("batch").IgnoreCase); + Assert.That(logs, Text.Contains("INSERT").IgnoreCase); + } + } + + Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Cleanup(); + } + + [Test] + [Description(@"Activating the AbstractBatcher's log the log stream: +-should not contains batch info +-should contain SQL log info only regarding batcher (SQL log should not be duplicated) +-the batcher should work.")] + public void AbstractBatcherLog() + { + using (new LogSpy(typeof(AbstractBatcher))) + { + using (var sl = new SqlLogSpy()) + { + sessions.Statistics.Clear(); + FillDb(); + string logs = sl.GetWholeLog(); + Assert.That(logs, Text.Contains("batch").IgnoreCase); + foreach (var loggingEvent in sl.Appender.GetEvents()) + { + string message = loggingEvent.RenderedMessage; + if(message.ToLowerInvariant().Contains("insert")) + { + Assert.That(message, Text.Contains("batch").IgnoreCase); + } + } + } + } + + Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Cleanup(); + } + + [Test] + [Description(@"Activating the AbstractBatcher's log the log stream: +-should contain well formatted SQL log info")] + public void AbstractBatcherLogFormattedSql() + { + using (new LogSpy(typeof(AbstractBatcher))) + { + using (var sl = new SqlLogSpy()) + { + sessions.Statistics.Clear(); + FillDb(); + foreach (var loggingEvent in sl.Appender.GetEvents()) + { + string message = loggingEvent.RenderedMessage; + if(message.StartsWith("Adding")) + { + // should be the line with the formatted SQL + var strings = message.Split(System.Environment.NewLine.ToCharArray()); + foreach (var sqlLine in strings) + { + if(sqlLine.Contains("p0")) + { + Assert.That(sqlLine, Text.Contains("p1")); + Assert.That(sqlLine, Text.Contains("p2")); + } + } + } + } + } + } + + Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Cleanup(); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.cs 2009-05-13 22:32:05 UTC (rev 4294) @@ -0,0 +1,9 @@ +namespace NHibernate.Test.Ado +{ + public class VerySimple + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual double Weight { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Ado/VerySimple.hbm.xml 2009-05-13 22:32:05 UTC (rev 4294) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.Ado"> + + <class name="VerySimple"> + <id name="Id"/> + <property name="Name"/> + <property name="Weight"/> + </class> + +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/LogSpy.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/LogSpy.cs 2009-05-13 22:07:13 UTC (rev 4293) +++ trunk/nhibernate/src/NHibernate.Test/LogSpy.cs 2009-05-13 22:32:05 UTC (rev 4294) @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; using log4net; using log4net.Appender; using log4net.Core; @@ -12,7 +14,7 @@ private readonly Logger logger; private readonly Level prevLogLevel; - public LogSpy(ILog log) + public LogSpy(ILog log, bool disable) { logger = log.Logger as Logger; if (logger == null) @@ -22,22 +24,35 @@ // Change the log level to DEBUG and temporarily save the previous log level prevLogLevel = logger.Level; - logger.Level = Level.Debug; + logger.Level = disable ? Level.Off : Level.Debug; // Add a new MemoryAppender to the logger. appender = new MemoryAppender(); logger.AddAppender(appender); } - public LogSpy(System.Type loggerType) : this(LogManager.GetLogger(loggerType)) {} + public LogSpy(ILog log) : this(log, false) { } + public LogSpy(System.Type loggerType) : this(LogManager.GetLogger(loggerType), false) { } + public LogSpy(System.Type loggerType, bool disable) : this(LogManager.GetLogger(loggerType), disable) { } - public LogSpy(string loggerName) : this(LogManager.GetLogger(loggerName)) {} + public LogSpy(string loggerName) : this(LogManager.GetLogger(loggerName), false) { } + public LogSpy(string loggerName, bool disable) : this(LogManager.GetLogger(loggerName), disable) { } public MemoryAppender Appender { get { return appender; } } + public virtual string GetWholeLog() + { + var wholeMessage = new StringBuilder(); + foreach (LoggingEvent loggingEvent in Appender.GetEvents()) + { + wholeMessage.Append(loggingEvent.RenderedMessage); + } + return wholeMessage.ToString(); + } + #region IDisposable Members public void Dispose() Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-13 22:07:13 UTC (rev 4293) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-13 22:32:05 UTC (rev 4294) @@ -74,6 +74,8 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="Ado\BatcherFixture.cs" /> + <Compile Include="Ado\VerySimple.cs" /> <Compile Include="Any\Address.cs" /> <Compile Include="Any\AnyTypeTest.cs" /> <Compile Include="Any\ComplexPropertyValue.cs" /> @@ -1769,6 +1771,7 @@ <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> + <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> <EmbeddedResource Include="NHSpecificTest\NH1760\Mappings.hbm.xml" /> <EmbeddedResource Include="MappingTest\Wicked.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-13 22:07:19
|
Revision: 4293 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4293&view=rev Author: fabiomaulo Date: 2009-05-13 22:07:13 +0000 (Wed, 13 May 2009) Log Message: ----------- Reformatted Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs 2009-05-13 19:31:17 UTC (rev 4292) +++ trunk/nhibernate/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs 2009-05-13 22:07:13 UTC (rev 4293) @@ -11,7 +11,7 @@ private static readonly ILog log = LogManager.GetLogger("NHibernate.SQL"); /// <summary> Constructs a new SqlStatementLogger instance.</summary> - public SqlStatementLogger() : this(false, false) {} + public SqlStatementLogger() : this(false, false) { } /// <summary> Constructs a new SqlStatementLogger instance. </summary> /// <param name="logToStdout">Should we log to STDOUT in addition to our internal logger. </param> @@ -47,11 +47,11 @@ string logMessage; if (string.IsNullOrEmpty(message)) { - logMessage= statement; + logMessage = statement; } else { - logMessage= message + statement; + logMessage = message + statement; } log.Debug(logMessage); if (LogToStdout) @@ -60,11 +60,6 @@ } } - public virtual void LogBatchCommand(string batchCommand) - { - log.Debug(batchCommand); - } - /// <summary> Log a IDbCommand. </summary> /// <param name="command">The SQL statement. </param> /// <param name="style">The requested formatting style. </param> @@ -84,7 +79,7 @@ else { var output = new StringBuilder(command.CommandText.Length + (command.Parameters.Count * 20)); - output.Append(command.CommandText.TrimEnd(' ',';','\n')); + output.Append(command.CommandText.TrimEnd(' ', ';', '\n')); output.Append(";"); IDataParameter p; @@ -107,37 +102,37 @@ public string GetParameterLogableValue(IDataParameter parameter) { - if(parameter.Value == null || DBNull.Value.Equals(parameter.Value)) + if (parameter.Value == null || DBNull.Value.Equals(parameter.Value)) { return "NULL"; } - if (IsStringType(parameter.DbType)) - { - return string.Concat("'", parameter.Value.ToString(), "'"); - } - var buffer = parameter.Value as byte[]; - if(buffer != null) - { - return GetBufferAsHexString(buffer); - } - return parameter.Value.ToString(); + if (IsStringType(parameter.DbType)) + { + return string.Concat("'", parameter.Value.ToString(), "'"); + } + var buffer = parameter.Value as byte[]; + if (buffer != null) + { + return GetBufferAsHexString(buffer); + } + return parameter.Value.ToString(); } - private static string GetBufferAsHexString(byte[] buffer) - { - var sb = new StringBuilder(buffer.Length*2 + 2); - sb.Append("0x"); - foreach (var b in buffer) - { - sb.Append(b.ToString("X2")); - } - return sb.ToString(); - } + private static string GetBufferAsHexString(byte[] buffer) + { + var sb = new StringBuilder(buffer.Length * 2 + 2); + sb.Append("0x"); + foreach (var b in buffer) + { + sb.Append(b.ToString("X2")); + } + return sb.ToString(); + } - private static bool IsStringType(DbType dbType) + private static bool IsStringType(DbType dbType) { return DbType.String.Equals(dbType) || DbType.AnsiString.Equals(dbType) - || DbType.AnsiStringFixedLength.Equals(dbType) || DbType.StringFixedLength.Equals(dbType); + || DbType.AnsiStringFixedLength.Equals(dbType) || DbType.StringFixedLength.Equals(dbType); } private FormatStyle DetermineActualStyle(FormatStyle style) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-13 19:31:22
|
Revision: 4292 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4292&view=rev Author: fabiomaulo Date: 2009-05-13 19:31:17 +0000 (Wed, 13 May 2009) Log Message: ----------- Test for NH-1760 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/DomainClass.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/SampleTest.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/DomainClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/DomainClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/DomainClass.cs 2009-05-13 19:31:17 UTC (rev 4292) @@ -0,0 +1,60 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1760 +{ + public class Customer + { + public Int32 Id { get; set; } + public String Name { get; set; } + } + + public class TestClass + { + public TestClassId Id { get; set; } + public String Value { get; set; } + } + + public class TestClassId + { + public Customer Customer { get; set; } + public Int32 SomeInt { get; set; } + + public bool Equals(TestClassId other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return Equals(other.Customer, Customer) && other.SomeInt == SomeInt; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + if (ReferenceEquals(this, obj)) + { + return true; + } + if (obj.GetType() != typeof (TestClassId)) + { + return false; + } + return Equals((TestClassId) obj); + } + + public override int GetHashCode() + { + unchecked + { + return ((Customer != null ? Customer.GetHashCode() : 0) * 397) ^ SomeInt; + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/Mappings.hbm.xml 2009-05-13 19:31:17 UTC (rev 4292) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1760" + default-lazy="false"> + + <class name="Customer"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + </class> + + <class name="TestClass" > + <composite-id name="Id" class="TestClassId"> + <key-many-to-one class="Customer" name="Customer" /> + <key-property name="SomeInt" /> + </composite-id> + <property name="Value" /> + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/SampleTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/SampleTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/SampleTest.cs 2009-05-13 19:31:17 UTC (rev 4292) @@ -0,0 +1,62 @@ +using System.Collections.Generic; +using NHibernate.Criterion; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1760 +{ + [TestFixture] + public class SampleTest : BugTestCase + { + private void FillDb() + { + using (ISession session = OpenSession()) + using (var tx = session.BeginTransaction()) + { + var customer = new Customer {Name = "Alkampfer"}; + session.Save(customer); + var testClass = new TestClass {Id = new TestClassId{Customer = customer, SomeInt = 42}, Value = "TESTVALUE"}; + session.Save(testClass); + tx.Commit(); + } + } + + private void Cleanup() + { + using (ISession session = OpenSession()) + using (var tx = session.BeginTransaction()) + { + session.CreateQuery("from TestClass").ExecuteUpdate(); + session.CreateQuery("from Customer").ExecuteUpdate(); + tx.Commit(); + } + } + + [Test, Ignore("Not fixed yet.")] + public void CanUseCriteria() + { + FillDb(); + int hqlCount; + int criteriaCount; + using (ISession session = OpenSession()) + { + IList<TestClass> retvalue = + session.CreateQuery("Select tc from TestClass tc where tc.Id.Customer.Name = :name").SetString("name", "Alkampfer") + .List<TestClass>(); + hqlCount = retvalue.Count; + } + + using (ISession session = OpenSession()) + { + ICriteria c = + session.CreateCriteria(typeof (TestClass)).CreateAlias("Id.Customer", "IdCust").Add(Restrictions.Eq("IdCust.Name", + "Alkampfer")); + IList<TestClass> retvalue = c.List<TestClass>(); + criteriaCount = retvalue.Count; + } + Assert.That(hqlCount == criteriaCount); + Assert.That(hqlCount, Is.EqualTo(1)); + + Cleanup(); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-13 16:35:33 UTC (rev 4291) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-13 19:31:17 UTC (rev 4292) @@ -377,6 +377,8 @@ <Compile Include="NHSpecificTest\NH1741\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1742\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1742\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1760\DomainClass.cs" /> + <Compile Include="NHSpecificTest\NH1760\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" /> <Compile Include="HQL\HQLFunctions.cs" /> <Compile Include="HQL\Human.cs" /> @@ -1768,6 +1770,7 @@ <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1760\Mappings.hbm.xml" /> <EmbeddedResource Include="MappingTest\Wicked.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1393\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1391\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-05-13 16:35:42
|
Revision: 4291 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4291&view=rev Author: ayenderahien Date: 2009-05-13 16:35:33 +0000 (Wed, 13 May 2009) Log Message: ----------- fixing issue with batcher only really batching when log is enabled Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 16:08:36 UTC (rev 4290) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 16:35:33 UTC (rev 4291) @@ -19,10 +19,7 @@ { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); - if (log.IsDebugEnabled) - { - currentBatchCommandsLog = new StringBuilder(); - } + currentBatchCommandsLog = new StringBuilder(); } public override int BatchSize @@ -35,23 +32,20 @@ { totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - if (log.IsDebugEnabled) + + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) { string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); + currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); } - else + else if (log.IsDebugEnabled) { log.Debug("Adding to batch:" + lineWithParameters); } - currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); } - else - { - Factory.Settings.SqlStatementLogger.LogCommand(batchUpdate, FormatStyle.Basic); - } currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate); if (currentBatch.CountOfCommands >= batchSize) { @@ -64,11 +58,11 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (log.IsDebugEnabled) + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) { if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); - else + else if (log.IsDebugEnabled) log.Debug(currentBatchCommandsLog.ToString()); currentBatchCommandsLog = new StringBuilder(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-05-13 16:09:03
|
Revision: 4290 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4290&view=rev Author: steverstrong Date: 2009-05-13 16:08:36 +0000 (Wed, 13 May 2009) Log Message: ----------- Cleaned up some code; a few renames, some reformatting, that sort of thing. No functional changes. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromReferenceNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeNodeStream.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlTreeAdapter.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IdentNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ImpliedFromElement.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/InLogicOperatorNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IntoClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/MethodNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/QueryNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlFragment.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SqlNode.cs trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/UpdateStatement.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/HqlSqlWalker.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -682,29 +682,9 @@ IASTNode CreateFromElement(string path, IASTNode pathNode, IASTNode alias, IASTNode propertyFetch) { - // try - { - FromElement fromElement = _currentFromClause.AddFromElement(path, alias); - fromElement.SetAllPropertyFetch(propertyFetch != null); - return fromElement; - } - /* - catch (Exception e) - { - // Try resolving as if it were a join - // TODO - clean this up! - try - { - pathNode = PreProcessPathForJoin(pathNode); - - CreateFromJoinElement(pathNode, alias, INNER, null, null, null); - return null; - } - catch (Exception) - { - throw e; - } - }*/ + FromElement fromElement = _currentFromClause.AddFromElement(path, alias); + fromElement.SetAllPropertyFetch(propertyFetch != null); + return fromElement; } private IASTNode PreProcessPathForJoin(IASTNode node) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/AssignmentSpecification.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -17,11 +17,11 @@ [CLSCompliant(false)] public class AssignmentSpecification { - private readonly IASTNode eq; - private readonly ISessionFactoryImplementor factory; - private readonly ISet<string> tableNames; - private readonly IParameterSpecification[] hqlParameters; - private SqlString sqlAssignmentString; + private readonly IASTNode _eq; + private readonly ISessionFactoryImplementor _factory; + private readonly ISet<string> _tableNames; + private readonly IParameterSpecification[] _hqlParameters; + private SqlString _sqlAssignmentString; public AssignmentSpecification(IASTNode eq, IQueryable persister) { @@ -30,8 +30,8 @@ throw new QueryException("assignment in set-clause not associated with equals"); } - this.eq = eq; - factory = persister.Factory; + _eq = eq; + _factory = persister.Factory; // Needed to bump this up to DotNode, because that is the only thing which currently // knows about the property-ref path in the correct format; it is either this, or @@ -63,30 +63,30 @@ { temp.Add(persister.GetSubclassTableName(persister.GetSubclassPropertyTableNumber(propertyPath))); } - tableNames = new ImmutableSet<string>(temp); + _tableNames = new ImmutableSet<string>(temp); if (rhs == null) { - hqlParameters = new IParameterSpecification[0]; + _hqlParameters = new IParameterSpecification[0]; } else if (IsParam(rhs)) { - hqlParameters = new[] { ((ParameterNode)rhs).HqlParameterSpecification }; + _hqlParameters = new[] { ((ParameterNode)rhs).HqlParameterSpecification }; } else { var parameterList = ASTUtil.CollectChildren(rhs, IsParam); - hqlParameters = new IParameterSpecification[parameterList.Count]; + _hqlParameters = new IParameterSpecification[parameterList.Count]; int i = 0; foreach (ParameterNode parameterNode in parameterList) { - hqlParameters[i++] = parameterNode.HqlParameterSpecification; + _hqlParameters[i++] = parameterNode.HqlParameterSpecification; } } } public bool AffectsTable(string tableName) { - return tableNames.Contains(tableName); + return _tableNames.Contains(tableName); } private static bool IsParam(IASTNode node) @@ -124,27 +124,27 @@ public IParameterSpecification[] Parameters { - get{return hqlParameters;} + get{return _hqlParameters;} } public SqlString SqlAssignmentFragment { get { - if (sqlAssignmentString == null) + if (_sqlAssignmentString == null) { try { - var gen = new SqlGenerator(factory, new CommonTreeNodeStream(eq)); + var gen = new SqlGenerator(_factory, new CommonTreeNodeStream(_eq)); gen.comparisonExpr(false); // false indicates to not generate parens around the assignment - sqlAssignmentString = gen.GetSQL(); + _sqlAssignmentString = gen.GetSQL(); } catch (Exception t) { throw new QueryException("cannot interpret set-clause assignment", t); } } - return sqlAssignmentString; + return _sqlAssignmentString; } } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BooleanLiteralNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -12,7 +12,7 @@ [CLSCompliant(false)] public class BooleanLiteralNode : LiteralNode, IExpectedTypeAwareNode { - private IType expectedType; + private IType _expectedType; public BooleanLiteralNode(IToken token) : base(token) { @@ -22,7 +22,7 @@ { get { - return expectedType ?? NHibernateUtil.Boolean; + return _expectedType ?? NHibernateUtil.Boolean; } set { @@ -46,8 +46,8 @@ */ public IType ExpectedType { - get { return expectedType; } - set { expectedType = value; } + get { return _expectedType; } + set { _expectedType = value; } } public override SqlString RenderText(ISessionFactoryImplementor sessionFactory) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DeleteStatement.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -11,7 +11,7 @@ [CLSCompliant(false)] public class DeleteStatement : AbstractRestrictableStatement { - private static readonly ILog log = LogManager.GetLogger(typeof(DeleteStatement)); + private static readonly ILog Log = LogManager.GetLogger(typeof(DeleteStatement)); public DeleteStatement(IToken token) : base(token) {} @@ -27,7 +27,7 @@ protected override ILog GetLog() { - return log; + return Log; } protected override int GetWhereClauseParentTokenType() Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/DotNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -20,18 +20,18 @@ [CLSCompliant(false)] public class DotNode : FromReferenceNode, ISelectExpression { - private static readonly ILog log = LogManager.GetLogger(typeof(DotNode)); + private static readonly ILog Log = LogManager.GetLogger(typeof(DotNode)); - private const int DEREF_UNKNOWN = 0; - private const int DEREF_ENTITY = 1; - private const int DEREF_COMPONENT = 2; - private const int DEREF_COLLECTION = 3; - private const int DEREF_PRIMITIVE = 4; - private const int DEREF_IDENTIFIER = 5; - private const int DEREF_JAVA_CONSTANT = 6; + private const int DerefUnknown = 0; + private const int DerefEntity = 1; + private const int DerefComponent = 2; + private const int DerefCollection = 3; + private const int DerefPrimitive = 4; + private const int DerefIdentifier = 5; + private const int DerefJavaConstant = 6; - public static bool UseThetaStyleImplicitJoins = false; - public static bool REGRESSION_STYLE_JOIN_SUPPRESSION = false; + public static bool UseThetaStyleImplicitJoins; + public static bool REGRESSION_STYLE_JOIN_SUPPRESSION; /// <summary> /// The full path, to the root alias of this dot node. @@ -41,7 +41,7 @@ /// <summary> /// The type of dereference that hapened (DEREF_xxx). /// </summary> - private int _dereferenceType = DEREF_UNKNOWN; + private int _dereferenceType = DerefUnknown; /// <summary> /// The identifier that is the name of the property. @@ -109,7 +109,7 @@ else { SqlNode rhs = (SqlNode) lhs.NextSibling; - _path = lhs.Path + "." + rhs.getOriginalText(); + _path = lhs.Path + "." + rhs.OriginalText; } } return _path; @@ -138,7 +138,7 @@ IType propertyType = PrepareLhs(); // Prepare the left hand side and get the data type. - DereferenceCollection( ( CollectionType ) propertyType, true, true, null, parent ); + DereferenceCollection( ( CollectionType ) propertyType, true, true, null); } public override void ResolveFirstChild() @@ -181,7 +181,7 @@ else { ResolveFirstChild(); - base.Resolve(generateJoin, implicitJoin); + Resolve(generateJoin, implicitJoin); } } @@ -226,7 +226,7 @@ { // The property is a collection... CheckLhsIsNotCollection(); - DereferenceCollection((CollectionType)propertyType, implicitJoin, false, classAlias, parent); + DereferenceCollection((CollectionType)propertyType, implicitJoin, false, classAlias); } else { @@ -235,13 +235,14 @@ { CheckLhsIsNotCollection(); } - _dereferenceType = DEREF_PRIMITIVE; + _dereferenceType = DerefPrimitive; InitText(); } IsResolved = true; } + public FromReferenceNode GetLhs() { FromReferenceNode lhs = ((FromReferenceNode)GetChild(0)); @@ -252,7 +253,7 @@ return lhs; } - public IType getDataType() + public IType GetDataType() { if (DataType == null) { @@ -265,20 +266,21 @@ // If the lhs is a collection, use CollectionPropertyMapping IType propertyType = fromElement.GetPropertyType(_propertyName, _propertyPath); - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("getDataType() : " + _propertyPath + " -> " + propertyType); + Log.Debug("getDataType() : " + _propertyPath + " -> " + propertyType); } DataType = propertyType; } + return DataType; } public void SetResolvedConstant(string text) { _path = text; - _dereferenceType = DEREF_JAVA_CONSTANT; + _dereferenceType = DerefJavaConstant; IsResolved = true; // Don't resolve the node again. } @@ -288,13 +290,13 @@ return new QueryException("illegal attempt to dereference collection [" + lhsPath + "] with element property reference [" + propertyName + "]"); } - private void DereferenceCollection(CollectionType collectionType, bool implicitJoin, bool indexed, string classAlias, IASTNode parent) + private void DereferenceCollection(CollectionType collectionType, bool implicitJoin, bool indexed, string classAlias) { - _dereferenceType = DEREF_COLLECTION; + _dereferenceType = DerefCollection; string role = collectionType.Role; //foo.bars.size (also handles deprecated stuff like foo.bars.maxelement for backwardness) - IASTNode sibling = this.NextSibling; + IASTNode sibling = NextSibling; bool isSizeProperty = sibling != null && CollectionProperties.IsAnyCollectionProperty( sibling.Text ); if (isSizeProperty) @@ -330,9 +332,9 @@ ); FromElement elem = factory.CreateCollection( queryableCollection, role, _joinType, _fetch, indexed ); - if ( log.IsDebugEnabled ) + if ( Log.IsDebugEnabled ) { - log.Debug( "dereferenceCollection() : Created new FROM element for " + propName + " : " + elem ); + Log.Debug( "dereferenceCollection() : Created new FROM element for " + propName + " : " + elem ); } SetImpliedJoin( elem ); @@ -422,9 +424,9 @@ { // special shortcut for id properties, skip the join! // this must only occur at the _end_ of a path expression - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("dereferenceShortcut() : property " + + Log.Debug("dereferenceShortcut() : property " + propertyName + " in " + FromElement.ClassName + " does not require a join."); } @@ -434,7 +436,7 @@ // Set the text for the parent. if (dotParent != null) { - dotParent._dereferenceType = DEREF_IDENTIFIER; + dotParent._dereferenceType = DerefIdentifier; dotParent.Text = Text; dotParent._columns = GetColumns(); } @@ -442,10 +444,10 @@ private void DereferenceEntityJoin(string classAlias, EntityType propertyType, bool impliedJoin, IASTNode parent) { - _dereferenceType = DEREF_ENTITY; - if ( log.IsDebugEnabled ) + _dereferenceType = DerefEntity; + if ( Log.IsDebugEnabled ) { - log.Debug( "dereferenceEntityJoin() : generating join for " + _propertyName + " in " + Log.Debug( "dereferenceEntityJoin() : generating join for " + _propertyName + " in " + FromElement.ClassName + " " + ( ( classAlias == null ) ? "{no alias}" : "(" + classAlias + ")" ) + " parent = " + ASTUtil.GetDebugstring( parent ) @@ -586,9 +588,9 @@ { if (IsCorrelatedSubselect) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug(methodName + "() : correlated subquery"); + Log.Debug(methodName + "() : correlated subquery"); } } } @@ -612,12 +614,12 @@ { FromReferenceNode lhs = GetLhs(); lhs.PrepareForDot( _propertyName ); - return getDataType(); + return GetDataType(); } private void DereferenceComponent(IASTNode parent) { - _dereferenceType = DEREF_COMPONENT; + _dereferenceType = DerefComponent; SetPropertyNameAndPath(parent); } @@ -631,16 +633,16 @@ _propertyName = rhs.Text; _propertyPath = _propertyPath + "." + _propertyName; // Append the new property name onto the unresolved path. dotNode._propertyPath = _propertyPath; - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("Unresolved property path is now '" + dotNode._propertyPath + "'"); + Log.Debug("Unresolved property path is now '" + dotNode._propertyPath + "'"); } } else { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("terminal propertyPath = [" + _propertyPath + "]"); + Log.Debug("terminal propertyPath = [" + _propertyPath + "]"); } } } @@ -693,7 +695,7 @@ else { Resolve(true, false); - IType type = getDataType(); + IType type = GetDataType(); if (type.IsEntityType) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -16,10 +16,10 @@ [CLSCompliant(false)] public class FromClause : HqlSqlWalkerNode, IDisplayableNode { - private static readonly ILog log = LogManager.GetLogger(typeof(FromClause)); - public static int ROOT_LEVEL = 1; + private static readonly ILog Log = LogManager.GetLogger(typeof(FromClause)); + private const int RootLevel = 1; - private int _level = ROOT_LEVEL; + private int _level = RootLevel; /// <summary> /// Counts the from elements as they are added. @@ -124,9 +124,9 @@ public void AddJoinByPathMap(string path, FromElement destination) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("addJoinByPathMap() : " + path + " -> " + destination); + Log.Debug("addJoinByPathMap() : " + path + " -> " + destination); } _fromElementsByPath.Add(path, destination); @@ -134,9 +134,9 @@ public void AddCollectionJoinFromElementByPath(string path, FromElement destination) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("addCollectionJoinFromElementByPath() : " + path + " -> " + destination); + Log.Debug("addCollectionJoinFromElementByPath() : " + path + " -> " + destination); } _collectionJoinFromElementsByPath.Add(path, destination); // Add the new node to the map so that we don't create it twice. } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -16,7 +16,7 @@ [CLSCompliant(false)] public class FromElement : HqlSqlWalkerNode, IDisplayableNode, IParameterContainer { - private static readonly ILog log = LogManager.GetLogger(typeof(FromElement)); + private static readonly ILog Log = LogManager.GetLogger(typeof(FromElement)); private bool _isAllPropertyFetch; private FromElementType _elementType; @@ -27,17 +27,15 @@ private FromClause _fromClause; private string[] _columns; private FromElement _origin; - private bool _manyToMany; private bool _useFromFragment; private bool _useWhereFragment = true; private bool _includeSubclasses = true; - private List<FromElement> _destinations = new List<FromElement>(); + private readonly List<FromElement> _destinations = new List<FromElement>(); private bool _dereferencedBySubclassProperty; private bool _dereferencedBySuperclassProperty; private bool _collectionJoin; private string _role; - private int sequence = -1; - private bool initialized = false; + private bool _initialized; private string _withClauseFragment; private string _withClauseJoinAlias; private bool _filter; @@ -98,7 +96,7 @@ public bool Filter { - set { _filter = true; } + set { _filter = value; } } public bool IsFilter @@ -307,7 +305,7 @@ return _elementType.RenderPropertySelect(size, k, IsAllPropertyFetch); } - public override SqlString RenderText(NHibernate.Engine.ISessionFactoryImplementor sessionFactory) + public override SqlString RenderText(Engine.ISessionFactoryImplementor sessionFactory) { return SqlString.Parse(Text); } @@ -351,9 +349,9 @@ { if (IsDereferencedBySuperclassOrSubclassProperty) { - if (!_includeSubclasses && log.IsInfoEnabled) + if (!_includeSubclasses && Log.IsInfoEnabled) { - log.Info("attempt to disable subclass-inclusions", new Exception("stack-trace source")); + Log.Info("attempt to disable subclass-inclusions", new Exception("stack-trace source")); } } _includeSubclasses = value; @@ -485,9 +483,9 @@ { Declarer propertyDeclarer = persister.GetSubclassPropertyDeclarer(propertyName); - if (log.IsInfoEnabled) + if (Log.IsInfoEnabled) { - log.Info("handling property dereference [" + persister.EntityName + " (" + ClassAlias + ") -> " + propertyName + " (" + propertyDeclarer + ")]"); + Log.Info("handling property dereference [" + persister.EntityName + " (" + ClassAlias + ") -> " + propertyName + " (" + propertyDeclarer + ")]"); } if (propertyDeclarer == Declarer.SubClass) { @@ -511,7 +509,6 @@ public void SetOrigin(FromElement origin, bool manyToMany) { _origin = origin; - _manyToMany = manyToMany; origin.AddDestination(this); if (origin.FromClause == FromClause) @@ -551,9 +548,9 @@ { if (IsDereferencedBySuperclassOrSubclassProperty) { - if (!includeSubclasses && log.IsInfoEnabled) + if (!includeSubclasses && Log.IsInfoEnabled) { - log.Info("attempt to disable subclass-inclusions", new Exception("stack-trace source")); + Log.Info("attempt to disable subclass-inclusions", new Exception("stack-trace source")); } } _includeSubclasses = includeSubclasses; @@ -571,7 +568,7 @@ public void InitializeCollection(FromClause fromClause, string classAlias, string tableAlias) { DoInitialize(fromClause, tableAlias, null, classAlias, null, null); - initialized = true; + _initialized = true; } public void InitializeEntity(FromClause fromClause, @@ -582,13 +579,12 @@ string tableAlias) { DoInitialize(fromClause, tableAlias, className, classAlias, persister, type); - this.sequence = fromClause.NextFromElementCounter(); - initialized = true; + _initialized = true; } public void CheckInitialized() { - if (!initialized) + if (!_initialized) { throw new InvalidOperationException("FromElement has not been initialized!"); } @@ -632,7 +628,7 @@ private void DoInitialize(FromClause fromClause, string tableAlias, string className, string classAlias, IEntityPersister persister, EntityType type) { - if (initialized) + if (_initialized) { throw new InvalidOperationException("Already initialized!!"); } @@ -645,9 +641,9 @@ // Register the FromElement with the FROM clause, now that we have the names and aliases. fromClause.RegisterFromElement(this); - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug(fromClause + " : " + className + " (" + Log.Debug(fromClause + " : " + className + " (" + (classAlias ?? "no alias") + ") -> " + tableAlias); } } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementFactory.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -13,7 +13,7 @@ [CLSCompliant(false)] public class FromElementFactory { - private static readonly ILog log = LogManager.GetLogger(typeof(FromElementFactory)); + private static readonly ILog Log = LogManager.GetLogger(typeof(FromElementFactory)); private readonly FromClause _fromClause; private readonly FromElement _origin; @@ -107,9 +107,9 @@ FromElement parentFromElement, string classAlias) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("createFromElementInSubselect() : path = " + path); + Log.Debug("createFromElementInSubselect() : path = " + path); } // Create an DotNode AST for the path and resolve it. @@ -119,23 +119,16 @@ // If the first identifier in the path referrs to the class alias (not the class name), then this // is a correlated subselect. If it's a correlated sub-select, use the existing table alias. Otherwise // generate a new one. - string tableAlias; bool correlatedSubselect = pathAlias == parentFromElement.ClassAlias; - if (correlatedSubselect) - { - tableAlias = fromElement.TableAlias; - } - else - { - tableAlias = null; - } + + string tableAlias = correlatedSubselect ? fromElement.TableAlias : null; // If the from element isn't in the same clause, create a new from element. if (fromElement.FromClause != _fromClause) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("createFromElementInSubselect() : creating a new FROM element..."); + Log.Debug("createFromElementInSubselect() : creating a new FROM element..."); } fromElement = CreateFromElement(entityPersister); @@ -148,9 +141,9 @@ tableAlias ); } - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("createFromElementInSubselect() : " + path + " -> " + fromElement); + Log.Debug("createFromElementInSubselect() : " + path + " -> " + fromElement); } return fromElement; @@ -234,8 +227,6 @@ public FromElement CreateElementJoin(IQueryableCollection queryableCollection) { - FromElement elem; - _implied = true; //TODO: always true for now, but not if we later decide to support elements() in the from clause _inElementsFunction = true; @@ -249,21 +240,19 @@ _queryableCollection = queryableCollection; SessionFactoryHelperExtensions sfh = _fromClause.SessionFactoryHelper; - FromElement destination = null; - string tableAlias = null; IEntityPersister entityPersister = queryableCollection.ElementPersister; - tableAlias = _fromClause.AliasGenerator.CreateName(entityPersister.EntityName); + string tableAlias = _fromClause.AliasGenerator.CreateName(entityPersister.EntityName); string associatedEntityName = entityPersister.EntityName; IEntityPersister targetEntityPersister = sfh.RequireClassPersister(associatedEntityName); // Create the FROM element for the target (the elements of the collection). - destination = CreateAndAddFromElement( - associatedEntityName, - _classAlias, - targetEntityPersister, - (EntityType)queryableCollection.ElementType, - tableAlias - ); + FromElement destination = CreateAndAddFromElement( + associatedEntityName, + _classAlias, + targetEntityPersister, + (EntityType)queryableCollection.ElementType, + tableAlias + ); // If the join is implied, then don't include sub-classes on the element. if (_implied) @@ -284,9 +273,8 @@ IAssociationType elementAssociationType = sfh.GetElementAssociationType(type); // Create the join element under the from element. - JoinType joinType = JoinType.InnerJoin; - JoinSequence joinSequence = sfh.CreateJoinSequence(_implied, elementAssociationType, tableAlias, joinType, targetColumns); - elem = InitializeJoin(_path, destination, joinSequence, targetColumns, _origin, false); + JoinSequence joinSequence = sfh.CreateJoinSequence(_implied, elementAssociationType, tableAlias, JoinType.InnerJoin, targetColumns); + FromElement elem = InitializeJoin(_path, destination, joinSequence, targetColumns, _origin, false); elem.UseFromFragment = true; // The associated entity is implied, but it must be included in the FROM. elem.CollectionTableAlias = roleAlias; // The collection alias is the role. return elem; @@ -310,9 +298,9 @@ // multi-table entity if (_implied && !elem.UseFromFragment) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("createEntityJoin() : Implied entity join"); + Log.Debug("createEntityJoin() : Implied entity join"); } elem.UseFromFragment = true; } @@ -355,9 +343,9 @@ // Get the class name of the associated entity. if (_queryableCollection.IsOneToMany) { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("createEntityAssociation() : One to many - path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); + Log.Debug("createEntityAssociation() : One to many - path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); } JoinSequence joinSequence = CreateJoinSequence(roleAlias, joinType); @@ -366,9 +354,9 @@ } else { - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("createManyToMany() : path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); + Log.Debug("createManyToMany() : path = " + _path + " role = " + role + " associatedEntityName = " + associatedEntityName); } elem = CreateManyToMany(role, associatedEntityName, @@ -491,7 +479,7 @@ { FromReferenceNode pathNode = (FromReferenceNode)PathHelper.ParsePath(path, _fromClause.ASTFactory); - pathNode.RecursiveResolve(FromReferenceNode.ROOT_LEVEL, // This is the root level node. + pathNode.RecursiveResolve(FromReferenceNode.RootLevel, // This is the root level node. false, // Generate an explicit from clause at the root. classAlias, null Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromElementType.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -19,11 +19,11 @@ [CLSCompliant(false)] public class FromElementType { - private static readonly ILog log = LogManager.GetLogger(typeof(FromElementType)); + private static readonly ILog Log = LogManager.GetLogger(typeof(FromElementType)); - private FromElement _fromElement; - private IEntityPersister _persister; - private EntityType _entityType; + private readonly FromElement _fromElement; + private readonly IEntityPersister _persister; + private readonly EntityType _entityType; private IQueryableCollection _queryableCollection; private CollectionPropertyMapping _collectionPropertyMapping; private JoinSequence _joinSequence; @@ -170,7 +170,7 @@ public string RenderScalarIdentifierSelect(int i) { CheckInitialized(); - string[] cols = GetPropertyMapping(NHibernate.Persister.Entity.EntityPersister.EntityID).ToColumns(TableAlias, NHibernate.Persister.Entity.EntityPersister.EntityID); + string[] cols = GetPropertyMapping(Persister.Entity.EntityPersister.EntityID).ToColumns(TableAlias, Persister.Entity.EntityPersister.EntityID); StringBuilder buf = new StringBuilder(); // For property references generate <tablealias>.<columnname> as <projectionalias> for (int j = 0; j < cols.Length; j++) @@ -302,7 +302,7 @@ if (_queryableCollection.ElementType.IsComponentType) { // Collection of components. - if (propertyName == NHibernate.Persister.Entity.EntityPersister.EntityID) + if (propertyName == Persister.Entity.EntityPersister.EntityID) { return (IPropertyMapping)_queryableCollection.OwnerEntityPersister; } @@ -394,11 +394,11 @@ enabledFilters, propertyMapping.ToColumns(tableAlias, path) ); - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("toColumns(" + tableAlias + "," + path + ") : subquery = " + subquery); + Log.Debug("toColumns(" + tableAlias + "," + path + ") : subquery = " + subquery); } - return new string[] { "(" + subquery + ")" }; + return new [] { "(" + subquery + ")" }; } else { @@ -429,15 +429,15 @@ // B) otherwise, we need to use the persister's // table name as the column qualification // 2) otherwise (not correlated), use the given alias - if (isCorrelation()) + if (IsCorrelation) { - if (isMultiTable()) + if (IsMultiTable) { return propertyMapping.ToColumns(tableAlias, path); } else { - return propertyMapping.ToColumns(extractTableName(), path); + return propertyMapping.ToColumns(ExtractTableName(), path); } } else @@ -448,7 +448,7 @@ else { string[] columns = propertyMapping.ToColumns(path); - log.Info("Using non-qualified column reference [" + path + " -> (" + ArrayHelper.ToString(columns) + ")]"); + Log.Info("Using non-qualified column reference [" + path + " -> (" + ArrayHelper.ToString(columns) + ")]"); return columns; } } @@ -470,21 +470,27 @@ _fromElement.CheckInitialized(); } - private bool isCorrelation() + private bool IsCorrelation { - FromClause top = _fromElement.Walker.GetFinalFromClause(); - return _fromElement.FromClause != _fromElement.Walker.CurrentFromClause && - _fromElement.FromClause == top; + get + { + FromClause top = _fromElement.Walker.GetFinalFromClause(); + return _fromElement.FromClause != _fromElement.Walker.CurrentFromClause && + _fromElement.FromClause == top; + } } - private bool isMultiTable() + private bool IsMultiTable { - // should be safe to only ever expect EntityPersister references here - return _fromElement.Queryable != null && - _fromElement.Queryable.IsMultiTable; + get + { + // should be safe to only ever expect EntityPersister references here + return _fromElement.Queryable != null && + _fromElement.Queryable.IsMultiTable; + } } - private string extractTableName() + private string ExtractTableName() { // should be safe to only ever expect EntityPersister references here return _fromElement.Queryable.TableName; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromReferenceNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromReferenceNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/FromReferenceNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -8,9 +8,9 @@ [CLSCompliant(false)] public abstract class FromReferenceNode : AbstractSelectExpression, IResolvableNode, IDisplayableNode, IPathNode { - private static readonly ILog log = LogManager.GetLogger(typeof(FromReferenceNode)); + private static readonly ILog Log = LogManager.GetLogger(typeof(FromReferenceNode)); - public static int ROOT_LEVEL = 0; + public const int RootLevel = 0; private FromElement _fromElement; private bool _resolved; @@ -35,9 +35,9 @@ set { _resolved = true; - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug("Resolved : " + Path + " -> " + Text); + Log.Debug("Resolved : " + Path + " -> " + Text); } } } @@ -71,7 +71,7 @@ public virtual string Path { - get { return getOriginalText(); } + get { return OriginalText; } } public void RecursiveResolve(int level, bool impliedAtRoot, string classAlias, IASTNode parent) @@ -87,7 +87,7 @@ ResolveFirstChild(); bool impliedJoin = true; - if ( level == ROOT_LEVEL && !impliedAtRoot ) + if ( level == RootLevel && !impliedAtRoot ) { impliedJoin = false; } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeAdapter.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -170,10 +170,8 @@ return dupped; } - else - { - throw new NotImplementedException(); - } + + throw new NotImplementedException(); } private void Initialise(object node) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeNodeStream.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeNodeStream.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlSqlWalkerTreeNodeStream.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -61,33 +61,32 @@ // We are at the end return 0; } - else if (nodes[parentIndex + 1] != down) + + if (nodes[parentIndex + 1] != down) { // Next node is not a DOWN node, so we have no children return 0; } - else + + // Count the DOWNs & UPs + int downCount = 0; + int index = 1; + do { - // Count the DOWNs & UPs - int downCount = 0; - int index = 1; - do + if (nodes[parentIndex + index] == down) { - if (nodes[parentIndex + index] == down) - { - downCount++; - } - else if (nodes[parentIndex + index] == up) - { - downCount--; - } + downCount++; + } + else if (nodes[parentIndex + index] == up) + { + downCount--; + } - index++; - - } while (downCount > 0); + index++; + + } while (downCount > 0); - return index - 1; - } + return index - 1; } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlTreeAdapter.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlTreeAdapter.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/HqlTreeAdapter.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -189,10 +189,8 @@ return dupped; } - else - { - return base.DupNode(t); - } + + return base.DupNode(t); } void Initialise(object node) Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IdentNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IdentNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IdentNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -14,10 +14,10 @@ [CLSCompliant(false)] public class IdentNode : FromReferenceNode, ISelectExpression { - private static int UNKNOWN = 0; - private static int PROPERTY_REF = 1; - private static int COMPONENT_REF = 2; - private bool _nakedPropertyRef = false; + private const int Unknown = 0; + private const int PropertyRef = 1; + private const int ComponentRef = 2; + private bool _nakedPropertyRef; public IdentNode(IToken token) : base(token) { @@ -81,7 +81,7 @@ throw new InvalidOperationException(); } - string propertyName = getOriginalText(); + string propertyName = OriginalText; if (!DataType.IsCollectionType) { throw new SemanticException("Collection expected; [" + propertyName + "] does not refer to a collection property"); @@ -92,21 +92,18 @@ string role = type.Role; IQueryableCollection queryableCollection = SessionFactoryHelper.RequireQueryableCollection(role); - string alias = null; // DotNode uses null here... string columnTableAlias = FromElement.TableAlias; - JoinType joinType = JoinType.InnerJoin; - bool fetch = false; FromElementFactory factory = new FromElementFactory( Walker.CurrentFromClause, FromElement, propertyName, - alias, + null, FromElement.ToColumns(columnTableAlias, propertyName, false), true ); - FromElement elem = factory.CreateCollection(queryableCollection, role, joinType, fetch, true); + FromElement elem = factory.CreateCollection(queryableCollection, role, JoinType.InnerJoin, false, true); FromElement = elem; Walker.AddQuerySpaces(queryableCollection.CollectionSpaces); // Always add the collection's query spaces. } @@ -128,7 +125,7 @@ DotNode dot = (DotNode)parent; if (parent.GetFirstChild() == this) { - if (ResolveAsNakedComponentPropertyRefLHS(dot)) + if (ResolveAsNakedComponentPropertyRefLhs(dot)) { // we are the LHS of the DOT representing a naked comp-prop-ref IsResolved = true; @@ -136,7 +133,7 @@ } else { - if (ResolveAsNakedComponentPropertyRefRHS(dot)) + if (ResolveAsNakedComponentPropertyRefRhs(dot)) { // we are the RHS of the DOT representing a naked comp-prop-ref IsResolved = true; @@ -146,12 +143,12 @@ else { int result = ResolveAsNakedPropertyRef(); - if (result == PROPERTY_REF) + if (result == PropertyRef) { // we represent a naked (simple) prop-ref IsResolved = true; } - else if (result == COMPONENT_REF) + else if (result == ComponentRef) { // EARLY EXIT!!! return so the resolve call explicitly coming from DotNode can // resolve this... @@ -184,25 +181,25 @@ if (fromElement == null) { - return UNKNOWN; + return Unknown; } IQueryable persister = fromElement.Queryable; if (persister == null) { - return UNKNOWN; + return Unknown; } IType propertyType = GetNakedPropertyType(fromElement); if (propertyType == null) { // assume this ident's text does *not* refer to a property on the given persister - return UNKNOWN; + return Unknown; } if ((propertyType.IsComponentType || propertyType.IsAssociationType)) { - return COMPONENT_REF; + return ComponentRef; } FromElement = fromElement; @@ -220,10 +217,10 @@ DataType = propertyType; _nakedPropertyRef = true; - return PROPERTY_REF; + return PropertyRef; } - private bool ResolveAsNakedComponentPropertyRefLHS(DotNode parent) + private bool ResolveAsNakedComponentPropertyRefLhs(DotNode parent) { FromElement fromElement = LocateSingleFromElement(); if (fromElement == null) @@ -235,15 +232,15 @@ if (componentType == null) { - throw new QueryException("Unable to resolve path [" + parent.Path + "], unexpected token [" + getOriginalText() + "]"); + throw new QueryException("Unable to resolve path [" + parent.Path + "], unexpected token [" + OriginalText + "]"); } if (!componentType.IsComponentType) { - throw new QueryException("Property '" + getOriginalText() + "' is not a component. Use an alias to reference associations or collections."); + throw new QueryException("Property '" + OriginalText + "' is not a component. Use an alias to reference associations or collections."); } IType propertyType ; // used to set the type of the parent dot node - string propertyPath = Text + "." + this.NextSibling.Text; + string propertyPath = Text + "." + NextSibling.Text; try { // check to see if our "propPath" actually @@ -263,7 +260,7 @@ return true; } - private bool ResolveAsNakedComponentPropertyRefRHS(DotNode parent) + private bool ResolveAsNakedComponentPropertyRefRhs(DotNode parent) { FromElement fromElement = LocateSingleFromElement(); if (fromElement == null) @@ -302,7 +299,7 @@ return null; } - string property = getOriginalText(); + string property = OriginalText; IType propertyType = null; try Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ImpliedFromElement.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ImpliedFromElement.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ImpliedFromElement.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -7,8 +7,8 @@ [CLSCompliant(false)] public class ImpliedFromElement : FromElement { - private bool _impliedInFromClause = false; - private bool _inProjectionList = false; + private bool _impliedInFromClause; + private bool _inProjectionList; public ImpliedFromElement(IToken token) : base(token) { Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/InLogicOperatorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/InLogicOperatorNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/InLogicOperatorNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -16,9 +16,9 @@ { } - public IASTNode getInList() + public IASTNode InList { - return RightHandOperand; + get { return RightHandOperand; } } public override void Initialize() @@ -29,7 +29,7 @@ throw new SemanticException("left-hand operand of in operator was null"); } - IASTNode inList = getInList(); + IASTNode inList = InList; if (inList == null) { throw new SemanticException("right-hand operand of in operator was null"); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IndexNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -19,7 +19,7 @@ [CLSCompliant(false)] public class IndexNode : FromReferenceNode { - private static readonly ILog log = LogManager.GetLogger(typeof(IndexNode)); + private static readonly ILog Log = LogManager.GetLogger(typeof(IndexNode)); public IndexNode(IToken token) : base(token) { @@ -49,7 +49,7 @@ IType type = collectionNode.DataType; if ( !type.IsCollectionType ) { - throw new SemanticException( "The [] operator cannot be applied to type " + type.ToString() ); + throw new SemanticException( "The [] operator cannot be applied to type " + type); } string collectionRole = ( ( CollectionType ) type ).Role; @@ -70,17 +70,17 @@ { FromElementFactory factory = new FromElementFactory( fromClause, fromElement, path ); elem = factory.CreateCollectionElementsJoin( queryableCollection, elementTable ); - if ( log.IsDebugEnabled ) + if ( Log.IsDebugEnabled ) { - log.Debug( "No FROM element found for the elements of collection join path " + path + Log.Debug( "No FROM element found for the elements of collection join path " + path + ", created " + elem ); } } else { - if ( log.IsDebugEnabled ) + if ( Log.IsDebugEnabled ) { - log.Debug( "FROM element found for collection join path " + path ); + Log.Debug( "FROM element found for collection join path " + path ); } } @@ -170,9 +170,9 @@ FromReferenceNode collectionNode = ( FromReferenceNode ) GetChild(0); String path = collectionNode.Path + "[]." + propertyName; - if (log.IsDebugEnabled) + if (Log.IsDebugEnabled) { - log.Debug( "Creating join for many-to-many elements for " + path ); + Log.Debug( "Creating join for many-to-many elements for " + path ); } FromElementFactory factory = new FromElementFactory( fromElement.FromClause, fromElement, path ); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IntoClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IntoClause.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/IntoClause.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -18,13 +18,13 @@ [CLSCompliant(false)] public class IntoClause : HqlSqlWalkerNode, IDisplayableNode { - private IQueryable persister; - private String columnSpec = string.Empty; - private IType[] types; + private IQueryable _persister; + private String _columnSpec = string.Empty; + private IType[] _types; - private bool discriminated; - private bool explicitIdInsertion; - private bool explicitVersionInsertion; + private bool _discriminated; + private bool _explicitIdInsertion; + private bool _explicitVersionInsertion; public IntoClause(IToken token) : base(token) @@ -38,13 +38,13 @@ throw new QueryException("cannot insert into abstract class (no table)"); } - this.persister = persister; + _persister = persister; InitializeColumns(); if (Walker.SessionFactoryHelper.HasPhysicalDiscriminatorColumn(persister)) { - discriminated = true; - columnSpec += ", " + persister.DiscriminatorColumnName; + _discriminated = true; + _columnSpec += ", " + persister.DiscriminatorColumnName; } ResetText(); @@ -52,53 +52,53 @@ private void ResetText() { - Text = "into " + TableName + " ( " + columnSpec + " )"; + Text = "into " + TableName + " ( " + _columnSpec + " )"; } public string TableName { - get { return persister.GetSubclassTableName(0); } + get { return _persister.GetSubclassTableName(0); } } public IQueryable Queryable { - get { return persister; } + get { return _persister; } } public string EntityName { - get { return persister.EntityName; } + get { return _persister.EntityName; } } public IType[] InsertionTypes { - get { return types; } + get { return _types; } } public bool IsDiscriminated { - get { return discriminated; } + get { return _discriminated; } } public bool IsExplicitIdInsertion { - get { return explicitIdInsertion; } + get { return _explicitIdInsertion; } } public bool IsExplicitVersionInsertion { - get { return explicitVersionInsertion; } + get { return _explicitVersionInsertion; } } public void PrependIdColumnSpec() { - columnSpec = persister.IdentifierColumnNames[0] + ", " + columnSpec; + _columnSpec = _persister.IdentifierColumnNames[0] + ", " + _columnSpec; ResetText(); } public void PrependVersionColumnSpec() { - columnSpec = persister.GetPropertyColumnNames(persister.VersionProperty)[0] + ", " + columnSpec; + _columnSpec = _persister.GetPropertyColumnNames(_persister.VersionProperty)[0] + ", " + _columnSpec; ResetText(); } @@ -106,17 +106,17 @@ { IType[] selectTypes = selectClause.QueryReturnTypes; - if (selectTypes.Length != types.Length) + if (selectTypes.Length != _types.Length) { throw new QueryException("number of select types did not match those for insert"); } - for (int i = 0; i < types.Length; i++) + for (int i = 0; i < _types.Length; i++) { - if (!AreCompatible(types[i], selectTypes[i])) + if (!AreCompatible(_types[i], selectTypes[i])) { throw new QueryException( - "insertion type [" + types[i] + "] and selection type [" + + "insertion type [" + _types[i] + "] and selection type [" + selectTypes[i] + "] at position " + i + " are not compatible" ); } @@ -135,7 +135,7 @@ buf.Append("IntoClause{"); buf.Append("entityName=").Append(EntityName); buf.Append(",tableName=").Append(TableName); - buf.Append(",columns={").Append(columnSpec).Append("}"); + buf.Append(",columns={").Append(_columnSpec).Append("}"); buf.Append("}"); return buf.ToString(); } @@ -145,8 +145,8 @@ IASTNode propertySpec = GetFirstChild(); var ts = new List<IType>(); VisitPropertySpecNodes(propertySpec.GetFirstChild(), ts); - types = ts.ToArray(); - columnSpec = columnSpec.Substring(0, columnSpec.Length - 2); + _types = ts.ToArray(); + _columnSpec = _columnSpec.Substring(0, _columnSpec.Length - 2); } private void VisitPropertySpecNodes(IASTNode propertyNode, ICollection<IType> types) @@ -171,22 +171,22 @@ throw new QueryException("INSERT statements cannot refer to superclass/joined properties [" + name + "]"); } - if (name == persister.IdentifierPropertyName) + if (name == _persister.IdentifierPropertyName) { - explicitIdInsertion = true; + _explicitIdInsertion = true; } - if (persister.IsVersioned) + if (_persister.IsVersioned) { - if (name == persister.PropertyNames[persister.VersionProperty]) + if (name == _persister.PropertyNames[_persister.VersionProperty]) { - explicitVersionInsertion = true; + _explicitVersionInsertion = true; } } - string[] columnNames = persister.ToColumns(name); + string[] columnNames = _persister.ToColumns(name); RenderColumns(columnNames); - types.Add(persister.ToType(name)); + types.Add(_persister.ToType(name)); // visit width-first, then depth VisitPropertySpecNodes(propertyNode.NextSibling, types); @@ -197,7 +197,7 @@ { for (int i = 0; i < columnNames.Length; i++) { - columnSpec += columnNames[i] + ", "; + _columnSpec += columnNames[i] + ", "; } } @@ -214,7 +214,7 @@ // // we may want to disallow it for discrim-subclass just for // consistency-sake (currently does not work anyway)... - return persister.GetSubclassPropertyTableNumber(propertyName) != 0; + return _persister.GetSubclassPropertyTableNumber(propertyName) != 0; } /// <summary> Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -1,5 +1,4 @@ using System; -using System.Threading; using Antlr.Runtime; using NHibernate.Engine; using NHibernate.Hql.Ast.ANTLR.Util; Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/MethodNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/MethodNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/MethodNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -16,7 +16,7 @@ [CLSCompliant(false)] public class MethodNode : AbstractSelectExpression, ISelectExpression { - private static readonly ILog log = LogManager.GetLogger(typeof(MethodNode)); + private static readonly ILog Log = LogManager.GetLogger(typeof(MethodNode)); private string[] _selectColumns; private string _methodName; @@ -151,15 +151,15 @@ SqlNode expr = ( SqlNode ) path; IType type = expr.DataType; - if ( log.IsDebugEnabled ) + if ( Log.IsDebugEnabled ) { - log.Debug( "collectionProperty() : name=" + name + " type=" + type ); + Log.Debug( "collectionProperty() : name=" + name + " type=" + type ); } ResolveCollectionProperty( expr ); } - private void PrepareAnyImplicitJoins(DotNode dotNode) + private static void PrepareAnyImplicitJoins(DotNode dotNode) { if ( dotNode.GetLhs() is DotNode ) { @@ -181,7 +181,7 @@ IQueryableCollection queryableCollection = collectionFromElement.QueryableCollection; String path = collectionNode.Path + "[]." + propertyName; - log.Debug("Creating elements for " + path); + Log.Debug("Creating elements for " + path); _fromElement = collectionFromElement; if (!collectionFromElement.IsCollectionOfValuesOrComponents) @@ -203,14 +203,7 @@ if (exprList != null) { - if (_methodName == "iif") - { - child = exprList.GetChild(1); - } - else - { - child = exprList.GetChild(0); - } + child = _methodName == "iif" ? exprList.GetChild(1) : exprList.GetChild(0); } DataType = SessionFactoryHelper.FindFunctionReturnType(_methodName, child); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/ParameterNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -1,5 +1,4 @@ using System; -using System.Text; using Antlr.Runtime; using NHibernate.Engine; using NHibernate.Param; @@ -49,7 +48,7 @@ public override SqlString RenderText(ISessionFactoryImplementor sessionFactory) { - int count = 0; + int count; if (ExpectedType != null && (count = ExpectedType.GetColumnSpan(sessionFactory)) > 1) { SqlStringBuilder buffer = new SqlStringBuilder(); Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/QueryNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/QueryNode.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/QueryNode.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -9,7 +9,7 @@ [CLSCompliant(false)] public class QueryNode : AbstractRestrictableStatement, ISelectExpression { - private static readonly ILog log = LogManager.GetLogger(typeof(QueryNode)); + private static readonly ILog Log = LogManager.GetLogger(typeof(QueryNode)); private OrderByClause _orderByClause; @@ -19,7 +19,7 @@ protected override ILog GetLog() { - return log; + return Log; } protected override int GetWhereClauseParentTokenType() @@ -89,17 +89,13 @@ // if there is no order by, make one if (_orderByClause == null) { - log.Debug( "getOrderByClause() : Creating a new ORDER BY clause" ); + Log.Debug( "getOrderByClause() : Creating a new ORDER BY clause" ); _orderByClause = (OrderByClause) Walker.ASTFactory.CreateNode(HqlSqlWalker.ORDER, "ORDER"); // Find the WHERE; if there is no WHERE, find the FROM... - IASTNode prevSibling = ASTUtil.FindTypeInChildren(this, HqlSqlWalker.WHERE); + IASTNode prevSibling = ASTUtil.FindTypeInChildren(this, HqlSqlWalker.WHERE) ?? + ASTUtil.FindTypeInChildren(this, HqlSqlWalker.FROM); - if ( prevSibling == null ) - { - prevSibling = ASTUtil.FindTypeInChildren(this, HqlSqlWalker.FROM); - } - // Now, inject the newly built ORDER BY into the tree prevSibling.AddSibling(_orderByClause); } Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs 2009-05-13 15:37:55 UTC (rev 4289) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs 2009-05-13 16:08:36 UTC (rev 4290) @@ -25,7 +25,7 @@ private ConstructorNode _constructorNode; private string[] _aliases; - public static bool VERSION2_SQL = false; + public static bool VERSION2_SQL; public SelectClause(IToken token) : base(token) { @@ -179,7 +179,7 @@ if ( fromElement.IsFetch ) { FromElement origin; - if ( fromElement.RealOrigin == null ) + if ( fromElement.RealOrigin == null ) { // work around that crazy issue where the tree contains // "empty" FromElements (no text); afaict, this is caused @@ -188,10 +188,8 @@ { throw new QueryException( "Unable to determine origin of join fetch [" + fromElement.GetDisplayText() + "]" ); } - else - { - origin = fromElement.Origin; - } + + origin = fromElement.Origin; ... [truncated message content] |
From: <fab...@us...> - 2009-05-13 15:38:04
|
Revision: 4289 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4289&view=rev Author: fabiomaulo Date: 2009-05-13 15:37:55 +0000 (Wed, 13 May 2009) Log Message: ----------- REVERT of SqlClientBatchingBatcher changes after r4279 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 09:17:42 UTC (rev 4288) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 15:37:55 UTC (rev 4289) @@ -19,7 +19,10 @@ { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); - currentBatchCommandsLog = new StringBuilder(); + if (log.IsDebugEnabled) + { + currentBatchCommandsLog = new StringBuilder(); + } } public override int BatchSize @@ -32,21 +35,24 @@ { totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - - if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + if (log.IsDebugEnabled) { string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); - currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); } - else if (log.IsDebugEnabled) + else { log.Debug("Adding to batch:" + lineWithParameters); } - currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate); + currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); } + else + { + Factory.Settings.SqlStatementLogger.LogCommand(batchUpdate, FormatStyle.Basic); + } + currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate); if (currentBatch.CountOfCommands >= batchSize) { DoExecuteBatch(batchUpdate); @@ -58,11 +64,11 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + if (log.IsDebugEnabled) { if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); - else if (log.IsDebugEnabled) + else log.Debug(currentBatchCommandsLog.ToString()); currentBatchCommandsLog = new StringBuilder(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |