Skip to content

Commit 28cf6c8

Browse files
committed
Added a test case for bug with component of entity-name mapped entity
(NH-3757)
1 parent d229631 commit 28cf6c8

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Collections.Generic;
2+
using NUnit.Framework;
3+
4+
namespace NHibernate.Test.NHSpecificTest.NH3757
5+
{
6+
[TestFixture]
7+
public class Fixture : BugTestCase
8+
{
9+
protected override void OnTearDown()
10+
{
11+
using (ISession s = OpenSession())
12+
{
13+
using (ITransaction tx = s.BeginTransaction())
14+
{
15+
s.CreateSQLQuery("delete from EntityName").ExecuteUpdate();
16+
tx.Commit();
17+
}
18+
}
19+
}
20+
21+
[Test]
22+
public void ShouldBePossibleToHaveComponentInEntityNameMappedEntity()
23+
{
24+
using (ISession session = OpenSession())
25+
using (ITransaction transaction = session.BeginTransaction())
26+
{
27+
var e1 = new Dictionary<string, object>();
28+
e1["Money"] = new Money { Amount = 100m, Currency = "USD" };
29+
session.Save("EntityName", e1);
30+
31+
session.Flush();
32+
transaction.Commit();
33+
}
34+
}
35+
}
36+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH3757">
3+
4+
<class entity-name="EntityName">
5+
<id name="Id" type="Int32" generator="native" />
6+
<component name="Money" class="Money">
7+
<property name="Amount" type="decimal"/>
8+
<property name="Currency" type="string"/>
9+
</component>
10+
</class>
11+
12+
</hibernate-mapping>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace NHibernate.Test.NHSpecificTest.NH3757
2+
{
3+
public class Money
4+
{
5+
public virtual decimal Amount { get; set; }
6+
7+
public virtual string Currency { get; set; }
8+
}
9+
}

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,8 @@
12011201
<Compile Include="NHSpecificTest\NH2860\SampleTest.cs" />
12021202
<Compile Include="NHSpecificTest\NH3641\Domain.cs" />
12031203
<Compile Include="NHSpecificTest\NH3641\TestFixture.cs" />
1204+
<Compile Include="NHSpecificTest\NH3757\Fixture.cs" />
1205+
<Compile Include="NHSpecificTest\NH3757\Money.cs" />
12041206
<Compile Include="NHSpecificTest\Properties\CompositePropertyRefTest.cs" />
12051207
<Compile Include="NHSpecificTest\Properties\DynamicEntityTest.cs" />
12061208
<Compile Include="NHSpecificTest\Properties\Model.cs" />
@@ -3073,6 +3075,7 @@
30733075
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
30743076
</ItemGroup>
30753077
<ItemGroup>
3078+
<EmbeddedResource Include="NHSpecificTest\NH3757\Mappings.hbm.xml" />
30763079
<EmbeddedResource Include="LazyComponentTest\Person.hbm.xml" />
30773080
<EmbeddedResource Include="NHSpecificTest\NH3570\Mappings.hbm.xml" />
30783081
<EmbeddedResource Include="NHSpecificTest\NH3455\Mappings.hbm.xml" />

0 commit comments

Comments
 (0)