You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fab...@us...> - 2010-07-21 17:19:57
|
Revision: 5031 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5031&view=rev Author: fabiomaulo Date: 2010-07-21 17:19:49 +0000 (Wed, 21 Jul 2010) Log Message: ----------- Fix NH-2243 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2243/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2243/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2243/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2243/Person.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2010-07-21 14:33:45 UTC (rev 5030) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2010-07-21 17:19:49 UTC (rev 5031) @@ -200,6 +200,7 @@ // KEY SimpleValue key = new DependantValue(table, persistentClass.Identifier); + key.ForeignKeyName = joinMapping.key.foreignkey; join.Key = key; key.IsCascadeDeleteEnabled = joinMapping.key.ondelete == HbmOndelete.Cascade; new ValuePropertyBinder(key, Mappings).BindSimpleValue(joinMapping.key, persistentClass.EntityName, false); Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2243/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2243/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2243/Fixture.cs 2010-07-21 17:19:49 UTC (rev 5031) @@ -0,0 +1,27 @@ +using System.IO; +using System.Reflection; +using System.Text; +using NHibernate.Cfg; +using NHibernate.Tool.hbm2ddl; +using NUnit.Framework; +using SharpTestsEx; + +namespace NHibernate.Test.NHSpecificTest.NH2243 +{ + public class Fixture + { + [Test] + public void ShouldCreateSchemaWithDefaultClause() + { + var script = new StringBuilder(); + const string mapping = "NHibernate.Test.NHSpecificTest.NH2243.Mappings.hbm.xml"; + + Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); + using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(mapping)) + cfg.AddInputStream(stream); + new SchemaExport(cfg).Execute(s => script.AppendLine(s), false, false); + + script.ToString().Should().Contain("MyNameForFK"); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2243/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2243/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2243/Mappings.hbm.xml 2010-07-21 17:19:49 UTC (rev 5031) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH2243"> + + <class name="Person" table="Person1"> + <id name="Id"> + <generator class="assigned" /> + </id> + <property name="Name"/> + <join table="Person2"> + <key column="PersonId" foreign-key="MyNameForFK" /> + <property name="Address"/> + </join> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2243/Person.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2243/Person.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2243/Person.cs 2010-07-21 17:19:49 UTC (rev 5031) @@ -0,0 +1,9 @@ +namespace NHibernate.Test.NHSpecificTest.NH2243 +{ + public class Person + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual string Address { 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 2010-07-21 14:33:45 UTC (rev 5030) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-21 17:19:49 UTC (rev 5031) @@ -758,6 +758,8 @@ <Compile Include="NHSpecificTest\NH2242\EscapedFormulaDomainClass.cs" /> <Compile Include="NHSpecificTest\NH2242\FormulaTest.cs" /> <Compile Include="NHSpecificTest\NH2242\UnescapedFormulaDomainClass.cs" /> + <Compile Include="NHSpecificTest\NH2243\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2243\Person.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -2195,6 +2197,7 @@ <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2243\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1891\FormulaEscaping.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2242\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2234\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-21 14:33:52
|
Revision: 5030 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5030&view=rev Author: fabiomaulo Date: 2010-07-21 14:33:45 +0000 (Wed, 21 Jul 2010) Log Message: ----------- Revert of mapping-schema breaking change introduced in r5017 (not needed to fix NH-2117) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2010-07-21 13:06:48 UTC (rev 5029) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2010-07-21 14:33:45 UTC (rev 5030) @@ -649,14 +649,11 @@ public HbmMeta[] meta; /// <remarks/> - [System.Xml.Serialization.XmlElementAttribute("column")] - public HbmColumn[] column; + [System.Xml.Serialization.XmlElementAttribute("column", typeof(HbmColumn))] + [System.Xml.Serialization.XmlElementAttribute("formula", typeof(HbmFormula))] + public object[] Items; /// <remarks/> - [System.Xml.Serialization.XmlElementAttribute("formula")] - public HbmFormula[] formula; - - /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] public string name; @@ -673,8 +670,8 @@ public string entityname; /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute("column")] - public string column1; + [System.Xml.Serialization.XmlAttributeAttribute()] + public string column; /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute("not-null")] @@ -741,8 +738,8 @@ public string propertyref; /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute("formula")] - public string formula1; + [System.Xml.Serialization.XmlAttributeAttribute()] + public string formula; /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs 2010-07-21 13:06:48 UTC (rev 5029) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs 2010-07-21 14:33:45 UTC (rev 5030) @@ -43,14 +43,14 @@ public IEnumerable<HbmColumn> Columns { - get { return column != null ? column.OfType<HbmColumn>() : AsColumns(); } + get { return Items != null ? Items.OfType<HbmColumn>() : AsColumns(); } } #endregion private IEnumerable<HbmColumn> AsColumns() { - if (string.IsNullOrEmpty(column1)) + if (string.IsNullOrEmpty(column)) { yield break; } @@ -58,7 +58,7 @@ { yield return new HbmColumn { - name = column1, + name = column, notnull = notnull, notnullSpecified = notnullSpecified, unique = unique, @@ -73,18 +73,18 @@ public IEnumerable<HbmFormula> Formulas { - get { return formula != null ? formula.OfType<HbmFormula>() : AsFormulas(); } + get { return Items != null ? Items.OfType<HbmFormula>() : AsFormulas(); } } private IEnumerable<HbmFormula> AsFormulas() { - if (string.IsNullOrEmpty(formula1)) + if (string.IsNullOrEmpty(formula)) { yield break; } else { - yield return new HbmFormula { Text = new[] { formula1 } }; + yield return new HbmFormula { Text = new[] { formula } }; } } @@ -114,7 +114,11 @@ /// </summary> public IEnumerable<object> ColumnsAndFormulas { - get { return Columns.Cast<object>().Concat(Formulas.Cast<object>()); } + // when Items is empty the column attribute AND formula attribute will be used + // and it may cause an issue (breaking change) + // On the other hand it work properly when a mixing between <formula> and <column> tags are used + // respecting the order used in the mapping to map multi-columns id. + get { return Items ?? Columns.Cast<object>().Concat(Formulas.Cast<object>()); } } public HbmLaziness? Lazy Modified: trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd =================================================================== --- trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2010-07-21 13:06:48 UTC (rev 5029) +++ trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2010-07-21 14:33:45 UTC (rev 5030) @@ -865,9 +865,11 @@ <xs:complexType> <xs:sequence> <xs:element ref="meta" minOccurs="0" maxOccurs="unbounded" /> - <xs:element ref="column" minOccurs="0" maxOccurs="unbounded" /> - <xs:element ref="formula" minOccurs="0" maxOccurs="unbounded" /> - </xs:sequence> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element ref="column" /> + <xs:element ref="formula" /> + </xs:choice> + </xs:sequence> <xs:attribute name="name" use="required" type="xs:string" /> <xs:attribute name="access" type="xs:string" /> <xs:attribute name="class" type="xs:string" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-21 13:06:55
|
Revision: 5029 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5029&view=rev Author: fabiomaulo Date: 2010-07-21 13:06:48 +0000 (Wed, 21 Jul 2010) Log Message: ----------- Ensure the CultureInfo to generate the file Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Tool.HbmXsd/Program.cs Modified: trunk/nhibernate/src/NHibernate.Tool.HbmXsd/Program.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Tool.HbmXsd/Program.cs 2010-07-21 06:37:34 UTC (rev 5028) +++ trunk/nhibernate/src/NHibernate.Tool.HbmXsd/Program.cs 2010-07-21 13:06:48 UTC (rev 5029) @@ -1,3 +1,6 @@ +using System.Globalization; +using System.Threading; + namespace NHibernate.Tool.HbmXsd { public class Program @@ -5,6 +8,9 @@ private static void Main(string[] args) { string outFile = args.Length == 0 ? @"..\..\..\NHibernate\Cfg\MappingSchema\Hbm.generated.cs" : args[0]; + var currentUiCulture = new CultureInfo("en-us"); + Thread.CurrentThread.CurrentCulture = currentUiCulture; + Thread.CurrentThread.CurrentUICulture = currentUiCulture; new HbmCodeGenerator().Execute(outFile); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-21 06:37:41
|
Revision: 5028 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5028&view=rev Author: fabiomaulo Date: 2010-07-21 06:37:34 +0000 (Wed, 21 Jul 2010) Log Message: ----------- Fix NH-1891 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/A.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/B.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/FormulaEscaping.hbm.xml Modified: trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2010-07-21 06:11:15 UTC (rev 5027) +++ trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2010-07-21 06:37:34 UTC (rev 5028) @@ -95,6 +95,7 @@ IEnumerator<string> tokensEnum = tokens.GetEnumerator(); bool hasMore = tokensEnum.MoveNext(); string nextToken = hasMore ? tokensEnum.Current : null; + string lastToken = string.Empty; while (hasMore) { string token = nextToken; @@ -139,7 +140,7 @@ isOpenQuote = false; } - if (isOpenQuote && !inFromClause) + if (isOpenQuote && !inFromClause && !lastToken.EndsWith(".")) { result.Append(placeholder).Append('.'); } @@ -201,6 +202,7 @@ { inFromClause = false; } + lastToken = token; } return result.ToString(); } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/A.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/A.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/A.cs 2010-07-21 06:37:34 UTC (rev 5028) @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1891 +{ + public class A + { + public virtual Guid Id { get; set; } + public virtual int FormulaCount { get; set; } + public virtual string FormulaConstraint { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/B.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/B.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/B.cs 2010-07-21 06:37:34 UTC (rev 5028) @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1891 +{ + public class B + { + public virtual Guid Id { get; set; } + public virtual string Name { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/Fixture.cs 2010-07-21 06:37:34 UTC (rev 5028) @@ -0,0 +1,56 @@ +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1891 +{ + [TestFixture] + public class Fixture : TestCase + { + protected override System.Collections.IList Mappings + { + get { return new string[] { "NHSpecificTest.NH1891.FormulaEscaping.hbm.xml" }; } + } + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override void OnTearDown() + { + using (ISession s = OpenSession()) + { + s.Delete("from B"); + s.Flush(); + s.Delete("from A"); + s.Flush(); + } + } + + [Test] + public void FormulaEscaping() + { + string name = "Test"; + + B b = new B(); + b.Name = name; + + A a = new A(); + a.FormulaConstraint = name; + + ISession s = OpenSession(); + + s.Save(b); + s.Save(a); + s.Flush(); + s.Close(); + + s = OpenSession(); + + a = s.Get<A>(a.Id); + + Assert.AreEqual(1, a.FormulaCount); + + s.Close(); + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/FormulaEscaping.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/FormulaEscaping.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/FormulaEscaping.hbm.xml 2010-07-21 06:37:34 UTC (rev 5028) @@ -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.NH1891"> + <class name="A" table="a" lazy="false"> + <id name="Id" column="id"> + <generator class="guid.comb" /> + </id> + <property name="FormulaCount" formula="(select count(*) from b where b.`Name` = FormulaConstraint)" type="Int32" /> + <property name="FormulaConstraint" /> + </class> + + <class name="B" table="b"> + <id name="Id" column="id"> + <generator class="guid.comb" /> + </id> + <property name="Name" /> + </class> +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-21 06:11:15 UTC (rev 5027) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-21 06:37:34 UTC (rev 5028) @@ -448,6 +448,9 @@ <Compile Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Employee.cs" /> <Compile Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Fixture.cs" /> <Compile Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Money.cs" /> + <Compile Include="NHSpecificTest\NH1891\A.cs" /> + <Compile Include="NHSpecificTest\NH1891\B.cs" /> + <Compile Include="NHSpecificTest\NH1891\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2061\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2061\Model.cs" /> <Compile Include="NHSpecificTest\NH2069\Fixture.cs" /> @@ -2192,6 +2195,7 @@ <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1891\FormulaEscaping.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2242\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2234\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2094\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-21 06:11:23
|
Revision: 5027 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5027&view=rev Author: fabiomaulo Date: 2010-07-21 06:11:15 +0000 (Wed, 21 Jul 2010) Log Message: ----------- Fix NH-2242 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/EscapedFormulaDomainClass.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/FormulaTest.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/UnescapedFormulaDomainClass.cs Modified: trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2010-07-20 21:23:32 UTC (rev 5026) +++ trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2010-07-21 06:11:15 UTC (rev 5027) @@ -139,7 +139,7 @@ isOpenQuote = false; } - if (isOpenQuote) + if (isOpenQuote && !inFromClause) { result.Append(placeholder).Append('.'); } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/EscapedFormulaDomainClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/EscapedFormulaDomainClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/EscapedFormulaDomainClass.cs 2010-07-21 06:11:15 UTC (rev 5027) @@ -0,0 +1,21 @@ +namespace NHibernate.Test.NHSpecificTest.NH2242 +{ + public class EscapedFormulaDomainClass + { + private int id; + + private int formula; + + public int Id + { + get { return id; } + set { id = value; } + } + + public int Formula + { + get { return formula; } + set { formula = value; } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/FormulaTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/FormulaTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/FormulaTest.cs 2010-07-21 06:11:15 UTC (rev 5027) @@ -0,0 +1,69 @@ +using NHibernate.Dialect; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH2242 +{ + [TestFixture] + public class FormulaTest : BugTestCase + { + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect as MsSql2005Dialect != null; + } + + [Test] + public void FormulaOfEscapedDomainClassShouldBeRetrievedCorrectly() + { + using (ISession session = OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { + var entity = new EscapedFormulaDomainClass(); + entity.Id = 1; + session.Save(entity); + + transaction.Commit(); + } + + session.Clear(); + + using (ITransaction transaction = session.BeginTransaction()) + { + var entity = session.Get<EscapedFormulaDomainClass>(1); + + Assert.AreEqual(1, entity.Formula); + session.Delete(entity); + + transaction.Commit(); + } + } + } + + [Test] + public void FormulaOfUnescapedDomainClassShouldBeRetrievedCorrectly() + { + using (ISession session = OpenSession()) + { + using (ITransaction transaction = session.BeginTransaction()) + { + var entity = new UnescapedFormulaDomainClass(); + entity.Id = 1; + session.Save(entity); + + transaction.Commit(); + } + + session.Clear(); + + using (ITransaction transaction = session.BeginTransaction()) + { + var entity = session.Get<UnescapedFormulaDomainClass>(1); + + Assert.AreEqual(1, entity.Formula); + session.Delete(entity); + transaction.Commit(); + } + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/Mappings.hbm.xml 2010-07-21 06:11:15 UTC (rev 5027) @@ -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.NH2242" default-access="field.camelcase" + default-lazy="false"> + <class name="EscapedFormulaDomainClass"> + <id name="Id"> + <generator class="assigned" /> + </id> + <property name="Formula" formula="(SELECT COUNT(*) FROM [EscapedFormulaDomainClass])" /> + </class> + <class name="UnescapedFormulaDomainClass"> + <id name="Id"> + <generator class="assigned" /> + </id> + <property name="Formula" formula="(SELECT COUNT(*) FROM UnescapedFormulaDomainClass)" /> + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/UnescapedFormulaDomainClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/UnescapedFormulaDomainClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/UnescapedFormulaDomainClass.cs 2010-07-21 06:11:15 UTC (rev 5027) @@ -0,0 +1,21 @@ +namespace NHibernate.Test.NHSpecificTest.NH2242 +{ + public class UnescapedFormulaDomainClass + { + private int id; + + private int formula; + + public int Id + { + get { return id; } + set { id = value; } + } + + public int Formula + { + get { return formula; } + set { formula = value; } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 21:23:32 UTC (rev 5026) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-21 06:11:15 UTC (rev 5027) @@ -752,6 +752,9 @@ <Compile Include="NHSpecificTest\NH2230\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2234\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2234\MyType.cs" /> + <Compile Include="NHSpecificTest\NH2242\EscapedFormulaDomainClass.cs" /> + <Compile Include="NHSpecificTest\NH2242\FormulaTest.cs" /> + <Compile Include="NHSpecificTest\NH2242\UnescapedFormulaDomainClass.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -2189,6 +2192,7 @@ <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2242\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2234\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2094\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2092\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-20 21:23:38
|
Revision: 5026 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5026&view=rev Author: fabiomaulo Date: 2010-07-20 21:23:32 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Test for NH-2234 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/MyType.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Fixture.cs 2010-07-20 21:23:32 UTC (rev 5026) @@ -0,0 +1,29 @@ +using System.Linq; +using NHibernate.Linq; +using NUnit.Framework; +using SharpTestsEx; + +namespace NHibernate.Test.NHSpecificTest.NH2234 +{ + public class SomethingLinq + { + public virtual string Name { get; set; } + public virtual MyUsertype Relation { get; set; } + } + + [TestFixture, Ignore("Not fixed yet.")] + public class Fixture: BugTestCase + { + [Test] + public void CanQueryViaLinq() + { + using (var s = OpenSession()) + { + var qry = from item in s.Query<SomethingLinq>() where item.Relation == MyUserTypes.Value1 select item; + + qry.ToList(); + qry.Executing(q => q.ToList()).NotThrows(); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Mappings.hbm.xml 2010-07-20 21:23:32 UTC (rev 5026) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH2234"> + + <class name="SomethingLinq"> + <id type="int"> + <generator class="hilo"/> + </id> + <property name="Name"/> + <property name="Relation" type="NHibernate.Test.NHSpecificTest.NH2234.SimpleCustomType, NHibernate.Test"/> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/MyType.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/MyType.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/MyType.cs 2010-07-20 21:23:32 UTC (rev 5026) @@ -0,0 +1,132 @@ +using System.Collections.Generic; +using System.Data; +using NHibernate.SqlTypes; +using NHibernate.UserTypes; + +namespace NHibernate.Test.NHSpecificTest.NH2234 +{ + public class MyUsertype + { + public MyUsertype(int id, string value) + { + Id = id; + Value = value; + } + + public int Id { get; set; } + public string Value { get; set; } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + + public override bool Equals(object obj) + { + var mut = obj as MyUsertype; + return mut != null && mut.Id == Id; + } + + public static bool operator ==(MyUsertype left, MyUsertype right) + { + return Equals(left, right); + } + + public static bool operator !=(MyUsertype left, MyUsertype right) + { + return !Equals(left, right); + } + } + + public static class MyUserTypes + { + public static readonly List<MyUsertype> _values = new List<MyUsertype>() + {new MyUsertype(1, "Value 1"), new MyUsertype(2, "Value 2")}; + + + public static MyUsertype Value1 + { + get { return _values[0]; } + } + + public static MyUsertype Value2 + { + get { return _values[1]; } + } + + public static MyUsertype Find(int id) + { + return _values.Find(item => item.Id == id); + } + } + + public class SimpleCustomType : IUserType + { + private static readonly SqlType[] ReturnSqlTypes = { SqlTypeFactory.Int32 }; + + + #region IUserType Members + + public new bool Equals(object x, object y) + { + return x.Equals(y); + } + + public int GetHashCode(object x) + { + return (x == null) ? 0 : x.GetHashCode(); + } + + public SqlType[] SqlTypes + { + get { return ReturnSqlTypes; } + } + + public object DeepCopy(object value) + { + return value; + } + + public void NullSafeSet(IDbCommand cmd, object value, int index) + { + if (value == null) + NHibernateUtil.Int32.NullSafeSet(cmd, null, index, null); + else + NHibernateUtil.Int32.NullSafeSet(cmd, ((MyUsertype)value).Id, index, null); + } + + public System.Type ReturnedType + { + get { return typeof(MyUsertype); } + } + + public object NullSafeGet(IDataReader rs, string[] names, object owner) + { + int value = (int)NHibernateUtil.Int32.NullSafeGet(rs, names[0], null, owner); + return MyUserTypes.Find(value); + } + + public bool IsMutable + { + get { return false; } + } + + public object Replace(object original, object target, object owner) + { + return original; + } + + public object Assemble(object cached, object owner) + { + return cached; + } + + public object Disassemble(object value) + { + return value; + } + + #endregion + } + +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 19:42:09 UTC (rev 5025) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 21:23:32 UTC (rev 5026) @@ -750,6 +750,8 @@ <Compile Include="NHSpecificTest\NH2201\Model.cs" /> <Compile Include="NHSpecificTest\NH2230\Domain.cs" /> <Compile Include="NHSpecificTest\NH2230\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2234\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2234\MyType.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -2187,6 +2189,7 @@ <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2234\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2094\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2092\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2093\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-20 19:42:16
|
Revision: 5025 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5025&view=rev Author: fabiomaulo Date: 2010-07-20 19:42:09 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Minor (ignore list) Property Changed: ---------------- trunk/nhibernate/src/NHibernate.Test/ Property changes on: trunk/nhibernate/src/NHibernate.Test ___________________________________________________________________ Modified: svn:ignore - bin obj .#* *.user *.xsx AssemblyInfo.cs hibernate.cfg.xml Debug Release *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* *.xml NHibernate.Test.pidb test-results + bin obj .#* *.user *.xsx AssemblyInfo.cs hibernate.cfg.xml Debug Release *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* *.xml NHibernate.Test.pidb test-results *[Rr]esparper* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-20 19:16:24
|
Revision: 5024 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5024&view=rev Author: fabiomaulo Date: 2010-07-20 19:16:18 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Apply NH-2236 (thanks to Diego Mijelshon) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/InformixDialect0940.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/InformixDialect0940.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/InformixDialect0940.cs 2010-07-20 19:01:08 UTC (rev 5023) +++ trunk/nhibernate/src/NHibernate/Dialect/InformixDialect0940.cs 2010-07-20 19:16:18 UTC (rev 5024) @@ -80,7 +80,7 @@ /// <remarks>This should be a "stand alone" select statement.</remarks> public override string GetSequenceNextValString(string sequenceName) { - return "select " + sequenceName + ".nextval from systables"; + return "select " + GetSelectSequenceNextValString(sequenceName) + " from systables where tabid=1"; } public override string GetDropSequenceString(string sequenceName) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-20 19:01:14
|
Revision: 5023 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5023&view=rev Author: fabiomaulo Date: 2010-07-20 19:01:08 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Additional tests with better exception message for NH-2094 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Fixture.cs Modified: trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs 2010-07-20 18:37:34 UTC (rev 5022) +++ trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs 2010-07-20 19:01:08 UTC (rev 5023) @@ -103,11 +103,11 @@ if (session == null) { - throw new LazyInitializationException("entity with lazy properties is not associated with a session"); + throw new LazyInitializationException(EntityName, null, string.Format("entity with lazy properties is not associated with a session. entity-name:'{0}' property:'{1}'", EntityName, fieldName)); } if (!session.IsOpen || !session.IsConnected) { - throw new LazyInitializationException("session is not connected"); + throw new LazyInitializationException(EntityName, null, string.Format("session is not connected. entity-name:'{0}' property:'{1}'", EntityName, fieldName)); } if (IsUninitializedProperty(fieldName)) Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Fixture.cs 2010-07-20 18:37:34 UTC (rev 5022) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Fixture.cs 2010-07-20 19:01:08 UTC (rev 5023) @@ -1,7 +1,8 @@ using NHibernate.ByteCode.Castle; using NHibernate.Cfg; using NUnit.Framework; - +using SharpTestsEx; + namespace NHibernate.Test.NHSpecificTest.NH2094 { [TestFixture] @@ -50,5 +51,75 @@ } } } + + [Test] + public void WhenAccessNoLazyPropertiesOutsideOfSessionThenNotThrows() + { + try + { + using (var s = OpenSession()) + { + var p = new Person { Id = 1, Name = "Person1", LazyField = "Long field" }; + + s.Save(p); + + s.Flush(); + } + + Person person; + + using (var s = OpenSession()) + { + person = s.Get<Person>(1); + } + string personName; + Executing.This(()=> personName = person.Name).Should().NotThrow(); + } + finally + { + using (var s = OpenSession()) + { + s.Delete("from Person"); + + s.Flush(); + } + } + } + + [Test] + public void WhenAccessLazyPropertiesOutsideOfSessionThenThrows() + { + try + { + using (var s = OpenSession()) + { + var p = new Person { Id = 1, Name = "Person1", LazyField = "Long field" }; + + s.Save(p); + + s.Flush(); + } + + Person person; + + using (var s = OpenSession()) + { + person = s.Get<Person>(1); + } + string lazyField; + var lazyException = Executing.This(() => lazyField = person.LazyField).Should().Throw<LazyInitializationException>().Exception; + lazyException.EntityName.Should().Not.Be.Null(); + lazyException.Message.Should().Contain("LazyField"); + } + finally + { + using (var s = OpenSession()) + { + s.Delete("from Person"); + + s.Flush(); + } + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-20 18:37:41
|
Revision: 5022 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5022&view=rev Author: fabiomaulo Date: 2010-07-20 18:37:34 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Fix NH-2094 (thanks to Johannes Gustafsson for the TEST) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Model.cs Modified: trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs 2010-07-20 17:52:31 UTC (rev 5021) +++ trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs 2010-07-20 18:37:34 UTC (rev 5022) @@ -96,6 +96,11 @@ if (initializing) return InvokeImplementation; + if (!IsUninitializedProperty(fieldName)) + { + return value; + } + if (session == null) { throw new LazyInitializationException("entity with lazy properties is not associated with a session"); @@ -105,17 +110,23 @@ throw new LazyInitializationException("session is not connected"); } - if (uninitializedFields != null && uninitializedFields.Contains(fieldName)) + if (IsUninitializedProperty(fieldName)) { return InitializeField(fieldName, target); } - if (value is INHibernateProxy && unwrapProxyFieldNames != null && unwrapProxyFieldNames.Contains(fieldName)) + var nhproxy = value as INHibernateProxy; + if (nhproxy != null && unwrapProxyFieldNames != null && unwrapProxyFieldNames.Contains(fieldName)) { - return InitializeOrGetAssociation((INHibernateProxy)value, fieldName); + return InitializeOrGetAssociation(nhproxy, fieldName); } return InvokeImplementation; } + private bool IsUninitializedProperty(string fieldName) + { + return uninitializedFields != null && uninitializedFields.Contains(fieldName); + } + private object InitializeOrGetAssociation(INHibernateProxy value, string fieldName) { if(value.HibernateLazyInitializer.IsUninitialized) Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Fixture.cs 2010-07-20 18:37:34 UTC (rev 5022) @@ -0,0 +1,54 @@ +using NHibernate.ByteCode.Castle; +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH2094 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.ProxyFactoryFactoryClass, + typeof(ProxyFactoryFactory).AssemblyQualifiedName); + } + + [Test] + public void CanAccessInitializedPropertiesOutsideOfSession() + { + try + { + using (var s = OpenSession()) + { + var p = new Person { Id = 1, Name = "Person1", LazyField = "Long field"}; + + s.Save(p); + + s.Flush(); + } + + Person person; + + using (var s = OpenSession()) + { + person = s.Get<Person>(1); + + Assert.AreEqual("Person1", person.Name); + Assert.AreEqual("Long field", person.LazyField); + } + + Assert.AreEqual("Person1", person.Name); + Assert.AreEqual("Long field", person.LazyField); + } + finally + { + using (var s = OpenSession()) + { + s.Delete("from Person"); + + s.Flush(); + } + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Mappings.hbm.xml 2010-07-20 18:37:34 UTC (rev 5022) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH2094"> + + <class name="Person"> + <id name="Id"/> + <property name="Name"></property> + + <property name="LazyField" lazy="true"></property> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2094/Model.cs 2010-07-20 18:37:34 UTC (rev 5022) @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH2094 +{ + public class Person + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + + public virtual string LazyField { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 17:52:31 UTC (rev 5021) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 18:37:34 UTC (rev 5022) @@ -461,6 +461,8 @@ <Compile Include="NHSpecificTest\NH2092\Model.cs" /> <Compile Include="NHSpecificTest\NH2093\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2093\Model.cs" /> + <Compile Include="NHSpecificTest\NH2094\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2094\Model.cs" /> <Compile Include="NHSpecificTest\NH2102\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2102\Model.cs" /> <Compile Include="NHSpecificTest\NH2189\Fixture.cs" /> @@ -2185,6 +2187,7 @@ <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2094\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2092\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2093\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2102\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-20 17:52:39
|
Revision: 5021 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5021&view=rev Author: fabiomaulo Date: 2010-07-20 17:52:31 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Passing test of NH-2092 (probably fixed by the fix of NH-2102) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Model.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Fixture.cs 2010-07-20 17:52:31 UTC (rev 5021) @@ -0,0 +1,55 @@ +using NHibernate.ByteCode.Castle; +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH2092 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.ProxyFactoryFactoryClass, + typeof(ProxyFactoryFactory).AssemblyQualifiedName); + } + + [Test] + public void ConstrainedLazyLoadedOneToOneUsingCastleProxy() + { + try + { + using (var s = OpenSession()) + { + var person = new Person { Id = 1, Name = "Person1" }; + var employee = new Employee { Id = 1, Name = "Emp1", Person = person }; + + s.Save(person); + s.Save(employee); + + s.Flush(); + } + + using (var s = OpenSession()) + { + var employee = s.Get<Employee>(1); + + Assert.False(NHibernateUtil.IsInitialized(employee.Person)); + + Assert.AreEqual(employee.Person.Name, "Person1"); + + Assert.True(NHibernateUtil.IsInitialized(employee.Person)); + } + } + finally + { + using (var s = OpenSession()) + { + s.Delete("from Employee"); + s.Delete("from Person"); + + s.Flush(); + } + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Mappings.hbm.xml 2010-07-20 17:52:31 UTC (rev 5021) @@ -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.NH2092"> + + <class name="Person"> + <id name="Id"/> + <property name="Name"></property> + </class> + + <class name="Employee"> + <id name="Id"/> + <property name="Name"></property> + + <one-to-one name="Person" constrained="true" lazy="proxy"/> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Model.cs 2010-07-20 17:52:31 UTC (rev 5021) @@ -0,0 +1,16 @@ +namespace NHibernate.Test.NHSpecificTest.NH2092 +{ + public class Person + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + } + + public class Employee + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + + public virtual Person Person { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 17:45:07 UTC (rev 5020) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 17:52:31 UTC (rev 5021) @@ -457,6 +457,8 @@ <Compile Include="NHSpecificTest\NH2069\Test.cs" /> <Compile Include="NHSpecificTest\NH2069\Test2.cs" /> <Compile Include="NHSpecificTest\NH2069\TestBase.cs" /> + <Compile Include="NHSpecificTest\NH2092\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2092\Model.cs" /> <Compile Include="NHSpecificTest\NH2093\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2093\Model.cs" /> <Compile Include="NHSpecificTest\NH2102\Fixture.cs" /> @@ -2183,6 +2185,7 @@ <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2092\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2093\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2102\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2069\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-20 17:45:14
|
Revision: 5020 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5020&view=rev Author: fabiomaulo Date: 2010-07-20 17:45:07 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Fix NH-2093 (thanks to Johannes Gustafsson for the TEST) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Event/Default/AbstractSaveEventListener.cs trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs trunk/nhibernate/src/NHibernate/Intercept/DefaultFieldInterceptor.cs trunk/nhibernate/src/NHibernate/Intercept/FieldInterceptionHelper.cs trunk/nhibernate/src/NHibernate/Intercept/IFieldInterceptor.cs trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs trunk/nhibernate/src/NHibernate/Proxy/NHibernateProxyHelper.cs trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2093/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2093/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2093/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2093/Model.cs Modified: trunk/nhibernate/src/NHibernate/Event/Default/AbstractSaveEventListener.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/Default/AbstractSaveEventListener.cs 2010-07-20 16:43:09 UTC (rev 5019) +++ trunk/nhibernate/src/NHibernate/Event/Default/AbstractSaveEventListener.cs 2010-07-20 17:45:07 UTC (rev 5020) @@ -292,7 +292,7 @@ { if (FieldInterceptionHelper.IsInstrumented(entity)) { - IFieldInterceptor interceptor = FieldInterceptionHelper.InjectFieldInterceptor(entity, persister.EntityName, null, null, source); + IFieldInterceptor interceptor = FieldInterceptionHelper.InjectFieldInterceptor(entity, persister.EntityName, persister.GetMappedClass(source.EntityMode), null, null, source); interceptor.MarkDirty(); } } Modified: trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs 2010-07-20 16:43:09 UTC (rev 5019) +++ trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs 2010-07-20 17:45:07 UTC (rev 5020) @@ -16,17 +16,19 @@ private readonly ISet<string> unwrapProxyFieldNames; private readonly ISet<string> loadedUnwrapProxyFieldNames = new HashedSet<string>(); private readonly string entityName; + private readonly System.Type mappedClass; [NonSerialized] private bool initializing; private bool isDirty; - protected internal AbstractFieldInterceptor(ISessionImplementor session, ISet<string> uninitializedFields, ISet<string> unwrapProxyFieldNames, string entityName) + protected internal AbstractFieldInterceptor(ISessionImplementor session, ISet<string> uninitializedFields, ISet<string> unwrapProxyFieldNames, string entityName, System.Type mappedClass) { this.session = session; this.uninitializedFields = uninitializedFields; this.unwrapProxyFieldNames = unwrapProxyFieldNames; this.entityName = entityName; + this.mappedClass = mappedClass; } #region IFieldInterceptor Members @@ -65,6 +67,16 @@ isDirty = false; } + public string EntityName + { + get { return entityName; } + } + + public System.Type MappedClass + { + get { return mappedClass; } + } + #endregion public ISet<string> UninitializedFields @@ -72,11 +84,6 @@ get { return uninitializedFields; } } - public string EntityName - { - get { return entityName; } - } - public bool Initializing { get { return initializing; } Modified: trunk/nhibernate/src/NHibernate/Intercept/DefaultFieldInterceptor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Intercept/DefaultFieldInterceptor.cs 2010-07-20 16:43:09 UTC (rev 5019) +++ trunk/nhibernate/src/NHibernate/Intercept/DefaultFieldInterceptor.cs 2010-07-20 17:45:07 UTC (rev 5020) @@ -5,8 +5,8 @@ { public class DefaultFieldInterceptor : AbstractFieldInterceptor { - public DefaultFieldInterceptor(ISessionImplementor session, ISet<string> uninitializedFields, ISet<string> unwrapProxyFieldNames, string entityName) - : base(session, uninitializedFields, unwrapProxyFieldNames, entityName) + public DefaultFieldInterceptor(ISessionImplementor session, ISet<string> uninitializedFields, ISet<string> unwrapProxyFieldNames, string entityName, System.Type mappedClass) + : base(session, uninitializedFields, unwrapProxyFieldNames, entityName, mappedClass) { } } Modified: trunk/nhibernate/src/NHibernate/Intercept/FieldInterceptionHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Intercept/FieldInterceptionHelper.cs 2010-07-20 16:43:09 UTC (rev 5019) +++ trunk/nhibernate/src/NHibernate/Intercept/FieldInterceptionHelper.cs 2010-07-20 17:45:07 UTC (rev 5020) @@ -33,6 +33,7 @@ } public static IFieldInterceptor InjectFieldInterceptor(object entity, string entityName, + System.Type mappedClass, ISet<string> uninitializedFieldNames, ISet<string> unwrapProxyFieldNames, ISessionImplementor session) @@ -40,7 +41,7 @@ var fieldInterceptorAccessor = entity as IFieldInterceptorAccessor; if (fieldInterceptorAccessor != null) { - var fieldInterceptorImpl = new DefaultFieldInterceptor(session, uninitializedFieldNames, unwrapProxyFieldNames, entityName); + var fieldInterceptorImpl = new DefaultFieldInterceptor(session, uninitializedFieldNames, unwrapProxyFieldNames, entityName, mappedClass); fieldInterceptorAccessor.FieldInterceptor = fieldInterceptorImpl; return fieldInterceptorImpl; } Modified: trunk/nhibernate/src/NHibernate/Intercept/IFieldInterceptor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Intercept/IFieldInterceptor.cs 2010-07-20 16:43:09 UTC (rev 5019) +++ trunk/nhibernate/src/NHibernate/Intercept/IFieldInterceptor.cs 2010-07-20 17:45:07 UTC (rev 5020) @@ -29,5 +29,11 @@ /// <summary> Intercept field set/get </summary> object Intercept(object target, string fieldName, object value); + + /// <summary> Get the entity-name of the field DeclaringType.</summary> + string EntityName { get; } + + /// <summary> Get the MappedClass (field container).</summary> + System.Type MappedClass { get; } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2010-07-20 16:43:09 UTC (rev 5019) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2010-07-20 17:45:07 UTC (rev 5020) @@ -3615,7 +3615,7 @@ } else { - IFieldInterceptor fieldInterceptor = FieldInterceptionHelper.InjectFieldInterceptor(entity, EntityName, null, null, session); + IFieldInterceptor fieldInterceptor = FieldInterceptionHelper.InjectFieldInterceptor(entity, EntityName, GetMappedClass(session.EntityMode), null, null, session); fieldInterceptor.MarkDirty(); } } Modified: trunk/nhibernate/src/NHibernate/Proxy/NHibernateProxyHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Proxy/NHibernateProxyHelper.cs 2010-07-20 16:43:09 UTC (rev 5019) +++ trunk/nhibernate/src/NHibernate/Proxy/NHibernateProxyHelper.cs 2010-07-20 17:45:07 UTC (rev 5020) @@ -1,3 +1,4 @@ +using NHibernate.Intercept; using NHibernate.Persister.Entity; namespace NHibernate.Proxy @@ -44,7 +45,7 @@ /// </remarks> public static System.Type GuessClass(object entity) { - INHibernateProxy proxy = entity as INHibernateProxy; + var proxy = entity as INHibernateProxy; if (proxy != null) { ILazyInitializer li = proxy.HibernateLazyInitializer; @@ -52,15 +53,15 @@ { return li.PersistentClass; } - else - { - return li.GetImplementation().GetType(); - } + return li.GetImplementation().GetType(); } - else + var fieldInterceptorAccessor = entity as IFieldInterceptorAccessor; + if (fieldInterceptorAccessor != null) { - return entity.GetType(); + var fieldInterceptor = fieldInterceptorAccessor.FieldInterceptor; + return fieldInterceptor.MappedClass; } + return entity.GetType(); } } } Modified: trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs 2010-07-20 16:43:09 UTC (rev 5019) +++ trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs 2010-07-20 17:45:07 UTC (rev 5020) @@ -229,7 +229,7 @@ HashedSet<string> lazyProps = lazyPropertiesAreUnfetched && EntityMetamodel.HasLazyProperties ? lazyPropertyNames : null; //TODO: if we support multiple fetch groups, we would need // to clone the set of lazy properties! - FieldInterceptionHelper.InjectFieldInterceptor(entity, EntityName, lazyProps, unwrapProxyPropertyNames, session); + FieldInterceptionHelper.InjectFieldInterceptor(entity, EntityName, this.MappedClass ,lazyProps, unwrapProxyPropertyNames, session); } } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2093/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2093/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2093/Fixture.cs 2010-07-20 17:45:07 UTC (rev 5020) @@ -0,0 +1,103 @@ +using System.Linq; +using NHibernate.ByteCode.Castle; +using NHibernate.Cfg; +using NHibernate.Proxy; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH2093 + { + [TestFixture] + public class Fixture : BugTestCase + { + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.ProxyFactoryFactoryClass, + typeof(ProxyFactoryFactory).AssemblyQualifiedName); + } + + [Test] + public void NHibernateProxyHelperReturnsCorrectType() + { + try + { + using (var s = OpenSession()) + { + var person = new Person { Id = 1, Name = "Person1" }; + var employee = new Employee { Id = 1, Name = "Emp1", Person = person }; + + s.Save(person); + s.Save(employee); + + s.Flush(); + } + + using (var s = OpenSession()) + { + var person = s.Load<Person>(1); + + var type = NHibernateProxyHelper.GuessClass(person); + + Assert.AreEqual(type, typeof(Person)); + } + + using (var s = OpenSession()) + { + var person = s.Get<Person>(1); + + var type = NHibernateProxyHelper.GuessClass(person); + + Assert.AreEqual(type, typeof(Person)); + } + } + finally + { + using (var s = OpenSession()) + { + s.Delete("from Employee"); + s.Delete("from Person"); + + s.Flush(); + } + } + } + + [Test] + public void CanUseFieldInterceptingProxyAsHQLArgument() + { + try + { + using (var s = OpenSession()) + { + var person = new Person { Id = 1, Name = "Person1" }; + var employee = new Employee { Id = 1, Name = "Emp1", Person = person }; + + s.Save(person); + s.Save(employee); + + s.Flush(); + } + + using (var s = OpenSession()) + { + var person = s.Get<Person>(1); + + var list = s.CreateQuery("from Employee where Person = :p") + .SetEntity("p", person) + .List<Employee>(); + + Assert.AreEqual(list.Count, 1); + } + } + finally + { + using (var s = OpenSession()) + { + s.Delete("from Employee"); + s.Delete("from Person"); + + s.Flush(); + } + } + } + } + } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2093/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2093/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2093/Mappings.hbm.xml 2010-07-20 17:45:07 UTC (rev 5020) @@ -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.NH2093"> + + <class name="Person"> + <id name="Id"/> + <property name="Name"></property> + <property name="LazyField" lazy="true"></property> + </class> + + <class name="Employee"> + <id name="Id"/> + <property name="Name"></property> + + <one-to-one name="Person" constrained="true" lazy="proxy"/> + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2093/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2093/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2093/Model.cs 2010-07-20 17:45:07 UTC (rev 5020) @@ -0,0 +1,20 @@ + using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH2093 + { + public class Person + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + + public virtual string LazyField { get; set; } + } + + public class Employee + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + + public virtual Person Person { get; set; } + } + } Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 16:43:09 UTC (rev 5019) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 17:45:07 UTC (rev 5020) @@ -457,6 +457,8 @@ <Compile Include="NHSpecificTest\NH2069\Test.cs" /> <Compile Include="NHSpecificTest\NH2069\Test2.cs" /> <Compile Include="NHSpecificTest\NH2069\TestBase.cs" /> + <Compile Include="NHSpecificTest\NH2093\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2093\Model.cs" /> <Compile Include="NHSpecificTest\NH2102\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2102\Model.cs" /> <Compile Include="NHSpecificTest\NH2189\Fixture.cs" /> @@ -1689,11 +1691,6 @@ <Project>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</Project> <Name>NHibernate</Name> </ProjectReference> - <Folder Include="Component" /> - <Folder Include="Component\Basic" /> - <Folder Include="NHSpecificTest\NH2061" /> - <Folder Include="NHSpecificTest\NH2195" /> - <Folder Include="TypedManyToOne" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="NHSpecificTest\NH386\Mappings.hbm.xml" /> @@ -2186,6 +2183,7 @@ <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2093\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2102\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2069\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2230\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-20 16:43:15
|
Revision: 5019 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5019&view=rev Author: fabiomaulo Date: 2010-07-20 16:43:09 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Fix NH-2102 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Mapping/Property.cs trunk/nhibernate/src/NHibernate/Tuple/Entity/EntityMetamodel.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs Modified: trunk/nhibernate/src/NHibernate/Mapping/Property.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2010-07-20 13:54:08 UTC (rev 5018) +++ trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2010-07-20 16:43:09 UTC (rev 5019) @@ -294,5 +294,10 @@ // true here for the case of many-to-one and one-to-one // with lazy="no-proxy" public bool UnwrapProxy { get; set; } + + public bool IsEntityRelation + { + get { return (Value as ToOne) != null; } + } } } Modified: trunk/nhibernate/src/NHibernate/Tuple/Entity/EntityMetamodel.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Tuple/Entity/EntityMetamodel.cs 2010-07-20 13:54:08 UTC (rev 5018) +++ trunk/nhibernate/src/NHibernate/Tuple/Entity/EntityMetamodel.cs 2010-07-20 16:43:09 UTC (rev 5019) @@ -128,14 +128,17 @@ foreach (Mapping.Property prop in persistentClass.PropertyClosureIterator) { + // NH: A lazy property is a simple property marked with lazy=true or a relation (in this case many-to-one or one-to-one marked as "no-proxy") + bool lazyProperty = prop.IsLazy && lazyAvailable && (!prop.IsEntityRelation || prop.UnwrapProxy); + if (prop == persistentClass.Version) { tempVersionProperty = i; - properties[i] = PropertyFactory.BuildVersionProperty(prop, lazyAvailable); + properties[i] = PropertyFactory.BuildVersionProperty(prop, lazyProperty); } else { - properties[i] = PropertyFactory.BuildStandardProperty(prop, lazyAvailable); + properties[i] = PropertyFactory.BuildStandardProperty(prop, lazyProperty); } if (prop.IsNaturalIdentifier) @@ -148,7 +151,6 @@ foundNonIdentifierPropertyNamedId = true; } - bool lazyProperty = prop.IsLazy && lazyAvailable; if (lazyProperty) { hasLazy = true; Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs 2010-07-20 13:54:08 UTC (rev 5018) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs 2010-07-20 16:43:09 UTC (rev 5019) @@ -1,17 +1,16 @@ -using NHibernate.ByteCode.Castle; using NHibernate.Cfg; using NUnit.Framework; using SharpTestsEx; namespace NHibernate.Test.NHSpecificTest.NH2102 { - [TestFixture, Ignore("Not fixed yet.")] + [TestFixture] public class Fixture : BugTestCase { protected override void Configure(Configuration configuration) { configuration.SetProperty(Environment.ProxyFactoryFactoryClass, - typeof(ProxyFactoryFactory).AssemblyQualifiedName); + typeof(ByteCode.Castle.ProxyFactoryFactory).AssemblyQualifiedName); } [Test] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jul...@us...> - 2010-07-20 13:54:14
|
Revision: 5018 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5018&view=rev Author: julian-maughan Date: 2010-07-20 13:54:08 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Forgot meta regeneration fixing NH-2117. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2010-07-20 00:54:39 UTC (rev 5017) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2010-07-20 13:54:08 UTC (rev 5018) @@ -649,11 +649,14 @@ public HbmMeta[] meta; /// <remarks/> - [System.Xml.Serialization.XmlElementAttribute("column", typeof(HbmColumn))] - [System.Xml.Serialization.XmlElementAttribute("formula", typeof(HbmFormula))] - public object[] Items; + [System.Xml.Serialization.XmlElementAttribute("column")] + public HbmColumn[] column; /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute("formula")] + public HbmFormula[] formula; + + /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] public string name; @@ -670,8 +673,8 @@ public string entityname; /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string column; + [System.Xml.Serialization.XmlAttributeAttribute("column")] + public string column1; /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute("not-null")] @@ -738,8 +741,8 @@ public string propertyref; /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string formula; + [System.Xml.Serialization.XmlAttributeAttribute("formula")] + public string formula1; /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs 2010-07-20 00:54:39 UTC (rev 5017) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs 2010-07-20 13:54:08 UTC (rev 5018) @@ -43,14 +43,14 @@ public IEnumerable<HbmColumn> Columns { - get { return Items != null ? Items.OfType<HbmColumn>() : AsColumns(); } + get { return column != null ? column.OfType<HbmColumn>() : AsColumns(); } } #endregion private IEnumerable<HbmColumn> AsColumns() { - if (string.IsNullOrEmpty(column)) + if (string.IsNullOrEmpty(column1)) { yield break; } @@ -58,7 +58,7 @@ { yield return new HbmColumn { - name = column, + name = column1, notnull = notnull, notnullSpecified = notnullSpecified, unique = unique, @@ -73,18 +73,18 @@ public IEnumerable<HbmFormula> Formulas { - get { return Items != null ? Items.OfType<HbmFormula>() : AsFormulas(); } + get { return formula != null ? formula.OfType<HbmFormula>() : AsFormulas(); } } private IEnumerable<HbmFormula> AsFormulas() { - if (string.IsNullOrEmpty(formula)) + if (string.IsNullOrEmpty(formula1)) { yield break; } else { - yield return new HbmFormula { Text = new[] { formula } }; + yield return new HbmFormula { Text = new[] { formula1 } }; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jul...@us...> - 2010-07-20 00:54:46
|
Revision: 5017 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5017&view=rev Author: julian-maughan Date: 2010-07-20 00:54:39 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Added support for many-to-one mappings that include a formula (ref. NH-2117) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ColumnsBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ValuePropertyBinder.cs trunk/nhibernate/src/NHibernate/SqlCommand/ANSIJoinFragment.cs trunk/nhibernate/src/NHibernate/SqlCommand/SelectFragment.cs trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/ trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/Address.cs trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/AddressId.cs trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/Customer.cs trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/Customer.hbm.xml trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/TypedManyToOneTest.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs 2010-07-20 00:34:18 UTC (rev 5016) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs 2010-07-20 00:54:39 UTC (rev 5017) @@ -109,6 +109,14 @@ #endregion + /// <summary> + /// Columns and Formulas, in declared order + /// </summary> + public IEnumerable<object> ColumnsAndFormulas + { + get { return Columns.Cast<object>().Concat(Formulas.Cast<object>()); } + } + public HbmLaziness? Lazy { get { return lazySpecified ? lazy : (HbmLaziness?) null;} Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2010-07-20 00:34:18 UTC (rev 5016) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2010-07-20 00:54:39 UTC (rev 5017) @@ -18,6 +18,8 @@ } compositeId = new Component(rootClass); + compositeId.IsKey = true; + rootClass.Identifier = compositeId; if (idSchema.name == null) Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ColumnsBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ColumnsBinder.cs 2010-07-20 00:34:18 UTC (rev 5016) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ColumnsBinder.cs 2010-07-20 00:54:39 UTC (rev 5017) @@ -15,25 +15,29 @@ { this.value = value; } - + + public void Bind(HbmColumn column, bool isNullable) + { + this.BindColumn(column, value.Table, isNullable); + } + public void Bind(IEnumerable<HbmColumn> columns, bool isNullable, Func<HbmColumn> defaultColumnDelegate) { var table = value.Table; - int colIndex = 0; foreach (var hbmColumn in columns) { - BindColumn(hbmColumn, table, colIndex++, isNullable); + BindColumn(hbmColumn, table, isNullable); } if (value.ColumnSpan == 0 && defaultColumnDelegate != null) { - BindColumn(defaultColumnDelegate(), table, colIndex, isNullable); + BindColumn(defaultColumnDelegate(), table, isNullable); } } - private void BindColumn(HbmColumn hbmColumn, Table table, int colIndex, bool isNullable) + private void BindColumn(HbmColumn hbmColumn, Table table, bool isNullable) { - var col = new Column {Value = value, TypeIndex = colIndex}; + var col = new Column {Value = value}; BindColumn(hbmColumn, col, isNullable); if (table != null) Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ValuePropertyBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ValuePropertyBinder.cs 2010-07-20 00:34:18 UTC (rev 5016) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ValuePropertyBinder.cs 2010-07-20 00:54:39 UTC (rev 5017) @@ -28,7 +28,7 @@ var formulas = propertyMapping.Formulas.ToArray(); if (formulas.Length > 0) { - BindFormula(formulas); + BindFormulas(formulas); } else { @@ -56,7 +56,7 @@ var formulas = element.Formulas.ToArray(); if (formulas.Length > 0) { - BindFormula(formulas); + BindFormulas(formulas); } else { @@ -76,14 +76,6 @@ } } - private void BindFormula(IEnumerable<HbmFormula> formulas) - { - foreach (var hbmFormula in formulas) - { - value.AddFormula(new Formula { FormulaString = hbmFormula.Text.LinesToString() }); - } - } - public void BindSimpleValue(HbmKey propertyMapping, string propertyPath, bool isNullable) { new ColumnsBinder(value, Mappings).Bind(propertyMapping.Columns, isNullable, @@ -103,7 +95,7 @@ var formulas = manyToManyMapping.Formulas.ToArray(); if (formulas.Length > 0) { - BindFormula(formulas); + BindFormulas(formulas); } else { @@ -159,7 +151,7 @@ var formulas = mapKeyMapping.Formulas.ToArray(); if (formulas.Length > 0) { - BindFormula(formulas); + BindFormulas(formulas); } else { @@ -173,27 +165,28 @@ } } - public void BindSimpleValue(HbmManyToOne manyToManyMapping, string propertyPath, bool isNullable) + public void BindSimpleValue(HbmManyToOne manyToOneMapping, string propertyPath, bool isNullable) { - var formulas = manyToManyMapping.Formulas.ToArray(); - if (formulas.Length > 0) + ColumnsBinder binder = new ColumnsBinder(value, Mappings); + object[] columnsAndFormulas = manyToOneMapping.ColumnsAndFormulas.ToArray(); + + if (columnsAndFormulas.Length > 0) { - BindFormula(formulas); + this.AddColumnsAndOrFormulas(binder, columnsAndFormulas, isNullable); } else { - new ColumnsBinder(value, Mappings).Bind(manyToManyMapping.Columns, isNullable, - () => - new HbmColumn - { - name = mappings.NamingStrategy.PropertyToColumnName(propertyPath), - notnull = manyToManyMapping.notnull, - notnullSpecified = manyToManyMapping.notnullSpecified, - unique = manyToManyMapping.unique, - uniqueSpecified = true, - uniquekey = manyToManyMapping.uniquekey, - index = manyToManyMapping.index - }); + // No formulas or columns, so add default column + binder.Bind(new HbmColumn() + { + name = mappings.NamingStrategy.PropertyToColumnName(propertyPath), + notnull = manyToOneMapping.notnull, + notnullSpecified = manyToOneMapping.notnullSpecified, + unique = manyToOneMapping.unique, + uniqueSpecified = true, + uniquekey = manyToOneMapping.uniquekey, + index = manyToOneMapping.index + }, isNullable); } } @@ -212,7 +205,7 @@ var formulas = mapKeyManyToManyMapping.Formulas.ToArray(); if (formulas.Length > 0) { - BindFormula(formulas); + BindFormulas(formulas); } else { @@ -245,5 +238,34 @@ new HbmColumn {name = mappings.NamingStrategy.PropertyToColumnName(propertyPath),}); } + + /// <summary> + /// Bind columns and formulas in the order in which they were mapped. + /// </summary> + /// <param name="binder"></param> + /// <param name="columnsAndFormulas"></param> + /// <param name="isNullable"></param> + private void AddColumnsAndOrFormulas(ColumnsBinder binder, object[] columnsAndFormulas, bool isNullable) + { + foreach (object item in columnsAndFormulas) + { + if (item.GetType() == typeof(HbmFormula)) + this.BindFormula((HbmFormula)item); + + if (item.GetType() == typeof(HbmColumn)) + binder.Bind((HbmColumn)item, isNullable); + } + } + + private void BindFormula(HbmFormula formula) + { + value.AddFormula(new Formula { FormulaString = formula.Text.LinesToString() }); + } + + private void BindFormulas(IEnumerable<HbmFormula> formulas) + { + foreach (var hbmFormula in formulas) + this.BindFormula(hbmFormula); + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/SqlCommand/ANSIJoinFragment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/ANSIJoinFragment.cs 2010-07-20 00:34:18 UTC (rev 5016) +++ trunk/nhibernate/src/NHibernate/SqlCommand/ANSIJoinFragment.cs 2010-07-20 00:54:39 UTC (rev 5017) @@ -42,10 +42,6 @@ for (int j = 0; j < fkColumns.Length; j++) { - if (fkColumns[j].IndexOf('.') < 1) - { - throw new AssertionFailure("missing alias"); - } buffer.Add(fkColumns[j] + "=" + alias + StringHelper.Dot + pkColumns[j]); if (j < fkColumns.Length - 1) { Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SelectFragment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/SqlCommand/SelectFragment.cs 2010-07-20 00:34:18 UTC (rev 5016) +++ trunk/nhibernate/src/NHibernate/SqlCommand/SelectFragment.cs 2010-07-20 00:54:39 UTC (rev 5017) @@ -75,7 +75,8 @@ { for (int i = 0; i < columnNames.Length; i++) { - AddColumn(tableAlias, columnNames[i]); + if (columnNames[i] != null) + AddColumn(tableAlias, columnNames[i]); } return this; } @@ -84,7 +85,8 @@ { for (int i = 0; i < columnNames.Length; i++) { - AddColumn(tableAlias, columnNames[i], columnAliases[i]); + if (columnNames[i] != null) + AddColumn(tableAlias, columnNames[i], columnAliases[i]); } return this; } @@ -93,7 +95,8 @@ { for (int i = 0; i < formulas.Length; i++) { - AddFormula(tableAlias, formulas[i], formulaAliases[i]); + if (formulas[i] != null) + AddFormula(tableAlias, formulas[i], formulaAliases[i]); } return this; Modified: trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd =================================================================== --- trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2010-07-20 00:34:18 UTC (rev 5016) +++ trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2010-07-20 00:54:39 UTC (rev 5017) @@ -865,10 +865,8 @@ <xs:complexType> <xs:sequence> <xs:element ref="meta" minOccurs="0" maxOccurs="unbounded" /> - <xs:choice minOccurs="0" maxOccurs="unbounded"> - <xs:element ref="column" /> - <xs:element ref="formula" /> - </xs:choice> + <xs:element ref="column" minOccurs="0" maxOccurs="unbounded" /> + <xs:element ref="formula" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> <xs:attribute name="name" use="required" type="xs:string" /> <xs:attribute name="access" type="xs:string" /> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 00:34:18 UTC (rev 5016) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 00:54:39 UTC (rev 5017) @@ -1487,6 +1487,10 @@ <Compile Include="TransactionTest\TransactionNotificationFixture.cs" /> <Compile Include="TransformTests\AliasToBeanResultTransformerFixture.cs" /> <Compile Include="TransformTests\Simple.cs" /> + <Compile Include="TypedManyToOne\Address.cs" /> + <Compile Include="TypedManyToOne\AddressId.cs" /> + <Compile Include="TypedManyToOne\Customer.cs" /> + <Compile Include="TypedManyToOne\TypedManyToOneTest.cs" /> <Compile Include="TypeParameters\DefaultValueIntegerType.cs" /> <Compile Include="TypeParameters\DefinedTypeForIdFixture.cs" /> <Compile Include="TypeParameters\EntityCustomId.cs" /> @@ -1605,6 +1609,7 @@ <EmbeddedResource Include="Component\Basic\User.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2061\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2195\Mappings.hbm.xml" /> + <EmbeddedResource Include="TypedManyToOne\Customer.hbm.xml" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="CompositeCollection\BaseClassA.hbm.xml" /> @@ -1688,6 +1693,7 @@ <Folder Include="Component\Basic" /> <Folder Include="NHSpecificTest\NH2061" /> <Folder Include="NHSpecificTest\NH2195" /> + <Folder Include="TypedManyToOne" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="NHSpecificTest\NH386\Mappings.hbm.xml" /> Property changes on: trunk/nhibernate/src/NHibernate.Test/TypedManyToOne ___________________________________________________________________ Added: bugtraq:url + http://jira.nhibernate.org/browse/%BUGID% Added: bugtraq:logregex + NH-\d+ Added: trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/Address.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/Address.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/Address.cs 2010-07-20 00:54:39 UTC (rev 5017) @@ -0,0 +1,15 @@ +using System; + +namespace NHibernate.Test.TypedManyToOne +{ + [Serializable] + public class Address + { + public virtual AddressId AddressId {get; set;} + public virtual string Street { get; set; } + public virtual string City { get; set; } + public virtual string State { get; set; } + public virtual string Zip { get; set; } + public virtual Customer Customer { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/AddressId.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/AddressId.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/AddressId.cs 2010-07-20 00:54:39 UTC (rev 5017) @@ -0,0 +1,55 @@ +using System; + +namespace NHibernate.Test.TypedManyToOne +{ + [Serializable] + public class AddressId + { + public virtual String Type { get; set; } + public virtual String Id { get; set; } + private int? requestedHash; + + public AddressId(String type, String id) + { + Id = id; + Type = type; + } + + public AddressId() { } + + public override bool Equals(object obj) + { + return Equals(obj as AddressId); + } + + public virtual bool Equals(AddressId other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return other.Id == Id && Equals(other.Type, Type); + } + + public override int GetHashCode() + { + if (!requestedHash.HasValue) + { + unchecked + { + requestedHash = (Id.GetHashCode() * 397) ^ Type.GetHashCode(); + } + } + return requestedHash.Value; + } + + public override string ToString() + { + return Type + '#' + Id; + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/Customer.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/Customer.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/Customer.cs 2010-07-20 00:54:39 UTC (rev 5017) @@ -0,0 +1,13 @@ +using System; + +namespace NHibernate.Test.TypedManyToOne +{ + [Serializable] + public class Customer + { + public virtual string CustomerId { get; set; } + public virtual string Name {get; set;} + public virtual Address BillingAddress {get; set;} + public virtual Address ShippingAddress {get; set;} + } +} Added: trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/Customer.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/Customer.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/Customer.hbm.xml 2010-07-20 00:54:39 UTC (rev 5017) @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- + + Shows how to map a one-to-many relationship in the relational + schema to "typed" one-to-one associations in the object model. + We map the Address class twice, with different entity names, + specifying a filtering condition in each mapping. The typed + associations then reference the named entities. + +--> + +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.TypedManyToOne" + assembly="NHibernate.Test"> + + <class name="Customer" + select-before-update="true" + dynamic-update="true"> + + <id name="CustomerId"> + <generator class="assigned"/> + </id> + + <property name="Name" not-null="true"/> + + <many-to-one name="BillingAddress" entity-name="BillingAddress" cascade="persist,save-update,delete" fetch="join"> + <column name="BillingAddressId" /> + <formula>(case when Name='blah' then 'SHIPPING' else 'BILLING' end)</formula> + </many-to-one> + + <many-to-one name="ShippingAddress" entity-name="ShippingAddress" cascade="persist,save-update,delete" fetch="join"> + <column name="ShippingAddressId"/> + <formula>'SHIPPING'</formula> + </many-to-one> + + </class> + + <class name="Address" + table="Address" + entity-name="BillingAddress" + where="add_type='BILLING'" + check="add_type in ('BILLING', 'SHIPPING')" + select-before-update="true" + dynamic-update="true"> + + <composite-id name="AddressId" class="AddressId"> + <key-property name="Id"/> + <key-property name="Type" column="add_type" /> + </composite-id> + + <property name="Street" not-null="true"/> + <property name="City" not-null="true"/> + <property name="State" not-null="true"/> + <property name="Zip" not-null="true"/> + + </class> + + <class name="Address" + table="Address" + entity-name="ShippingAddress" + where="add_type='SHIPPING'" + check="add_type in ('BILLING', 'SHIPPING')" + select-before-update="true" + dynamic-update="true"> + + <composite-id name="AddressId" class="AddressId"> + <key-property name="Id"/> + <key-property name="Type" column="add_type" /> + </composite-id> + + <property name="Street" not-null="true"/> + <property name="City" not-null="true"/> + <property name="State" not-null="true"/> + <property name="Zip" not-null="true"/> + + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/TypedManyToOneTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/TypedManyToOneTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/TypedManyToOne/TypedManyToOneTest.cs 2010-07-20 00:54:39 UTC (rev 5017) @@ -0,0 +1,131 @@ +using System.Collections; +using NUnit.Framework; + +namespace NHibernate.Test.TypedManyToOne +{ + [TestFixture] + public class TypedManyToOneTest : TestCase + { + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override IList Mappings + { + get { return new[] { "TypedManyToOne.Customer.hbm.xml" }; } + } + + [Test] + public void TestCreateQuery() + { + var cust = new Customer(); + cust.CustomerId = "abc123"; + cust.Name = "Matt"; + + var ship = new Address(); + ship.Street = "peachtree rd"; + ship.State = "GA"; + ship.City = "ATL"; + ship.Zip = "30326"; + ship.AddressId = new AddressId("SHIPPING", "xyz123"); + ship.Customer = cust; + + var bill = new Address(); + bill.Street = "peachtree rd"; + bill.State = "GA"; + bill.City = "ATL"; + bill.Zip = "30326"; + bill.AddressId = new AddressId("BILLING", "xyz123"); + bill.Customer = cust; + + cust.BillingAddress = bill; + cust.ShippingAddress = ship; + + using(ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Persist(cust); + t.Commit(); + } + + using(ISession s = sessions.OpenSession()) + using(ITransaction t = s.BeginTransaction()) + { + try + { + IList results = s.CreateQuery("from Customer cust left join fetch cust.BillingAddress where cust.CustomerId='abc123'").List(); + //IList results = s.CreateQuery("from Customer cust left join fetch cust.BillingAddress left join fetch cust.ShippingAddress").List(); + cust = (Customer)results[0]; + Assert.That(NHibernateUtil.IsInitialized(cust.ShippingAddress), Is.False); + Assert.That(NHibernateUtil.IsInitialized(cust.BillingAddress), Is.True); + Assert.That(cust.BillingAddress.Zip, Is.EqualTo("30326")); + Assert.That(cust.ShippingAddress.Zip, Is.EqualTo("30326")); + Assert.That(cust.BillingAddress.AddressId.Type, Is.EqualTo("BILLING")); + Assert.That(cust.ShippingAddress.AddressId.Type, Is.EqualTo("SHIPPING")); + t.Commit(); + } + catch + { + throw; + } + } + + using(ISession s = sessions.OpenSession()) + using(ITransaction t = s.BeginTransaction()) + { + try + { + s.SaveOrUpdate(cust); + ship = cust.ShippingAddress; + cust.ShippingAddress = null; + s.Delete("ShippingAddress", ship); + s.Flush(); + + Assert.That(s.Get("ShippingAddress", ship.AddressId), Is.Null); + s.Delete(cust); + + t.Commit(); + } + catch + { + throw; + } + } + } + + [Test] + public void TestCreateQueryNull() + { + var cust = new Customer(); + cust.CustomerId = "xyz123"; + cust.Name = "Matt"; + + using(ISession s = sessions.OpenSession()) + using(ITransaction t = s.BeginTransaction()) + { + s.Persist(cust); + t.Commit(); + } + + using(ISession s = sessions.OpenSession()) + using(ITransaction t = s.BeginTransaction()) + { + try + { + IList results = s.CreateQuery("from Customer cust left join fetch cust.BillingAddress where cust.CustomerId='xyz123'").List(); + //IList results = s.CreateQuery("from Customer cust left join fetch cust.BillingAddress left join fetch cust.ShippingAddress").List(); + cust = (Customer)results[0]; + Assert.That(cust.ShippingAddress, Is.Null); + Assert.That(cust.BillingAddress, Is.Null); + s.Delete(cust); + t.Commit(); + } + catch + { + throw; + } + } + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jul...@us...> - 2010-07-20 00:34:24
|
Revision: 5016 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5016&view=rev Author: julian-maughan Date: 2010-07-20 00:34:18 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Point to correct Debug folder Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.nunit Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.nunit =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.nunit 2010-07-19 17:28:53 UTC (rev 5015) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.nunit 2010-07-20 00:34:18 UTC (rev 5016) @@ -1,9 +1,9 @@ <NUnitProject> - <Settings activeconfig="Debug" /> - <Config name="Debug" appbase="bin\Debug" configfile="NHibernate.Test.dll.config" binpathtype="Auto"> - <assembly path="NHibernate.Test.dll" /> - </Config> - <Config name="Release" appbase="bin\Release" configfile="NHibernate.Test.dll.config" binpathtype="Auto"> - <assembly path="NHibernate.Test.dll" /> - </Config> + <Settings activeconfig="Debug" /> + <Config name="Debug" appbase="bin\Debug-2.0" configfile="NHibernate.Test.dll.config" binpathtype="Auto"> + <assembly path="NHibernate.Test.dll" /> + </Config> + <Config name="Release" appbase="bin\Release" configfile="NHibernate.Test.dll.config" binpathtype="Auto"> + <assembly path="NHibernate.Test.dll" /> + </Config> </NUnitProject> \ 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: <jul...@us...> - 2010-07-19 17:28:59
|
Revision: 5015 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5015&view=rev Author: julian-maughan Date: 2010-07-19 17:28:53 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Fix for failing test Components/Basic/TestMergeComponent. Refinement of contributed patch (see NH-2011 and NH-2061) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2010-07-19 15:31:18 UTC (rev 5014) +++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2010-07-19 17:28:53 UTC (rev 5015) @@ -1121,14 +1121,14 @@ // need to extract the component values and check for subtype replacements... IAbstractComponentType componentType = (IAbstractComponentType)types[i]; IType[] subtypes = componentType.Subtypes; - object[] origComponentValues = original[i] == null - ? new object[subtypes.Length] - : componentType.GetPropertyValues(original[i], session); - object[] targetComponentValues = componentType.GetPropertyValues(target[i], session); - object[] componentCopy = ReplaceAssociations(origComponentValues, targetComponentValues, subtypes, session, null, copyCache, - foreignKeyDirection); - if (!componentType.IsAnyType) + object[] origComponentValues = original[i] == null ? new object[subtypes.Length] : componentType.GetPropertyValues(original[i], session); + object[] targetComponentValues = target[i] == null ? new object[subtypes.Length] : componentType.GetPropertyValues(target[i], session); + + object[] componentCopy = ReplaceAssociations(origComponentValues, targetComponentValues, subtypes, session, null, copyCache, foreignKeyDirection); + + if (!componentType.IsAnyType && target[i] != null) componentType.SetPropertyValues(target[i], componentCopy, session.EntityMode); + copied[i] = target[i]; } else if (!types[i].IsAssociationType) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jul...@us...> - 2010-07-19 15:31:24
|
Revision: 5014 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5014&view=rev Author: julian-maughan Date: 2010-07-19 15:31:18 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Mapping files for NH-2102 added to NHibernate.Test project as embedded resources. Tests should now pass - Ignore attributes removed. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Modified: trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs 2010-07-19 14:59:28 UTC (rev 5013) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs 2010-07-19 15:31:18 UTC (rev 5014) @@ -8,7 +8,7 @@ namespace NHibernate.Test.Component.Basic { - [TestFixture, Ignore("Not fixed yet.")] + [TestFixture] public class ComponentTest : TestCase { protected override string MappingsAssembly Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs 2010-07-19 14:59:28 UTC (rev 5013) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs 2010-07-19 15:31:18 UTC (rev 5014) @@ -4,7 +4,7 @@ namespace NHibernate.Test.NHSpecificTest.NH2061 { - [TestFixture, Ignore("Not fixed yet.")] + [TestFixture] public class Fixture : BugTestCase { [Test] Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-19 14:59:28 UTC (rev 5013) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-19 15:31:18 UTC (rev 5014) @@ -1602,8 +1602,8 @@ <Compile Include="VersionTest\Task.cs" /> <Compile Include="VersionTest\Thing.cs" /> <Compile Include="VersionTest\VersionFixture.cs" /> - <None Include="Component\Basic\User.hbm.xml" /> - <None Include="NHSpecificTest\NH2061\Mappings.hbm.xml" /> + <EmbeddedResource Include="Component\Basic\User.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH2061\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2195\Mappings.hbm.xml" /> </ItemGroup> <ItemGroup> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jul...@us...> - 2010-07-19 14:59:35
|
Revision: 5013 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5013&view=rev Author: julian-maughan Date: 2010-07-19 14:59:28 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Updated SQLiteDialect to explicitly declare that it does not support limit parameters (SupportsVariableLimit = false). This makes it consistent with the implementation of GetLimitString which does not use parameters when paging, and fixes the problem of non-limit parameter types getting mixed up (ref. NH-2195, NH-2129) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2195/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2195/DomainClass.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2195/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2195/SQLiteMultiCriteriaTest.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs 2010-07-19 14:46:08 UTC (rev 5012) +++ trunk/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs 2010-07-19 14:59:28 UTC (rev 5013) @@ -1,9 +1,9 @@ using System.Data; +using System.Data.Common; using System.Text; using NHibernate.Dialect.Function; using NHibernate.SqlCommand; using NHibernate.Util; -using System.Data.Common; namespace NHibernate.Dialect { @@ -114,6 +114,11 @@ get { return false; } } + public override bool SupportsVariableLimit + { + get { return false; } + } + public override bool SupportsIdentityColumns { get { return true; } @@ -138,19 +143,19 @@ public override string Qualify(string catalog, string schema, string table) { StringBuilder qualifiedName = new StringBuilder(); - bool quoted = false; + bool quoted = false; - if (!string.IsNullOrEmpty(catalog)) + if (!string.IsNullOrEmpty(catalog)) { - if (catalog.StartsWith(OpenQuote.ToString())) - { - catalog = catalog.Substring(1, catalog.Length - 1); - quoted = true; - } - if (catalog.EndsWith(CloseQuote.ToString())) + if (catalog.StartsWith(OpenQuote.ToString())) { - catalog = catalog.Substring(0, catalog.Length - 1); - quoted = true; + catalog = catalog.Substring(1, catalog.Length - 1); + quoted = true; + } + if (catalog.EndsWith(CloseQuote.ToString())) + { + catalog = catalog.Substring(0, catalog.Length - 1); + quoted = true; } qualifiedName.Append(catalog).Append(StringHelper.Underscore); } @@ -158,32 +163,32 @@ { if (schema.StartsWith(OpenQuote.ToString())) { - schema = schema.Substring(1, schema.Length - 1); - quoted = true; + schema = schema.Substring(1, schema.Length - 1); + quoted = true; } - if (schema.EndsWith(CloseQuote.ToString())) - { - schema = schema.Substring(0, schema.Length - 1); - quoted = true; - } - qualifiedName.Append(schema).Append(StringHelper.Underscore); + if (schema.EndsWith(CloseQuote.ToString())) + { + schema = schema.Substring(0, schema.Length - 1); + quoted = true; + } + qualifiedName.Append(schema).Append(StringHelper.Underscore); } if (table.StartsWith(OpenQuote.ToString())) { - table = table.Substring(1, table.Length - 1); - quoted = true; + table = table.Substring(1, table.Length - 1); + quoted = true; } - if (table.EndsWith(CloseQuote.ToString())) - { - table = table.Substring(0, table.Length - 1); - quoted = true; - } + if (table.EndsWith(CloseQuote.ToString())) + { + table = table.Substring(0, table.Length - 1); + quoted = true; + } - string name = qualifiedName.Append(table).ToString(); - if (quoted) - return OpenQuote + name + CloseQuote; - return name; + string name = qualifiedName.Append(table).ToString(); + if (quoted) + return OpenQuote + name + CloseQuote; + return name; } @@ -215,4 +220,4 @@ return pagingBuilder.ToSqlString(); } } -} +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2195/DomainClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2195/DomainClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2195/DomainClass.cs 2010-07-19 14:59:28 UTC (rev 5013) @@ -0,0 +1,29 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH2195 +{ + public class DomainClass + { + private string stringData; + private int intData; + private int id; + + public int Id + { + get { return id; } + set { id = value; } + } + + public string StringData + { + get { return stringData; } + set { stringData = value; } + } + + public int IntData + { + get { return intData; } + set { intData = value; } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2195/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2195/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2195/Mappings.hbm.xml 2010-07-19 14:59:28 UTC (rev 5013) @@ -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.NH2195" + default-access="field.camelcase" + default-lazy="false"> + + <class name="DomainClass"> + <id name="Id"> + <generator class="assigned" /> + </id> + <property name="StringData" /> + <property name="IntData" /> + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2195/SQLiteMultiCriteriaTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2195/SQLiteMultiCriteriaTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2195/SQLiteMultiCriteriaTest.cs 2010-07-19 14:59:28 UTC (rev 5013) @@ -0,0 +1,145 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using NHibernate.Criterion; +using NHibernate.Dialect; +using NHibernate.Tool.hbm2ddl; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH2195 +{ + [TestFixture] + public class SQLiteMultiCriteriaTest : BugTestCase + { + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession session = this.OpenSession()) + { + DomainClass entity = new DomainClass(); + entity.Id = 1; + entity.StringData = "John Doe"; + entity.IntData = 1; + session.Save(entity); + + entity = new DomainClass(); + entity.Id = 2; + entity.StringData = "Jane Doe"; + entity.IntData = 2; + session.Save(entity); + session.Flush(); + } + } + + private object SchemaExport(NHibernate.Cfg.Configuration cfg) + { + throw new NotImplementedException(); + } + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession session = this.OpenSession()) + { + string hql = "from System.Object"; + session.Delete(hql); + session.Flush(); + } + } + + protected override bool AppliesTo(NHibernate.Dialect.Dialect dialect) + { + return dialect as SQLiteDialect != null; + } + + [Test] + public void SingleCriteriaQueriesWithIntsShouldExecuteCorrectly() + { + // Test querying IntData + using (ISession session = this.OpenSession()) + { + ICriteria criteriaWithPagination = session.CreateCriteria<DomainClass>(); + criteriaWithPagination.Add(Expression.Le("IntData",2)); + ICriteria criteriaWithRowCount = CriteriaTransformer.Clone(criteriaWithPagination); + criteriaWithPagination.SetFirstResult(0).SetMaxResults(1); + criteriaWithRowCount.SetProjection(Projections.RowCountInt64()); + + IList<DomainClass> list = criteriaWithPagination.List<DomainClass>(); + + Assert.AreEqual(2, criteriaWithRowCount.UniqueResult<long>()); + Assert.AreEqual(1, list.Count); + } + } + + [Test] + public void SingleCriteriaQueriesWithStringsShouldExecuteCorrectly() + { + // Test querying StringData + using (ISession session = this.OpenSession()) + { + ICriteria criteriaWithPagination = session.CreateCriteria<DomainClass>(); + criteriaWithPagination.Add(Expression.Like("StringData", "%Doe%")); + ICriteria criteriaWithRowCount = CriteriaTransformer.Clone(criteriaWithPagination); + criteriaWithPagination.SetFirstResult(0).SetMaxResults(1); + criteriaWithRowCount.SetProjection(Projections.RowCountInt64()); + + IList<DomainClass> list = criteriaWithPagination.List<DomainClass>(); + + Assert.AreEqual(2, criteriaWithRowCount.UniqueResult<long>()); + Assert.AreEqual(1, list.Count); + } + } + + [Test] + public void MultiCriteriaQueriesWithIntsShouldExecuteCorrectly() + { + // Test querying IntData + using (ISession session = this.OpenSession()) + { + ICriteria criteriaWithPagination = session.CreateCriteria<DomainClass>(); + criteriaWithPagination.Add(Expression.Le("IntData", 2)); + ICriteria criteriaWithRowCount = CriteriaTransformer.Clone(criteriaWithPagination); + criteriaWithPagination.SetFirstResult(0).SetMaxResults(1); + criteriaWithRowCount.SetProjection(Projections.RowCountInt64()); + + IMultiCriteria multiCriteria = session.CreateMultiCriteria(); + multiCriteria.Add(criteriaWithPagination); + multiCriteria.Add(criteriaWithRowCount); + + IList results = multiCriteria.List(); + long numResults = (long)((IList)results[1])[0]; + IList list = (IList)results[0]; + + Assert.AreEqual(2, criteriaWithRowCount.UniqueResult<long>()); + Assert.AreEqual(1, list.Count); + } + } + + [Test] + public void MultiCriteriaQueriesWithStringsShouldExecuteCorrectly() + { + // Test querying StringData + using (ISession session = this.OpenSession()) + { + ICriteria criteriaWithPagination = session.CreateCriteria<DomainClass>(); + criteriaWithPagination.Add(Expression.Like("StringData", "%Doe%")); + ICriteria criteriaWithRowCount = CriteriaTransformer.Clone(criteriaWithPagination); + criteriaWithPagination.SetFirstResult(0).SetMaxResults(1); + criteriaWithRowCount.SetProjection(Projections.RowCountInt64()); + + IMultiCriteria multiCriteria = session.CreateMultiCriteria(); + multiCriteria.Add(criteriaWithPagination); + multiCriteria.Add(criteriaWithRowCount); + + IList results = multiCriteria.List(); + + long numResults = (long)((IList)results[1])[0]; + IList list = (IList)results[0]; + + Assert.AreEqual(2, criteriaWithRowCount.UniqueResult<long>()); + Assert.AreEqual(1, list.Count); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-19 14:46:08 UTC (rev 5012) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-19 14:59:28 UTC (rev 5013) @@ -738,6 +738,8 @@ <Compile Include="NHSpecificTest\NH2113\Model.cs" /> <Compile Include="NHSpecificTest\NH2192\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2192\Model.cs" /> + <Compile Include="NHSpecificTest\NH2195\DomainClass.cs" /> + <Compile Include="NHSpecificTest\NH2195\SQLiteMultiCriteriaTest.cs" /> <Compile Include="NHSpecificTest\NH2201\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2201\Model.cs" /> <Compile Include="NHSpecificTest\NH2230\Domain.cs" /> @@ -1602,6 +1604,7 @@ <Compile Include="VersionTest\VersionFixture.cs" /> <None Include="Component\Basic\User.hbm.xml" /> <None Include="NHSpecificTest\NH2061\Mappings.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH2195\Mappings.hbm.xml" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="CompositeCollection\BaseClassA.hbm.xml" /> @@ -1684,6 +1687,7 @@ <Folder Include="Component" /> <Folder Include="Component\Basic" /> <Folder Include="NHSpecificTest\NH2061" /> + <Folder Include="NHSpecificTest\NH2195" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="NHSpecificTest\NH386\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-19 14:46:17
|
Revision: 5012 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5012&view=rev Author: fabiomaulo Date: 2010-07-19 14:46:08 +0000 (Mon, 19 Jul 2010) Log Message: ----------- - Minor (moved assignment for UnwrapProxy in many-to-one) - Added assignment for UnwrapProxy in one-to-one) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs 2010-07-19 14:32:15 UTC (rev 5011) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs 2010-07-19 14:46:08 UTC (rev 5012) @@ -107,7 +107,6 @@ var value = new ManyToOne(table); BindManyToOne(manyToOneMapping, value, propertyName, true); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); - property.UnwrapProxy = manyToOneMapping.Lazy == HbmLaziness.NoProxy; BindManyToOneProperty(manyToOneMapping, property); } else if ((componentMapping = entityPropertyMapping as HbmComponent) != null) @@ -304,6 +303,7 @@ private void BindOneToOneProperty(HbmOneToOne oneToOneMapping, Property property) { property.Cascade = oneToOneMapping.cascade ?? mappings.DefaultCascade; + property.UnwrapProxy = oneToOneMapping.Lazy == HbmLaziness.NoProxy; var toOne = property.Value as ToOne; if (toOne != null) { @@ -329,6 +329,7 @@ private void BindManyToOneProperty(HbmManyToOne manyToOneMapping, Property property) { property.Cascade = manyToOneMapping.cascade ?? mappings.DefaultCascade; + property.UnwrapProxy = manyToOneMapping.Lazy == HbmLaziness.NoProxy; property.IsUpdateable = manyToOneMapping.update; property.IsInsertable = manyToOneMapping.insert; var toOne = property.Value as ToOne; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-19 14:32:22
|
Revision: 5011 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5011&view=rev Author: fabiomaulo Date: 2010-07-19 14:32:15 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Not fixed yet test for NH-2102 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Model.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs 2010-07-19 14:32:15 UTC (rev 5011) @@ -0,0 +1,52 @@ +using NHibernate.ByteCode.Castle; +using NHibernate.Cfg; +using NUnit.Framework; +using SharpTestsEx; + +namespace NHibernate.Test.NHSpecificTest.NH2102 +{ + [TestFixture, Ignore("Not fixed yet.")] + public class Fixture : BugTestCase + { + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.ProxyFactoryFactoryClass, + typeof(ProxyFactoryFactory).AssemblyQualifiedName); + } + + [Test] + public void EntityWithConstrainedLazyLoadedOneToOneShouldNotGenerateFieldInterceptingProxy() + { + try + { + using (var s = OpenSession()) + { + var person = new Person { Id = 1, Name = "Person1" }; + var employee = new Employee { Id = 1, Name = "Emp1", Person = person }; + + s.Save(person); + s.Save(employee); + + s.Flush(); + } + + using (var s = OpenSession()) + { + var employee = s.Get<Employee>(1); + + employee.Should().Be.OfType<Employee>(); + } + } + finally + { + using (var s = OpenSession()) + { + s.Delete("from Employee"); + s.Delete("from Person"); + + s.Flush(); + } + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Mappings.hbm.xml 2010-07-19 14:32:15 UTC (rev 5011) @@ -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.NH2102"> + + <class name="Person"> + <id name="Id"/> + <property name="Name"></property> + </class> + + <class name="Employee"> + <id name="Id"/> + <property name="Name"></property> + + <one-to-one name="Person" constrained="true" lazy="proxy"/> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Model.cs 2010-07-19 14:32:15 UTC (rev 5011) @@ -0,0 +1,16 @@ +namespace NHibernate.Test.NHSpecificTest.NH2102 +{ + public class Person + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + } + + public class Employee + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + + public virtual Person Person { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-19 14:31:25 UTC (rev 5010) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-19 14:32:15 UTC (rev 5011) @@ -457,6 +457,8 @@ <Compile Include="NHSpecificTest\NH2069\Test.cs" /> <Compile Include="NHSpecificTest\NH2069\Test2.cs" /> <Compile Include="NHSpecificTest\NH2069\TestBase.cs" /> + <Compile Include="NHSpecificTest\NH2102\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2102\Model.cs" /> <Compile Include="NHSpecificTest\NH2189\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2189\Model.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\AbstractIntEnumsBagFixture.cs" /> @@ -2174,6 +2176,7 @@ <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2102\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2069\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2230\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2189\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-19 14:31:32
|
Revision: 5010 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5010&view=rev Author: fabiomaulo Date: 2010-07-19 14:31:25 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Marked tests as Ignore Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs 2010-07-19 14:22:36 UTC (rev 5009) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs 2010-07-19 14:31:25 UTC (rev 5010) @@ -8,7 +8,7 @@ namespace NHibernate.Test.Component.Basic { - [TestFixture] + [TestFixture, Ignore("Not fixed yet.")] public class ComponentTest : TestCase { protected override string MappingsAssembly Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs 2010-07-19 14:22:36 UTC (rev 5009) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs 2010-07-19 14:31:25 UTC (rev 5010) @@ -4,7 +4,7 @@ namespace NHibernate.Test.NHSpecificTest.NH2061 { - [TestFixture] + [TestFixture, Ignore("Not fixed yet.")] public class Fixture : BugTestCase { [Test] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jul...@us...> - 2010-07-19 14:22:44
|
Revision: 5009 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5009&view=rev Author: julian-maughan Date: 2010-07-19 14:22:36 +0000 (Mon, 19 Jul 2010) Log Message: ----------- NHibernate.Driver.SQLite20Driver should be used. SQLiteDriver is for an old .NET 1.x version. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Config.Templates/SQLite.cfg.xml Modified: trunk/nhibernate/src/NHibernate.Config.Templates/SQLite.cfg.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Config.Templates/SQLite.cfg.xml 2010-07-18 15:05:47 UTC (rev 5008) +++ trunk/nhibernate/src/NHibernate.Config.Templates/SQLite.cfg.xml 2010-07-19 14:22:36 UTC (rev 5009) @@ -6,7 +6,7 @@ --> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > <session-factory name="NHibernate.Test"> - <property name="connection.driver_class">NHibernate.Driver.SQLiteDriver</property> + <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property> <property name="connection.connection_string"> Data Source=nhibernate.db;Version=3 </property> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jul...@us...> - 2010-07-18 15:05:54
|
Revision: 5008 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5008&view=rev Author: julian-maughan Date: 2010-07-18 15:05:47 +0000 (Sun, 18 Jul 2010) Log Message: ----------- Added Hibernate component tests, and contributed test for issue NH-2061 (Merge operation causes exception for null components that contain many-to-many relations) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs trunk/nhibernate/src/NHibernate.Test/Legacy/SQLLoaderTest.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Component/ trunk/nhibernate/src/NHibernate.Test/Component/Basic/ trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs trunk/nhibernate/src/NHibernate.Test/Component/Basic/Employee.cs trunk/nhibernate/src/NHibernate.Test/Component/Basic/OptionalComponent.cs trunk/nhibernate/src/NHibernate.Test/Component/Basic/Person.cs trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.cs trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Model.cs Added: trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,417 @@ +using System; +using System.Collections.Generic; +using NHibernate; +using NHibernate.Cfg; +using NHibernate.Criterion; +using NHibernate.Transaction; +using NUnit.Framework; + +namespace NHibernate.Test.Component.Basic +{ + [TestFixture] + public class ComponentTest : TestCase + { + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override System.Collections.IList Mappings + { + get { return new string[] { "Component.Basic.User.hbm.xml" }; } + } + + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(NHibernate.Cfg.Environment.GenerateStatistics, "true"); + } + + protected override void OnTearDown() + { + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Delete("from User"); + s.Delete("from Employee"); + t.Commit(); + } + + base.OnTearDown(); + } + + [Test] + public void TestUpdateFalse() + { + User u; + + sessions.Statistics.Clear(); + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + u = new User("gavin", "secret", new Person("Gavin King", new DateTime(1999, 12, 31), "Karbarook Ave")); + s.Persist(u); + s.Flush(); + u.Person.Name = "XXXXYYYYY"; + t.Commit(); + s.Close(); + } + + Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(1)); + Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0)); + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + u = (User)s.Get(typeof(User), "gavin"); + Assert.That(u.Person.Name, Is.EqualTo("Gavin King")); + s.Delete(u); + t.Commit(); + s.Close(); + } + + Assert.That(sessions.Statistics.EntityDeleteCount, Is.EqualTo(1)); + } + + [Test] + public void TestComponent() + { + User u; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + u = new User("gavin", "secret", new Person("Gavin King", new DateTime(1999, 12, 31), "Karbarook Ave")); + s.Persist(u); + s.Flush(); + u.Person.ChangeAddress("Phipps Place"); + t.Commit(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + u = (User)s.Get(typeof(User), "gavin"); + Assert.That(u.Person.Address, Is.EqualTo("Phipps Place")); + Assert.That(u.Person.PreviousAddress, Is.EqualTo("Karbarook Ave")); + Assert.That(u.Person.Yob, Is.EqualTo(u.Person.Dob.Year)); + u.Password = "$ecret"; + t.Commit(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + u = (User)s.Get(typeof(User), "gavin"); + Assert.That(u.Person.Address, Is.EqualTo("Phipps Place")); + Assert.That(u.Person.PreviousAddress, Is.EqualTo("Karbarook Ave")); + Assert.That(u.Password, Is.EqualTo("$ecret")); + s.Delete(u); + t.Commit(); + } + } + + [Test] + public void TestComponentStateChangeAndDirtiness() + { + // test for HHH-2366 + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + User u = new User("steve", "hibernater", new Person( "Steve Ebersole", new DateTime(1999, 12, 31), "Main St")); + s.Persist(u); + s.Flush(); + long intialUpdateCount = sessions.Statistics.EntityUpdateCount; + u.Person.Address = "Austin"; + s.Flush(); + Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(intialUpdateCount + 1)); + intialUpdateCount = sessions.Statistics.EntityUpdateCount; + u.Person.Address = "Cedar Park"; + s.Flush(); + Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(intialUpdateCount + 1)); + s.Delete(u); + t.Commit(); + s.Close(); + } + } + + [Test] + [Ignore("Ported from Hibernate. Read properties not supported in NH yet.")] + public void TestCustomColumnReadAndWrite() + { + const double HEIGHT_INCHES = 73; + const double HEIGHT_CENTIMETERS = HEIGHT_INCHES * 2.54d; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + User u = new User("steve", "hibernater", new Person( "Steve Ebersole", new DateTime(1999, 12, 31), "Main St")); + u.Person.HeightInches = HEIGHT_INCHES; + s.Persist(u); + s.Flush(); + + // Test value conversion during insert + double heightViaSql = (double)s.CreateSQLQuery("select height_centimeters from t_user where t_user.username='steve'").UniqueResult(); + Assert.That(heightViaSql, Is.EqualTo(HEIGHT_CENTIMETERS).Within(0.01d)); + + // Test projection + double heightViaHql = (double)s.CreateQuery("select u.Person.HeightInches from User u where u.Id = 'steve'").UniqueResult(); + Assert.That(heightViaHql, Is.EqualTo(HEIGHT_INCHES).Within(0.01d)); + + // Test restriction and entity load via criteria + u = (User)s.CreateCriteria(typeof(User)) + .Add(Restrictions.Between("Person.HeightInches", HEIGHT_INCHES - 0.01d, HEIGHT_INCHES + 0.01d)) + .UniqueResult(); + Assert.That(u.Person.HeightInches, Is.EqualTo(HEIGHT_INCHES).Within(0.01d)); + + // Test predicate and entity load via HQL + u = (User)s.CreateQuery("from User u where u.Person.HeightInches between ? and ?") + .SetDouble(0, HEIGHT_INCHES - 0.01d) + .SetDouble(1, HEIGHT_INCHES + 0.01d) + .UniqueResult(); + + Assert.That(u.Person.HeightInches, Is.EqualTo(HEIGHT_INCHES).Within(0.01d)); + + // Test update + u.Person.HeightInches = 1; + s.Flush(); + heightViaSql = (double)s.CreateSQLQuery("select height_centimeters from t_user where t_user.username='steve'").UniqueResult(); + Assert.That(heightViaSql, Is.EqualTo(2.54d).Within(0.01d)); + s.Delete(u); + t.Commit(); + s.Close(); + } + } + + [Test] + [Ignore("Ported from Hibernate - failing in NH")] + public void TestComponentQueries() + { + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + Employee emp = new Employee(); + emp.HireDate = new DateTime(1999, 12, 31); + emp.Person = new Person(); + emp.Person.Name = "steve"; + emp.Person.Dob = new DateTime(1999, 12, 31); + s.Save(emp); + + s.CreateQuery("from Employee e where e.Person = :p and 1=1 and 2=2").SetParameter("p", emp.Person).List(); + s.CreateQuery("from Employee e where :p = e.Person").SetParameter("p", emp.Person).List(); + s.CreateQuery("from Employee e where e.Person = ('steve', current_timestamp)").List(); + + s.Delete( emp ); + t.Commit(); + s.Close(); + } + } + + [Test] + public void TestComponentFormulaQuery() + { + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.CreateQuery("from User u where u.Person.Yob = 1999").List(); + s.CreateCriteria(typeof(User)) + .Add(Property.ForName("Person.Yob").Between(1999, 2002)) + .List(); + + if (Dialect.SupportsRowValueConstructorSyntax) + { + s.CreateQuery("from User u where u.Person = ('gavin', :dob, 'Peachtree Rd', 'Karbarook Ave', 1974, 'Peachtree Rd')") + .SetDateTime("dob", new DateTime(1974, 3, 25)).List(); + s.CreateQuery("from User where Person = ('gavin', :dob, 'Peachtree Rd', 'Karbarook Ave', 1974, 'Peachtree Rd')") + .SetDateTime("dob", new DateTime(1974, 3, 25)).List(); + } + t.Commit(); + s.Close(); + } + } + + [Test] + public void TestNamedQuery() + { + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.GetNamedQuery("userNameIn") + .SetParameterList( "nameList", new object[] {"1ovthafew", "turin", "xam"} ) + .List(); + t.Commit(); + s.Close(); + } + } + + [Test] + public void TestMergeComponent() + { + Employee emp = null; + IEnumerator<Employee> enumerator = null; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = new Employee(); + emp.HireDate = new DateTime(1999, 12, 31); + emp.Person = new Person(); + emp.Person.Name = "steve"; + emp.Person.Dob = new DateTime(1999, 12, 31); + s.Persist(emp); + t.Commit(); + s.Close(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Get(typeof(Employee), emp.Id); + t.Commit(); + s.Close(); + } + + Assert.That(emp.OptionalComponent, Is.Null); + + emp.OptionalComponent = new OptionalComponent(); + emp.OptionalComponent.Value1 = "emp-value1"; + emp.OptionalComponent.Value2 = "emp-value2"; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Merge(emp); + t.Commit(); + s.Close(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Get(typeof(Employee), emp.Id); + t.Commit(); + s.Close(); + } + + Assert.That(emp.OptionalComponent.Value1, Is.EqualTo("emp-value1")); + Assert.That(emp.OptionalComponent.Value2, Is.EqualTo("emp-value2")); + + emp.OptionalComponent.Value1 = null; + emp.OptionalComponent.Value2 = null; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Merge(emp); + t.Commit(); + s.Close(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Get(typeof(Employee), emp.Id); + NHibernateUtil.Initialize(emp.DirectReports); + t.Commit(); + s.Close(); + } + + Assert.That(emp.OptionalComponent, Is.Null); + + Employee emp1 = new Employee(); + emp1.HireDate = new DateTime(1999, 12, 31); + emp1.Person = new Person(); + emp1.Person.Name = "bozo"; + emp1.Person.Dob = new DateTime(1999, 12, 31); + emp.DirectReports.Add(emp1); + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Merge(emp); + t.Commit(); + s.Close(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Get(typeof(Employee), emp.Id); + NHibernateUtil.Initialize(emp.DirectReports); + t.Commit(); + s.Close(); + } + + Assert.That(emp.DirectReports.Count, Is.EqualTo(1)); + + enumerator = emp.DirectReports.GetEnumerator(); + enumerator.MoveNext(); + emp1 = (Employee)enumerator.Current; + Assert.That(emp1.OptionalComponent, Is.Null); + + emp1.OptionalComponent = new OptionalComponent(); + emp1.OptionalComponent.Value1 = "emp1-value1"; + emp1.OptionalComponent.Value2 = "emp1-value2"; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Merge(emp); + t.Commit(); + s.Close(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Get(typeof(Employee), emp.Id); + NHibernateUtil.Initialize(emp.DirectReports); + t.Commit(); + s.Close(); + } + + Assert.That(emp.DirectReports.Count, Is.EqualTo(1)); + + enumerator = emp.DirectReports.GetEnumerator(); + enumerator.MoveNext(); + emp1 = (Employee)enumerator.Current; + Assert.That(emp1.OptionalComponent.Value1, Is.EqualTo("emp1-value1")); + Assert.That(emp1.OptionalComponent.Value2, Is.EqualTo("emp1-value2")); + + emp1.OptionalComponent.Value1 = null; + emp1.OptionalComponent.Value2 = null; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Merge(emp); + t.Commit(); + s.Close(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Get(typeof(Employee), emp.Id); + NHibernateUtil.Initialize(emp.DirectReports); + t.Commit(); + s.Close(); + } + + Assert.That(emp.DirectReports.Count, Is.EqualTo(1)); + + enumerator = emp.DirectReports.GetEnumerator(); + enumerator.MoveNext(); + emp1 = (Employee)enumerator.Current; + Assert.That(emp1.OptionalComponent, Is.Null); + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Delete( emp ); + t.Commit(); + s.Close(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Component/Basic/Employee.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/Employee.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/Employee.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,18 @@ +using System; +using Iesi.Collections.Generic; + +namespace NHibernate.Test.Component.Basic +{ + public class Employee + { + public virtual long Id { get; set; } + + public virtual Person Person { get; set; } + + public virtual DateTime HireDate { get; set; } + + public virtual OptionalComponent OptionalComponent { get; set; } + + public virtual ISet<Employee> DirectReports { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Component/Basic/OptionalComponent.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/OptionalComponent.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/OptionalComponent.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,8 @@ +namespace NHibernate.Test.Component.Basic +{ + public class OptionalComponent + { + public string Value1 { get; set; } + public string Value2 { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Component/Basic/Person.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/Person.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/Person.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,75 @@ +using System; + +namespace NHibernate.Test.Component.Basic +{ + public class Person + { + private string name; + private DateTime dob; + private string address; + private string currentAddress; + private string previousAddress; + private int yob; + private double heightInches; + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual DateTime Dob + { + get { return dob; } + set { dob = value; } + } + + public virtual string Address + { + get { return address; } + set { address = value; } + } + + public virtual string CurrentAddress + { + get { return currentAddress; } + set { currentAddress = value; } + } + + public virtual string PreviousAddress + { + get { return previousAddress; } + set { previousAddress = value; } + } + + public virtual int Yob + { + get { return yob; } + set { yob = value; } + } + + public virtual double HeightInches + { + get { return heightInches; } + set { heightInches = value; } + } + + public Person() + { + } + + public Person(String name, DateTime dob, String address) + { + this.name = name; + this.dob = dob; + this.address = address; + this.currentAddress = address; + } + + public virtual void ChangeAddress(String add) + { + this.PreviousAddress = this.Address; + this.Address = add; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,47 @@ +using System; + +namespace NHibernate.Test.Component.Basic +{ + public class User + { + private string userName; + private string password; + private Person person; + private DateTime lastModified; + + public virtual string UserName + { + get { return userName; } + set { userName = value; } + } + + public virtual string Password + { + get { return password; } + set { password = value; } + } + + public virtual Person Person + { + get { return person; } + set { person = value; } + } + + public virtual DateTime LastModified + { + get { return lastModified; } + set { lastModified = value; } + } + + public User() + { + } + + public User(string id, string pw, Person person) + { + this.userName = id; + this.password = pw; + this.person = person; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.hbm.xml 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping + xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.Component.Basic"> + + <class name="User" table="T_USER"> + <id name="UserName"/> + <timestamp name="LastModified"/> + <property name="Password" not-null="true" optimistic-lock="false"/> + <component name="Person"> + <property name="Name" update="false" not-null="true"/> + <property name="Dob" update="false" not-null="true"/> + <property name="Address"/> + <property name="PreviousAddress" insert="false"/> + <property name="Yob" formula="year(dob)"/> +<!-- + <property name="heightInches"> + <column name="height_centimeters" + not-null="true" + read="height_centimeters / 2.54" + write="? * 2.54"/> + </property> +--> + <property name="CurrentAddress" + column="address" + insert="false" + update="false"/> + </component> + </class> + + <class name="Employee" table="T_EMP"> + <id name="Id" type="long" column="ID"> + <generator class="increment"/> + </id> + <property name="HireDate" type="date" column="HIRE_DATE"/> + <component name="Person"> + <property name="Name" update="false" not-null="true"/> + <property name="Dob" update="false" not-null="true"/> + </component> + <component name="OptionalComponent"> + <property name="Value1" not-null="false"/> + <property name="Value2" not-null="false"/> + </component> + <set name="DirectReports" cascade="all-delete-orphan,merge" lazy="true"> + <key column="PARENT_ID" /> + <one-to-many class="Employee"/> + </set> + </class> + + <query name="userNameIn"><![CDATA[from User where Person.Name in (:nameList) or UserName in (:nameList)]]></query> + +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs 2010-07-15 16:20:51 UTC (rev 5007) +++ trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -1,7 +1,7 @@ using System; using System.Collections; +using NHibernate.Criterion; using NHibernate.DomainModel; -using NHibernate.Criterion; using NUnit.Framework; namespace NHibernate.Test.ExpressionTest @@ -174,7 +174,7 @@ Componentizable master = new Componentizable(); if (name != null) { - Component masterComp = new Component(); + NHibernate.DomainModel.Component masterComp = new NHibernate.DomainModel.Component(); masterComp.Name = name; if (subName != null || subName1 != null) { Modified: trunk/nhibernate/src/NHibernate.Test/Legacy/SQLLoaderTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Legacy/SQLLoaderTest.cs 2010-07-15 16:20:51 UTC (rev 5007) +++ trunk/nhibernate/src/NHibernate.Test/Legacy/SQLLoaderTest.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -457,7 +457,7 @@ Componentizable c = new Componentizable(); c.NickName = "Flacky"; - Component component = new Component(); + NHibernate.DomainModel.Component component = new NHibernate.DomainModel.Component(); component.Name = "flakky comp"; SubComponent subComponent = new SubComponent(); subComponent.SubName = "subway"; Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2010-07-15 16:20:51 UTC (rev 5007) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -71,7 +71,7 @@ Assert.That(compimplements, Is.Not.Null); Assert.That(compimplements.Value, Is.EqualTo("AnotherInterface")); - Property xp = ((Component)prop.Value).GetProperty("X"); + Property xp = ((NHibernate.Mapping.Component)prop.Value).GetProperty("X"); MetaAttribute propximplements = xp.GetMetaAttribute("implements"); Assert.That(propximplements, Is.Not.Null); Assert.That(propximplements.Value, Is.EqualTo("AnotherInterface")); @@ -97,7 +97,7 @@ assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/ Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount level")); - var component = (Component)property.Value; + var component = (NHibernate.Mapping.Component)property.Value; property = component.GetProperty("X"); propertyAttribute = property.GetMetaAttribute("globalmutated"); @@ -126,7 +126,7 @@ Assert.That(propertyAttribute.Value, Is.EqualTo("wicked level")); var bag = (Bag)property.Value; - component = (Component)bag.Element; + component = (NHibernate.Mapping.Component)bag.Element; Assert.That(component.MetaAttributes.Count, Is.EqualTo(4)); Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH2061 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void merge_with_many_to_many_inside_component_that_is_null() + { + // Order with null GroupComponent + Order newOrder = new Order(); + newOrder.GroupComponent = null; + + Order mergedCopy = null; + + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + mergedCopy = (Order)session.Merge(newOrder); + tx.Commit(); + } + + Assert.That(mergedCopy, Is.Not.Null); + Assert.That(mergedCopy.GroupComponent, Is.Null); + } + + protected override void OnTearDown() + { + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + session.Delete("from Order"); + session.Delete("from Country"); + tx.Commit(); + } + + base.OnTearDown(); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Mappings.hbm.xml 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH2061"> + + <class name="Order" table="Orders"> + <id name="Id" unsaved-value="00000000-0000-0000-0000-000000000000"> + <generator class="guid.comb"/> + </id> + <component name="GroupComponent"> + <bag name="Countries" table="OrderCountries" cascade="none" > + <key column="OrderId" /> + <many-to-many column="CountryCode" class="Country" /> + </bag> + </component> + </class> + + <class name="Country" table="Countries"> + <id name="CountryCode"> + <generator class="assigned"/> + </id> + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Model.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH2061 +{ + public class Order + { + public virtual Guid Id { get; set; } + public virtual GroupComponent GroupComponent { get; set; } + } + + public class GroupComponent + { + public virtual IList<Country> Countries { get; set; } + } + + public class Country + { + public virtual string CountryCode { 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 2010-07-15 16:20:51 UTC (rev 5007) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-18 15:05:47 UTC (rev 5008) @@ -132,6 +132,11 @@ <Compile Include="CollectionTest\IdBagFixture.cs" /> <Compile Include="CollectionTest\NullableValueTypeElementMapFixture.cs" /> <Compile Include="CollectionTest\Parent.cs" /> + <Compile Include="Component\Basic\ComponentTest.cs" /> + <Compile Include="Component\Basic\Employee.cs" /> + <Compile Include="Component\Basic\OptionalComponent.cs" /> + <Compile Include="Component\Basic\Person.cs" /> + <Compile Include="Component\Basic\User.cs" /> <Compile Include="CompositeCollection\BaseClassA.cs" /> <Compile Include="CompositeCollection\BaseClassB.cs" /> <Compile Include="CompositeCollection\ChildClassA.cs" /> @@ -443,6 +448,8 @@ <Compile Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Employee.cs" /> <Compile Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Fixture.cs" /> <Compile Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Money.cs" /> + <Compile Include="NHSpecificTest\NH2061\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2061\Model.cs" /> <Compile Include="NHSpecificTest\NH2069\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2069\ITest.cs" /> <Compile Include="NHSpecificTest\NH2069\ITest2.cs" /> @@ -1591,6 +1598,8 @@ <Compile Include="VersionTest\Task.cs" /> <Compile Include="VersionTest\Thing.cs" /> <Compile Include="VersionTest\VersionFixture.cs" /> + <None Include="Component\Basic\User.hbm.xml" /> + <None Include="NHSpecificTest\NH2061\Mappings.hbm.xml" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="CompositeCollection\BaseClassA.hbm.xml" /> @@ -1670,6 +1679,9 @@ <Project>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</Project> <Name>NHibernate</Name> </ProjectReference> + <Folder Include="Component" /> + <Folder Include="Component\Basic" /> + <Folder Include="NHSpecificTest\NH2061" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="NHSpecificTest\NH386\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jul...@us...> - 2010-07-15 16:20:58
|
Revision: 5007 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5007&view=rev Author: julian-maughan Date: 2010-07-15 16:20:51 +0000 (Thu, 15 Jul 2010) Log Message: ----------- Performance enhancement, reported as "MsSql2005Dialect does not use parameters for paging parameters" (ref. NH-2215). Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs trunk/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs trunk/nhibernate/src/NHibernate.Test/Pagination/CustomMsSqlDriver.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2010-07-15 15:16:31 UTC (rev 5006) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2010-07-15 16:20:51 UTC (rev 5007) @@ -45,7 +45,7 @@ public override SqlString GetLimitString(SqlString querySqlString, int offset, int last) { //dont do this paging code if there is no offset, use the - //sql 2000 dialect since it wont just uses a top statement + //sql 2000 dialect since it just uses a top statement if (offset == 0) { return base.GetLimitString(querySqlString, offset, last); @@ -76,11 +76,17 @@ sortExpressions = new[] {new SqlString("CURRENT_TIMESTAMP"),}; } + Parameter limitParameter = Parameter.Placeholder; + limitParameter.ParameterPosition = 0; + + Parameter offsetParameter = Parameter.Placeholder; + offsetParameter.ParameterPosition = 1; + SqlStringBuilder result = new SqlStringBuilder() - .Add("SELECT TOP ") - .Add(last.ToString()) - .Add(" ") + .Add("SELECT TOP (") + .Add(limitParameter) + .Add(") ") .Add(StringHelper.Join(", ", columnsOrAliases)) .Add(" FROM (") .Add(select) @@ -88,10 +94,12 @@ AppendSortExpressions(aliasToColumn, sortExpressions, result); - result.Add(") as __hibernate_sort_row ") - .Add(from) - .Add(") as query WHERE query.__hibernate_sort_row > ") - .Add(offset.ToString()).Add(" ORDER BY query.__hibernate_sort_row"); + result + .Add(") as __hibernate_sort_row ") + .Add(from) + .Add(") as query WHERE query.__hibernate_sort_row > ") + .Add(offsetParameter) + .Add(" ORDER BY query.__hibernate_sort_row"); return result.ToSqlString(); } @@ -106,8 +114,7 @@ return trimmedExpression.Trim(); } - private static void AppendSortExpressions(Dictionary<SqlString, SqlString> aliasToColumn, SqlString[] sortExpressions, - SqlStringBuilder result) + private static void AppendSortExpressions(Dictionary<SqlString, SqlString> aliasToColumn, SqlString[] sortExpressions, SqlStringBuilder result) { for (int i = 0; i < sortExpressions.Length; i++) { @@ -256,6 +263,21 @@ { get { return true; } } + + public override bool BindLimitParametersInReverseOrder + { + get { return true; } + } + + public override bool SupportsVariableLimit + { + get { return true; } + } + + public override bool BindLimitParametersFirst + { + get { return true; } + } protected override string GetSelectExistingObject(string name, Table table) { @@ -436,4 +458,3 @@ } } } - Modified: trunk/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs 2010-07-15 15:16:31 UTC (rev 5006) +++ trunk/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs 2010-07-15 16:20:51 UTC (rev 5007) @@ -19,37 +19,37 @@ SqlString str = d.GetLimitString(new SqlString("select distinct c.Contact_Id as Contact1_19_0_, c._Rating as Rating2_19_0_ from dbo.Contact c where COALESCE(c.Rating, 0) > 0 order by c.Rating desc , c.Last_Name , c.First_Name"), 1, 10); System.Console.WriteLine(str); Assert.AreEqual( - "SELECT TOP 10 Contact1_19_0_, Rating2_19_0_ FROM (select distinct c.Contact_Id as Contact1_19_0_, c._Rating as Rating2_19_0_, ROW_NUMBER() OVER(ORDER BY c.Rating DESC, c.Last_Name, c.First_Name) as __hibernate_sort_row from dbo.Contact c where COALESCE(c.Rating, 0) > 0) as query WHERE query.__hibernate_sort_row > 1 ORDER BY query.__hibernate_sort_row", + "SELECT TOP (?) Contact1_19_0_, Rating2_19_0_ FROM (select distinct c.Contact_Id as Contact1_19_0_, c._Rating as Rating2_19_0_, ROW_NUMBER() OVER(ORDER BY c.Rating DESC, c.Last_Name, c.First_Name) as __hibernate_sort_row from dbo.Contact c where COALESCE(c.Rating, 0) > 0) as query WHERE query.__hibernate_sort_row > ? ORDER BY query.__hibernate_sort_row", str.ToString()); str = d.GetLimitString(new SqlString("SELECT fish.id FROM fish"), 1, 10); System.Console.WriteLine(str); Assert.AreEqual( - "SELECT TOP 10 id FROM (SELECT fish.id, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > 1 ORDER BY query.__hibernate_sort_row", + "SELECT TOP (?) id FROM (SELECT fish.id, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > ? ORDER BY query.__hibernate_sort_row", str.ToString()); str = d.GetLimitString(new SqlString("SELECT DISTINCT fish_.id FROM fish fish_"), 1, 10); System.Console.WriteLine(str); Assert.AreEqual( - "SELECT TOP 10 id FROM (SELECT DISTINCT fish_.id, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish fish_) as query WHERE query.__hibernate_sort_row > 1 ORDER BY query.__hibernate_sort_row", + "SELECT TOP (?) id FROM (SELECT DISTINCT fish_.id, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish fish_) as query WHERE query.__hibernate_sort_row > ? ORDER BY query.__hibernate_sort_row", str.ToString()); str = d.GetLimitString(new SqlString("SELECT DISTINCT fish_.id as ixx9_ FROM fish fish_"), 1, 10); System.Console.WriteLine(str); Assert.AreEqual( - "SELECT TOP 10 ixx9_ FROM (SELECT DISTINCT fish_.id as ixx9_, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish fish_) as query WHERE query.__hibernate_sort_row > 1 ORDER BY query.__hibernate_sort_row", + "SELECT TOP (?) ixx9_ FROM (SELECT DISTINCT fish_.id as ixx9_, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish fish_) as query WHERE query.__hibernate_sort_row > ? ORDER BY query.__hibernate_sort_row", str.ToString()); str = d.GetLimitString(new SqlString("SELECT * FROM fish ORDER BY name"), 5, 15); System.Console.WriteLine(str); Assert.AreEqual( - "SELECT TOP 15 * FROM (SELECT *, ROW_NUMBER() OVER(ORDER BY name) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > 5 ORDER BY query.__hibernate_sort_row", + "SELECT TOP (?) * FROM (SELECT *, ROW_NUMBER() OVER(ORDER BY name) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > ? ORDER BY query.__hibernate_sort_row", str.ToString()); str = d.GetLimitString(new SqlString("SELECT fish.id, fish.name FROM fish ORDER BY name DESC"), 7, 28); System.Console.WriteLine(str); Assert.AreEqual( - "SELECT TOP 28 id, name FROM (SELECT fish.id, fish.name, ROW_NUMBER() OVER(ORDER BY fish.name DESC) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > 7 ORDER BY query.__hibernate_sort_row", + "SELECT TOP (?) id, name FROM (SELECT fish.id, fish.name, ROW_NUMBER() OVER(ORDER BY fish.name DESC) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > ? ORDER BY query.__hibernate_sort_row", str.ToString()); str = @@ -57,25 +57,25 @@ new SqlString("SELECT * FROM fish LEFT JOIN (SELECT * FROM meat ORDER BY weight) AS t ORDER BY name DESC"), 10, 20); System.Console.WriteLine(str); Assert.AreEqual( - "SELECT TOP 20 * FROM (SELECT *, ROW_NUMBER() OVER(ORDER BY name DESC) as __hibernate_sort_row FROM fish LEFT JOIN (SELECT * FROM meat ORDER BY weight) AS t) as query WHERE query.__hibernate_sort_row > 10 ORDER BY query.__hibernate_sort_row", + "SELECT TOP (?) * FROM (SELECT *, ROW_NUMBER() OVER(ORDER BY name DESC) as __hibernate_sort_row FROM fish LEFT JOIN (SELECT * FROM meat ORDER BY weight) AS t) as query WHERE query.__hibernate_sort_row > ? ORDER BY query.__hibernate_sort_row", str.ToString()); str = d.GetLimitString(new SqlString("SELECT *, (SELECT COUNT(1) FROM fowl WHERE fish_id = fish.id) AS some_count FROM fish"), 1, 10); System.Console.WriteLine(str); Assert.AreEqual( - "SELECT TOP 10 *, some_count FROM (SELECT *, (SELECT COUNT(1) FROM fowl WHERE fish_id = fish.id) AS some_count, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > 1 ORDER BY query.__hibernate_sort_row", + "SELECT TOP (?) *, some_count FROM (SELECT *, (SELECT COUNT(1) FROM fowl WHERE fish_id = fish.id) AS some_count, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > ? ORDER BY query.__hibernate_sort_row", str.ToString()); str = d.GetLimitString(new SqlString("SELECT * FROM fish WHERE scales = ", Parameter.Placeholder), 1, 10); System.Console.WriteLine(str); Assert.AreEqual( - "SELECT TOP 10 * FROM (SELECT *, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish WHERE scales = ?) as query WHERE query.__hibernate_sort_row > 1 ORDER BY query.__hibernate_sort_row", + "SELECT TOP (?) * FROM (SELECT *, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish WHERE scales = ?) as query WHERE query.__hibernate_sort_row > ? ORDER BY query.__hibernate_sort_row", str.ToString()); str = d.GetLimitString(new SqlString("SELECT f.Type, COUNT(DISTINCT f.Name) AS Name FROM Fish f GROUP BY f.Type ORDER BY COUNT(DISTINCT f.Name)"), 1, 10); System.Console.WriteLine(str); Assert.AreEqual( - "SELECT TOP 10 Type, Name FROM (SELECT f.Type, COUNT(DISTINCT f.Name) AS Name, ROW_NUMBER() OVER(ORDER BY COUNT(DISTINCT f.Name)) as __hibernate_sort_row FROM Fish f GROUP BY f.Type) as query WHERE query.__hibernate_sort_row > 1 ORDER BY query.__hibernate_sort_row", + "SELECT TOP (?) Type, Name FROM (SELECT f.Type, COUNT(DISTINCT f.Name) AS Name, ROW_NUMBER() OVER(ORDER BY COUNT(DISTINCT f.Name)) as __hibernate_sort_row FROM Fish f GROUP BY f.Type) as query WHERE query.__hibernate_sort_row > ? ORDER BY query.__hibernate_sort_row", str.ToString()); } @@ -97,14 +97,14 @@ SqlString result = d.GetLimitString(new SqlString("select concat(a.Description,', ', a.Description) as desc from Animal a"), 1, 10); System.Console.WriteLine(result); - Assert.AreEqual("SELECT TOP 10 desc FROM (select concat(a.Description,', ', a.Description) as desc, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row from Animal a) as query WHERE query.__hibernate_sort_row > 1 ORDER BY query.__hibernate_sort_row", result.ToString()); + Assert.AreEqual("SELECT TOP (?) desc FROM (select concat(a.Description,', ', a.Description) as desc, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row from Animal a) as query WHERE query.__hibernate_sort_row > ? ORDER BY query.__hibernate_sort_row", result.ToString()); // The test use the function "cast" because cast need the keyWork "as" too SqlString str = d.GetLimitString(new SqlString("SELECT fish.id, cast('astring, with,comma' as string) as bar FROM fish"), 1, 10); System.Console.WriteLine(str); Assert.AreEqual( - "SELECT TOP 10 id, bar FROM (SELECT fish.id, cast('astring, with,comma' as string) as bar, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > 1 ORDER BY query.__hibernate_sort_row", + "SELECT TOP (?) id, bar FROM (SELECT fish.id, cast('astring, with,comma' as string) as bar, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > ? ORDER BY query.__hibernate_sort_row", str.ToString()); } [Test] Modified: trunk/nhibernate/src/NHibernate.Test/Pagination/CustomMsSqlDriver.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Pagination/CustomMsSqlDriver.cs 2010-07-15 15:16:31 UTC (rev 5006) +++ trunk/nhibernate/src/NHibernate.Test/Pagination/CustomMsSqlDriver.cs 2010-07-15 16:20:51 UTC (rev 5007) @@ -22,11 +22,11 @@ int offset = (int)((IDataParameter)command.Parameters[0]).Value; int limit = (int)((IDataParameter)command.Parameters[1]).Value; - Assert.That(command.CommandText.ToLower().Contains("top " + limit), - "Expected string containing 'top " + limit + "', but got " + command.CommandText); + Assert.That(command.CommandText.ToLower().Contains("top (@p0)"), + "Expected string containing 'top (@p0)', but got " + command.CommandText); - Assert.That(command.CommandText.ToLower().Contains("hibernate_sort_row > " + offset), - "Expected string containing 'hibernate_sort_row > " + offset + "', but got " + command.CommandText); + Assert.That(command.CommandText.ToLower().Contains("hibernate_sort_row > @p1"), + "Expected string containing 'hibernate_sort_row > @p1', but got " + command.CommandText); } base.OnBeforePrepare(command); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |