|
From: <fab...@us...> - 2009-03-28 20:15:11
|
Revision: 4159
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4159&view=rev
Author: fabiomaulo
Date: 2009-03-28 20:15:05 +0000 (Sat, 28 Mar 2009)
Log Message:
-----------
Fix NH-1700
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1700/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1700/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1700/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1700/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2009-03-28 19:07:03 UTC (rev 4158)
+++ trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2009-03-28 20:15:05 UTC (rev 4159)
@@ -315,17 +315,25 @@
public Table AddDenormalizedTable(string schema, string catalog, string name, bool isAbstract, string subselect, Table includedTable)
{
string key = subselect ?? dialect.Qualify(schema, catalog, name);
- if (tables.ContainsKey(key))
+
+ Table table = new DenormalizedTable(includedTable)
+ {
+ IsAbstract = isAbstract,
+ Name = name,
+ Catalog = catalog,
+ Schema = schema,
+ Subselect = subselect
+ };
+
+ Table existing;
+ if (tables.TryGetValue(key, out existing))
{
- throw new DuplicateMappingException("table", name);
+ if (existing.IsPhysicalTable)
+ {
+ throw new DuplicateMappingException("table", name);
+ }
}
- Table table = new DenormalizedTable(includedTable);
- table.IsAbstract = isAbstract;
- table.Name = name;
- table.Catalog = catalog;
- table.Schema = schema;
- table.Subselect = subselect;
tables[key] = table;
return table;
}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1700/Domain.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1700/Domain.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1700/Domain.cs 2009-03-28 20:15:05 UTC (rev 4159)
@@ -0,0 +1,16 @@
+namespace NHibernate.Test.NHSpecificTest.NH1700
+{
+ public class PayrollSegment
+ {
+ public virtual string Id { get; set; }
+ }
+ public class ActualPayrollSegment : PayrollSegment
+ {
+ }
+ public class ProjectedPayrollSegment : PayrollSegment
+ {
+ }
+ public class ClosedPayrollSegment : PayrollSegment
+ {
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1700/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1700/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1700/Fixture.cs 2009-03-28 20:15:05 UTC (rev 4159)
@@ -0,0 +1,23 @@
+using NHibernate.Cfg;
+using NHibernate.Tool.hbm2ddl;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1700
+{
+ [TestFixture]
+ public class Fixture
+ {
+ [Test]
+ public void ShouldNotThrowDuplicateMapping()
+ {
+ var cfg = new Configuration();
+ if (TestConfigurationHelper.hibernateConfigFile != null)
+ cfg.Configure(TestConfigurationHelper.hibernateConfigFile);
+
+ cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1700.Mappings.hbm.xml", GetType().Assembly);
+ new SchemaExport(cfg).Create(false, true);
+
+ new SchemaExport(cfg).Drop(false, true);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1700/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1700/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1700/Mappings.hbm.xml 2009-03-28 20:15:05 UTC (rev 4159)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1700">
+
+ <class name="PayrollSegment" abstract="true" polymorphism="explicit">
+ <id name="Id" column="PayrollSegmentKey"/>
+ <union-subclass name="ActualPayrollSegment" table="PayrollSegment"/>
+ <union-subclass name="ProjectedPayrollSegment" table="ProjectedPayrollSegment"/>
+ <union-subclass name="ClosedPayrollSegment" table="ClosedPayrollSegment"/>
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-28 19:07:03 UTC (rev 4158)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-28 20:15:05 UTC (rev 4159)
@@ -297,6 +297,8 @@
<Compile Include="NHSpecificTest\NH1693\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1693\Model.cs" />
<Compile Include="NHSpecificTest\NH1694\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1700\Domain.cs" />
+ <Compile Include="NHSpecificTest\NH1700\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1706\Domain.cs" />
<Compile Include="NHSpecificTest\NH1706\KeyPropertyRefFixture.cs" />
<Compile Include="NHSpecificTest\NH1710\Fixture.cs" />
@@ -1698,6 +1700,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1700\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1693\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1710\WithColumnNode.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1710\InLine.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|