From: <fab...@us...> - 2010-07-23 04:39:06
|
Revision: 5052 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5052&view=rev Author: fabiomaulo Date: 2010-07-23 04:38:56 +0000 (Fri, 23 Jul 2010) Log Message: ----------- Fix NH-2041 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs trunk/nhibernate/src/NHibernate/Mapping/Component.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2041/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2041/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2041/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2041/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs 2010-07-23 03:51:24 UTC (rev 5051) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs 2010-07-23 04:38:56 UTC (rev 5052) @@ -114,7 +114,7 @@ else if ((componentMapping = entityPropertyMapping as HbmComponent) != null) { string subpath = propertyName == null ? null : StringHelper.Qualify(propertyBasePath, propertyName); - var value = CreateNewComponent(); + var value = CreateNewComponent(table); // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute System.Type reflectedClass = mappedClass == null ? null : GetPropertyType(componentMapping.Class, mappedClass, propertyName, componentMapping.Access); BindComponent(componentMapping, value, reflectedClass, entityName, subpath, componetDefaultNullable, inheritedMetas); @@ -131,7 +131,7 @@ else if ((dynamicComponentMapping = entityPropertyMapping as HbmDynamicComponent) != null) { string subpath = propertyName == null ? null : StringHelper.Qualify(propertyBasePath, propertyName); - var value = CreateNewComponent(); + var value = CreateNewComponent(table); // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute System.Type reflectedClass = mappedClass == null ? null : GetPropertyType(dynamicComponentMapping.Class, mappedClass, propertyName, dynamicComponentMapping.Access); BindComponent(dynamicComponentMapping, value, reflectedClass, entityName, subpath, componetDefaultNullable, inheritedMetas); @@ -152,7 +152,7 @@ throw new AssertionFailure("Nested Composite Element without a owner component."); } string subpath = propertyName == null ? null : StringHelper.Qualify(propertyBasePath, propertyName); - var value = CreateNewComponent(); + var value = CreateNewComponent(table); // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute System.Type reflectedClass = mappedClass == null ? null : GetPropertyType(nestedCompositeElementMapping.Class, mappedClass, propertyName, nestedCompositeElementMapping.access); BindComponent(nestedCompositeElementMapping, value, reflectedClass, entityName, subpath, componetDefaultNullable, inheritedMetas); @@ -180,10 +180,10 @@ } } - private Component CreateNewComponent() + private Component CreateNewComponent(Table table) { // Manage nested components - return component != null ? new Component(component) : new Component(persistentClass); + return component != null ? new Component(component) : new Component(table, persistentClass); } private System.Type GetPropertyType(string classMapping, System.Type containingType, string propertyName, string propertyAccess) Modified: trunk/nhibernate/src/NHibernate/Mapping/Component.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/Component.cs 2010-07-23 03:51:24 UTC (rev 5051) +++ trunk/nhibernate/src/NHibernate/Mapping/Component.cs 2010-07-23 04:38:56 UTC (rev 5052) @@ -92,18 +92,18 @@ this.owner = owner; } + public Component(Table table, PersistentClass owner) + : base(table) + { + this.owner = owner; + } + public Component(Collection collection) : base(collection.CollectionTable) { owner = collection.Owner; } - public Component(Join join) - : base(join.Table) - { - owner = join.PersistentClass; - } - public Component(Component component) : base(component.Table) { Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2041/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2041/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2041/Domain.cs 2010-07-23 04:38:56 UTC (rev 5052) @@ -0,0 +1,13 @@ +namespace NHibernate.Test.NHSpecificTest.NH2041 +{ + public class MyClass + { + public Coordinates Location { get; set; } + } + + public class Coordinates + { + public decimal Latitude { get; set; } + public decimal Longitude { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2041/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2041/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2041/Fixture.cs 2010-07-23 04:38:56 UTC (rev 5052) @@ -0,0 +1,21 @@ +using System.Linq; +using NUnit.Framework; +using NHibernate.Cfg; +using SharpTestsEx; + +namespace NHibernate.Test.NHSpecificTest.NH2041 +{ + public class Fixture + { + [Test] + public void WhenJoinTableContainComponentsThenColumnsShouldBeInJoinedTable() + { + Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); + cfg.AddResource("NHibernate.Test.NHSpecificTest.NH2041.Mappings.hbm.xml", GetType().Assembly); + var mappings = cfg.CreateMappings(Dialect.Dialect.GetDialect(cfg.Properties)); + var table = mappings.GetTable(null, null, "Locations"); + table.Should().Not.Be.Null(); + table.ColumnIterator.Select(c => c.Name).Should().Have.SameValuesAs("myclassId", "latitudecol", "longitudecol"); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2041/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2041/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2041/Mappings.hbm.xml 2010-07-23 04:38:56 UTC (rev 5052) @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH2041" + assembly="NHibernate.Test"> + + <class name="MyClass"> + <id type="int"> + <generator class="hilo" /> + </id> + <join table="Locations"> + <key column="myclassId"/> + <component name="Location"> + <property name="Latitude" column="latitudecol"/> + <property name="Longitude" column="longitudecol"/> + </component> + </join> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-23 03:51:24 UTC (rev 5051) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-23 04:38:56 UTC (rev 5052) @@ -453,6 +453,8 @@ <Compile Include="NHSpecificTest\NH1891\B.cs" /> <Compile Include="NHSpecificTest\NH1891\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2031\HqlModFuctionForMsSqlTest.cs" /> + <Compile Include="NHSpecificTest\NH2041\Domain.cs" /> + <Compile Include="NHSpecificTest\NH2041\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2061\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2061\Model.cs" /> <Compile Include="NHSpecificTest\NH2069\Fixture.cs" /> @@ -2204,6 +2206,7 @@ <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2041\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2031\Mappings.hbm.xml" /> <EmbeddedResource Include="TypesTest\DateClass.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2207\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |